diff --git a/lib/_source/a2_starter.ahk b/lib/_source/a2_starter.ahk index 9c153bc7..fdfdd3cd 100644 --- a/lib/_source/a2_starter.ahk +++ b/lib/_source/a2_starter.ahk @@ -32,12 +32,12 @@ a2.cfg := a2_get_user_config(a2data) if (A_Args.Length) { args := _gather_args() - Run "%a2_ahk%" "%lib_path%\a2.ahk" %args%, %root_path% + Run '"' a2_ahk '" "' lib_path '\a2.ahk" ' args, root_path } else - Run "%a2_ahk%" "%lib_path%\a2.ahk", %root_path% + Run '"' a2_ahk '" "' lib_path '\a2.ahk"', root_path -check_load_time_errors(lib_path) +; check_load_time_errors(lib_path) If !FileExist(path_join(root_path, "_ user_data_include")) { ; Start the ui by default if there is no include file written yet. diff --git a/lib/a2.ahk b/lib/a2.ahk index aed0af23..b865d7fc 100644 --- a/lib/a2.ahk +++ b/lib/a2.ahk @@ -1,25 +1,31 @@ ; a2 - modular Autohotkey script envirionment ; main file! This gathers all the runtime resources #SingleInstance force -#Persistent +Persistent #NoTrayIcon -#include -#include - -#include lib\a2_core.ahk -#include lib\a2_config.ahk -#include lib\a2_globals.ahk -#include lib\a2_urls.ahk -#include lib\a2_exceptions.ahk -#include lib\a2_user_data.ahk +#include +#include +#include +#include +#include +#include +#include +#include + +#include a2_core.ahk +#include a2_config.ahk +#include a2_globals.ahk +#include a2_urls.ahk +#include a2_exceptions.ahk +#include a2_user_data.ahk ; build essential paths and objects root_dir := path_dirname(A_ScriptDir) "\" data_dir := a2_get_user_data_path(root_dir) -global a2 := new A2Core_Class(data_dir) +global a2 := A2Core_Class(data_dir) a2.cfg := a2_get_user_config(data_dir) -SetWorkingDir % a2.paths.a2 +SetWorkingDir a2.paths.a2 _a2_check_arguments() _a2_build_tray_menu(a2_title) @@ -28,7 +34,7 @@ if !a2.cfg.no_startup_tooltip a2tip(a2_title) if a2.cfg.auto_reload - SetTimer, _a2_check_changes, 1000 + SetTimer _a2_check_changes, 1000 OnExit("a2ui_exit") OnError("a2_on_runtime_exception") @@ -43,15 +49,15 @@ a2ui() { a2tip(tt_text) a2_win_id := WinExist("a2 ahk_class Qt623QWindowIcon ahk_exe pythonw.exe") if (a2_win_id) - WinActivate, ahk_id %a2_win_id% + WinActivate "ahk_id " a2_win_id else { ui_starter := path_join(a2.paths.a2, "a2ui.exe") - Run, "%ui_starter%" + Run ui_starter } } a2ui_help() { - Run, %a2_help% + Run a2_help } a2ui_reload() { @@ -60,7 +66,7 @@ a2ui_reload() { a2ui_exit() { exit_func := "a2_exit_calls" - if IsFunc(exit_func) + if IsObject(exit_func) %exit_func%() ExitApp } @@ -78,19 +84,18 @@ _a2_check_changes() { ; Removes the attribute from all files and returns true if any was found do_reload := false for _, libdir in [a2.paths.lib, a2.paths.ahklib] { - pattern := string_suffix(libdir, "\") "*.ahk" - Loop, Files, %pattern% + Loop Files, string_suffix(libdir, "\") "*.ahk" { num_files++ If InStr(A_LoopFileAttrib, "A") { do_reload := true - FileSetAttrib, -A, %A_LoopFileFullpath% + FileSetAttrib "-A", A_LoopFileFullpath a2log_debug("Changed lib file: " A_LoopFileFullPath) } } } - Loop, read, % a2.paths.includes + Loop read a2.paths.includes { if !string_startswith(A_LoopReadLine, "#include ") Continue @@ -99,7 +104,7 @@ _a2_check_changes() { if InStr(FileGetAttrib(path), "A") { do_reload := true a2log_debug("Changed include file: " path) - FileSetAttrib, -A, %path% + FileSetAttrib "-A", path } } @@ -114,30 +119,32 @@ _a2_check_arguments() { if (arg == "--shutdown") ExitApp else - MsgBox, a2, Arguments handling is WIP!`nWhat's "%arg%"? + MsgBox("Arguments handling is WIP!`nWhat's '" arg "'?", "a2") } } _a2_build_tray_menu(a2_title) { ; Build the tray icon menu. - a2ui_res := a2.paths.resources - Menu, Tray, Icon, %a2ui_res%a2.ico, , 1 - Menu, Tray, Icon - Gui, 1:Destroy - - Menu, Tray, NoStandard - Menu, Tray, DeleteAll - Menu, Tray, Tip, %a2_title% - Menu, Tray, Click, 1 - Menu, Tray, add, Open a2 User Interface, a2ui - Menu, Tray, icon, Open a2 User Interface, %a2ui_res%a2.ico - Menu, Tray, default, Open a2 User Interface - Menu, Tray, add, Open a2 Directory, a2_explore - Menu, Tray, icon, Open a2 Directory, %a2ui_res%a2.ico - Menu, Tray, add, Reload a2 Runtime, a2ui_reload - Menu, Tray, icon, Reload a2 Runtime, %a2ui_res%a2reload.ico - Menu, Tray, add, Help on a2, a2ui_help - Menu, Tray, icon, Help on a2, %a2ui_res%a2help.ico - Menu, Tray, add, Quit a2 Runtime, _a2ui_exit - Menu, Tray, icon, Quit a2 Runtime, %a2ui_res%a2x.ico + ; a2ui_res := a2.paths.resources + TraySetIcon(path_join(a2.paths.resources, "a2.ico")) + ; A_TrayMenu.Add + ; Menu Tray, Icon, %a2ui_res%a2.ico, , 1 + ; Menu Tray, Icon + ; Gui 1:Destroy + + ; Menu Tray, NoStandard + ; Menu Tray, DeleteAll + ; Menu Tray, Tip, %a2_title% + ; Menu Tray, Click, 1 + ; Menu Tray, add, Open a2 User Interface, a2ui + ; Menu Tray, icon, Open a2 User Interface, %a2ui_res%a2.ico + ; Menu Tray, default, Open a2 User Interface + ; Menu Tray, add, Open a2 Directory, a2_explore + ; Menu Tray, icon, Open a2 Directory, %a2ui_res%a2.ico + ; Menu Tray, add, Reload a2 Runtime, a2ui_reload + ; Menu Tray, icon, Reload a2 Runtime, %a2ui_res%a2reload.ico + ; Menu Tray, add, Help on a2, a2ui_help + ; Menu Tray, icon, Help on a2, %a2ui_res%a2help.ico + ; Menu Tray, add, Quit a2 Runtime, _a2ui_exit + ; Menu Tray, icon, Quit a2 Runtime, %a2ui_res%a2x.ico } diff --git a/lib/a2_config.ahk b/lib/a2_config.ahk index f9708fd7..b40df20e 100644 --- a/lib/a2_config.ahk +++ b/lib/a2_config.ahk @@ -1,2 +1,2 @@ -SetTitleMatchMode, 2 +SetTitleMatchMode 2 a2_title := "a2 - dev_version 0.5.4" diff --git a/lib/a2_core.ahk b/lib/a2_core.ahk index 597a181d..f26e42bd 100644 --- a/lib/a2_core.ahk +++ b/lib/a2_core.ahk @@ -1,4 +1,4 @@ -#include +#include Autohotkey\lib\Class_SQliteDB.ahk /** * a2 global object definition */ @@ -19,10 +19,14 @@ class A2Core_Class { this.title := "a2" - root_dir := path_dirname(A_ScriptDir) "\" + if (A_ScriptName = "a2.exe") + root_dir := A_ScriptDir "\" + else + root_dir := path_dirname(A_ScriptDir) "\" + this.paths := {a2: root_dir - ,lib: A_ScriptDir "\" - ,ahklib: A_ScriptDir "\Autohotkey\lib\" + ,lib: root_dir "lib\" + ,ahklib: root_dir "lib\Autohotkey\lib\" ,ui: root_dir "ui\" ,resources: root_dir "ui\res\" ,data: data_path @@ -34,356 +38,357 @@ class A2Core_Class this.cfg := {} this._check_sqlite() - this.db := this.Ca2DB(data_path) + this.db := _Ca2DB(data_path) } - /** - * API for modules to inteact with the DB - */ - class Ca2DB - { - /** - * Path to the DB file of the a2 instance - * - * @type string - */ - static path := "" - - /** - * Constructor - * Opens connection to the DB - */ - __New(data_path) - { - this.path := data_path "a2.db" - ; Ensure the DB file does exist - if (!FileExist(this.path)) - { - db_file := FileOpen(this.path, "w") - db_file.Write("") - db_file.Close() - } + _check_sqlite() { + ; make sure the SQLlite-dll can be found + ini_path := path_join(this.paths.lib, "SQLiteDB.ini") + if (FileExist(ini_path)) + Return - this.dbObject := SQLiteDB() - } + sqldll := "SQLite3.dll" + dll_path := path_join(this.paths.ui, sqldll) - /** - * Destructor - * Closes the connection to the DB - */ - __Delete() - { - this.dbObject.CloseDB() + if (!FileExist(dll_path)) { + msg := 'The "' sqldll '" must exist here:`n' dll_path '!`n`nWhere is it?' + msgbox_error(msg, sqldll ' missing?!') + Return } - /** - * Get the value of key from the DB - * Entry in DB is a key/value pair - * - * @param string modulePack Name of the Module Pack that called the method - * @param string moduleName Name of the Module that called the method - * @param string key Name of the key in the Table - * @return string - */ - get(modulePack, moduleName, key) - { - moduleTable := this.__moduleTable(modulePack, moduleName) - this.__validateTable(moduleTable) ; will throw an error if invalid - return this.__get(moduleTable, key) - } + ini_code := "[Main]`nDllPath=" dll_path + FileAppend(ini_code, ini_path) + } +} - /** - * From a A_LineFile path build the module key and fetch the wanted value. - * Entry in DB is a key/value pair. - * - * @param string line_file Path to a file in a module directory. - * @param string key Name of the key in the Table. - * @return string - */ - find(line_file, key) { - moduleTable := this.__moduleTableFromFile(line_file) - this.__validateTable(moduleTable) - return this.__get(moduleTable, key) - } - /** - * Set a new value to a key from the DB - * Entry in DB is a key/value pair - * - * @param string modulePack Name of the Module Pack that called the method - * @param string moduleName Name of the Module that called the method - * @param string key Name of the key in the Table - * @param string value Value to be set in the Table - */ - set(modulePack, moduleName, key, value) +/** + * API for modules to inteact with the DB +*/ +class _Ca2DB +{ + /** + * Path to the DB file of the a2 instance + * + * @type string + */ + static path := "" + + /** + * Constructor + * Opens connection to the DB + */ + __New(data_path) + { + this.path := data_path "a2.db" + ; Ensure the DB file does exist + if (!FileExist(this.path)) { - moduleTable := this.__moduleTable(modulePack, moduleName) + db_file := FileOpen(this.path, "w") + db_file.Write("") + db_file.Close() + } - this.__validateTable(moduleTable) ; will throw an error if invalid + this.dbObject := SQLiteDB() + } - if (this.get(modulePack, moduleName, key)) - this.__update(moduleTable, key, value) - else - this.__insert(moduleTable, key, value) - } + /** + * Destructor + * Closes the connection to the DB + */ + __Delete() + { + this.dbObject.CloseDB() + } - /** - * From a A_LineFile path build the module key and set the according value. - * Entry in DB is a key/value pair. - * - * @param string line_file Path to a file in a module directory. - * @param string key Name of the key in table. - * @param string value Value to be set in table. - * @return string - */ - find_set(line_file, key, value) { - moduleTable := this.__moduleTableFromFile(line_file) - this.__validateTable(moduleTable) - if (this.__get(moduleTable, key)) - this.__update(moduleTable, key, value) - else - this.__insert(moduleTable, key, value) - } + /** + * Get the value of key from the DB + * Entry in DB is a key/value pair + * + * @param string modulePack Name of the Module Pack that called the method + * @param string moduleName Name of the Module that called the method + * @param string key Name of the key in the Table + * @return string + */ + get(modulePack, moduleName, key) + { + moduleTable := this.__moduleTable(modulePack, moduleName) + this.__validateTable(moduleTable) ; will throw an error if invalid + return this.__get(moduleTable, key) + } - /** - * Delete a row from the table in the DB - * based on the key name - * - * @param string modulePack Name of the Module Pack that called the method - * @param string moduleName Name of the Module that called the method - * @param string key Name of the key in the Table - */ - delete(modulePack, moduleName, key) - { - moduleTable := this.__moduleTable(modulePack, moduleName) + /** + * From a A_LineFile path build the module key and fetch the wanted value. + * Entry in DB is a key/value pair. + * + * @param string line_file Path to a file in a module directory. + * @param string key Name of the key in the Table. + * @return string + */ + find(line_file, key) { + moduleTable := this.__moduleTableFromFile(line_file) + this.__validateTable(moduleTable) + return this.__get(moduleTable, key) + } - this.__validateTable(moduleTable) ; will throw an error if invalid + /** + * Set a new value to a key from the DB + * Entry in DB is a key/value pair + * + * @param string modulePack Name of the Module Pack that called the method + * @param string moduleName Name of the Module that called the method + * @param string key Name of the key in the Table + * @param string value Value to be set in the Table + */ + set(modulePack, moduleName, key, value) + { + moduleTable := this.__moduleTable(modulePack, moduleName) - this.__remove(moduleTable, key) - } + this.__validateTable(moduleTable) ; will throw an error if invalid - /** - * Increment the value of a key by a specific amount - * - Value MUST be numeric/integer - * - Amount can be negative - * - If the key was non-existing, it will be creted with value = amount - * - * @param string modulePack Name of the Module Pack that called the method - * @param string moduleName Name of the Module that called the method - * @param string key Name of the key in the Table - * @param integer step Amount to increase the value by - * @return integer Value after adding the amount - */ - increment(modulePack, moduleName, key, step := 1) - { - ; if step is not number - ; return -1 + if (this.get(modulePack, moduleName, key)) + this.__update(moduleTable, key, value) + else + this.__insert(moduleTable, key, value) + } - moduleTable := this.__moduleTable(modulePack, moduleName) + /** + * From a A_LineFile path build the module key and set the according value. + * Entry in DB is a key/value pair. + * + * @param string line_file Path to a file in a module directory. + * @param string key Name of the key in table. + * @param string value Value to be set in table. + * @return string + */ + find_set(line_file, key, value) { + moduleTable := this.__moduleTableFromFile(line_file) + this.__validateTable(moduleTable) + if (this.__get(moduleTable, key)) + this.__update(moduleTable, key, value) + else + this.__insert(moduleTable, key, value) + } - this.__validateTable(moduleTable) ; will throw an error if invalid + /** + * Delete a row from the table in the DB + * based on the key name + * + * @param string modulePack Name of the Module Pack that called the method + * @param string moduleName Name of the Module that called the method + * @param string key Name of the key in the Table + */ + delete(modulePack, moduleName, key) + { + moduleTable := this.__moduleTable(modulePack, moduleName) - currentValue := this.__get(moduleTable, key) + this.__validateTable(moduleTable) ; will throw an error if invalid - ; if currentValue is not number - ; return -2 + this.__remove(moduleTable, key) + } - value := ((currentValue) ? currentValue : 0) + step + /** + * Increment the value of a key by a specific amount + * - Value MUST be numeric/integer + * - Amount can be negative + * - If the key was non-existing, it will be creted with value = amount + * + * @param string modulePack Name of the Module Pack that called the method + * @param string moduleName Name of the Module that called the method + * @param string key Name of the key in the Table + * @param integer step Amount to increase the value by + * @return integer Value after adding the amount + */ + increment(modulePack, moduleName, key, step := 1) + { + ; if step is not number + ; return -1 - this.set(modulePack, moduleName, key, value) + moduleTable := this.__moduleTable(modulePack, moduleName) - return value - } + this.__validateTable(moduleTable) ; will throw an error if invalid - /** - * Private Method - * Get value from Table row - * Only supports 1 entry - * - * @param string moduleTable Name of the Table - * @param string key Value in column "key" - * @return string - */ - __get(moduleTable, key) - { - this.__openConnection() + currentValue := this.__get(moduleTable, key) - row := "" - result := "" - recordSet := "" + ; if currentValue is not number + ; return -2 - sql := "SELECT value FROM '" moduleTable "' WHERE key = '" key "'" - this.dbObject.Query(sql, recordSet) ; no error handle + value := ((currentValue) ? currentValue : 0) + step - if (recordSet.HasRows) - { - Loop(recordSet.HasRows) - { - recordSet.next(row) - result := row[1] - } - } - recordSet.Free() + this.set(modulePack, moduleName, key, value) - ; Close connection to DB to unlock the file - this.__closeConnection() + return value + } - return (result) ? result : false - } + /** + * Private Method + * Get value from Table row + * Only supports 1 entry + * + * @param string moduleTable Name of the Table + * @param string key Value in column "key" + * @return string + */ + __get(moduleTable, key) + { + this.__openConnection() - /** - * Private Method - * Set value to Table row - * Only supports 1 entry - * - * @param string moduleTable Name of the Table - * @param string key Value for column "key" - * @param string value Value for column "value" - */ - __insert(moduleTable, key, value) - { - this.__openConnection() + row := "" + result := "" + recordSet := "" - sql := "INSERT INTO '" moduleTable "' ('key', 'value') VALUES ('" key "', '" value "')" - if (!this.dbObject.Exec(sql)) - throw Error("[" this.dbObject.ErrorCode "] " this.dbObject.ErrorMsg, -1) + sql := "SELECT value FROM '" moduleTable "' WHERE key = '" key "'" + this.dbObject.Query(sql, recordSet) ; no error handle - ; Close connection to DB to unlock the file - this.__closeConnection() + if (recordSet.HasRows) + { + Loop(recordSet.HasRows) + { + recordSet.next(row) + result := row[1] + } } + recordSet.Free() - /** - * Private Method - * Update value in Table row - * Only supports 1 entry - * - * @param string moduleTable Name of the Table - * @param string key Value in column "key" - * @param string value Value for column "value" - */ - __update(moduleTable, key, value) - { - this.__openConnection() + ; Close connection to DB to unlock the file + this.__closeConnection() - sql := "UPDATE '" moduleTable "' set value = '" value "' WHERE key = '" key "'" - if (!this.dbObject.Exec(sql)) - throw Error("[" this.dbObject.ErrorCode "] " this.dbObject.ErrorMsg, -1) + return (result) ? result : false + } - ; Close connection to DB to unlock the file - this.__closeConnection() - } + /** + * Private Method + * Set value to Table row + * Only supports 1 entry + * + * @param string moduleTable Name of the Table + * @param string key Value for column "key" + * @param string value Value for column "value" + */ + __insert(moduleTable, key, value) + { + this.__openConnection() - /** - * Private Method - * Delete row from Table - * Renamed, as __delete() is the destructor - * - * @param string moduleTable Name of the Table - * @param string key Value in column "key" - */ - __remove(moduleTable, key) - { - this.__openConnection() + sql := "INSERT INTO '" moduleTable "' ('key', 'value') VALUES ('" key "', '" value "')" + if (!this.dbObject.Exec(sql)) + throw Error("[" this.dbObject.ErrorCode "] " this.dbObject.ErrorMsg, -1) - sql := "DELETE FROM '" moduleTable "' WHERE key = '" key "'" - if (!this.dbObject.Exec(sql)) - throw Error("[" this.dbObject.ErrorCode "] " this.dbObject.ErrorMsg, -1) + ; Close connection to DB to unlock the file + this.__closeConnection() + } - ; Close connection to DB to unlock the file - this.__closeConnection() - } + /** + * Private Method + * Update value in Table row + * Only supports 1 entry + * + * @param string moduleTable Name of the Table + * @param string key Value in column "key" + * @param string value Value for column "value" + */ + __update(moduleTable, key, value) + { + this.__openConnection() - /** - * Private Method - * Generate the Table name based on the module - * that called the method - * - * @param string modulePack Name of the Module Pack that called the method - * @param string moduleName Name of the Module that called the method - * @return string - */ - __moduleTable(modulePack, moduleName) - { - return modulePack "|" moduleName - } + sql := "UPDATE '" moduleTable "' set value = '" value "' WHERE key = '" key "'" + if (!this.dbObject.Exec(sql)) + throw Error("[" this.dbObject.ErrorCode "] " this.dbObject.ErrorMsg, -1) - __moduleTableFromFile(line_file) { - parts := StrSplit(line_file, "\") - num_parts := parts.Length() - if num_parts < 3 - throw Error('Unusable path input! Cannot find db entry from "' line_file '"!', -1) - return this.__moduleTable(parts[num_parts - 2], parts[num_parts - 1]) - } + ; Close connection to DB to unlock the file + this.__closeConnection() + } - /** - * Private Method - * Ensures the Table exists in the DB - * Throws a terminating Exception if it doesn't - * - * @param string moduleTable Name of the Table - */ - __validateTable(moduleTable) - { - this.__openConnection() + /** + * Private Method + * Delete row from Table + * Renamed, as __delete() is the destructor + * + * @param string moduleTable Name of the Table + * @param string key Value in column "key" + */ + __remove(moduleTable, key) + { + this.__openConnection() - sql := "SELECT COUNT(*) FROM '" moduleTable "'" - table := "" - if (!this.dbObject.getTable(sql, table)) - throw Error("[" this.dbObject.ErrorCode "] " this.dbObject.ErrorMsg, -1) + sql := "DELETE FROM '" moduleTable "' WHERE key = '" key "'" + if (!this.dbObject.Exec(sql)) + throw Error("[" this.dbObject.ErrorCode "] " this.dbObject.ErrorMsg, -1) - ; Close connection to DB to unlock the file - this.__closeConnection() - } + ; Close connection to DB to unlock the file + this.__closeConnection() + } - /** - * Private Method - * Handles the establishing of the connection to the DB - */ - __openConnection() - { - if (this.dbObject._Handle) ; connection is already open - Return + /** + * Private Method + * Generate the Table name based on the module + * that called the method + * + * @param string modulePack Name of the Module Pack that called the method + * @param string moduleName Name of the Module that called the method + * @return string + */ + __moduleTable(modulePack, moduleName) + { + return modulePack "|" moduleName + } - Loop(5) - { - if (this.dbObject.OpenDB(this.path)) - break - else - sleep 50 - } + __moduleTableFromFile(line_file) { + parts := StrSplit(line_file, "\") + num_parts := parts.Length() + if num_parts < 3 + throw Error('Unusable path input! Cannot find db entry from "' line_file '"!', -1) + return this.__moduleTable(parts[num_parts - 2], parts[num_parts - 1]) + } - if (!this.dbObject._Handle) - throw Error("[" this.dbObject.ErrorCode "] " this.dbObject.ErrorMsg, -1) - } + /** + * Private Method + * Ensures the Table exists in the DB + * Throws a terminating Exception if it doesn't + * + * @param string moduleTable Name of the Table + */ + __validateTable(moduleTable) + { + this.__openConnection() - /** - * Private Method - * Handles the terminate of the connection to the DB - */ - __closeConnection() - { - if (!this.dbObject.CloseDB()) - throw Error("[" this.dbObject.ErrorCode "] " this.dbObject.ErrorMsg, -1) - } + sql := "SELECT COUNT(*) FROM '" moduleTable "'" + table := "" + if (!this.dbObject.getTable(sql, table)) + throw Error("[" this.dbObject.ErrorCode "] " this.dbObject.ErrorMsg, -1) + ; Close connection to DB to unlock the file + this.__closeConnection() } - _check_sqlite() { - ; make sure the SQLlite-dll can be found - ini_path := path_join(this.paths.lib, "SQLiteDB.ini") - if (FileExist(ini_path)) + /** + * Private Method + * Handles the establishing of the connection to the DB + */ + __openConnection() + { + if (this.dbObject._Handle) ; connection is already open Return - sqldll := "SQLite3.dll" - dll_path := path_join(this.paths.ui, sqldll) - - if (!FileExist(dll_path)) { - msg := 'The "' sqldll '" must exist here:`n' dll_path '!`n`nWhere is it?' - msgbox_error(msg, sqldll ' missing?!') - Return + Loop(5) + { + if (this.dbObject.OpenDB(this.path)) + break + else + sleep 50 } - ini_code := "[Main]`nDllPath=" dll_path - FileAppend(ini_code, ini_path) + if (!this.dbObject._Handle) + throw Error("[" this.dbObject.ErrorCode "] " this.dbObject.ErrorMsg, -1) } -} + + /** + * Private Method + * Handles the terminate of the connection to the DB + */ + __closeConnection() + { + if (!this.dbObject.CloseDB()) + throw Error("[" this.dbObject.ErrorCode "] " this.dbObject.ErrorMsg, -1) + } + +} \ No newline at end of file diff --git a/lib/a2_user_data.ahk b/lib/a2_user_data.ahk index 3c25faa6..16e34a8e 100644 --- a/lib/a2_user_data.ahk +++ b/lib/a2_user_data.ahk @@ -26,9 +26,9 @@ a2_get_user_data_path(a2dir) { a2_get_user_config(a2data) { ; Parse the a2.cfg in the user data dir and equip global a2cfg with values - a2cfg := {} + a2cfg := Map() config_path := path_join(a2data, "a2.cfg") - Loop Read, %config_path% + Loop Read, config_path { parts := StrSplit(A_LoopReadLine, " ",,3) varname := Trim(parts[1])