Introduction


Welcome to DDB, the ultimate array and dictionary function for AutoHotkey.

DDB is based on COM dictionary object and it is very easy to use.
DDB can be used in three ways.

- Directly using DDB function
- Trough ArrayFunctions
- Trough DictionaryFunctions

To use Array- and DictionaryFunctions functions you will need to define an empty function with predefined parameters.

After DDB() has been called, those empty functions will become functional arrays and dictionaries.

Parameters

Function

Usage

DDB

You can call DDB(dictionary,action,key,item) function directly to save, get, find, delete... values, see DDB for more information.

ArrayFunctions

This is a special feature of DDB, it provides very short and simple syntax.
To use that feature, you will need to include an empty function in your script having 1 parameter where you can set delimiter character. For example:
a(p=","){
}
DDB will breathe life into this function by assigning dynamically created dictionary and the code to it.

DictionaryFunctions

This is another special feature of DDB, it also provides similar short and simple syntax.
Different to ArrayFunctions, you will need to have 3 parameters in your function. For example:
d(key="",item="1",cmode="1"){
}

Multithreading

DDB also supports multithreading
To use that feature you will need do get AutoHotkey.dll (1.0.48.03).
You can use Thread() function to start new threads.
In your new thread you will need to include same empty functions.
DDB will recognize it, check if a dictionary already exists for it and create required code as well as connect the function to the dictionary.
Of course you can exclude some of the functions and create new once in your new thread.

Return Value

Dynamic

Remarks

Only AutoHotkey 1.0.48.3 is supported at the moment.

To use ArrayFunctions and DictionaryFunctions you need to call DDB() once to initialize and once before exiting the process to terminate.

When using DDB in multithread environment, new functions need to have a different name than the ones in main process and other threads!
Note, when you terminate DDB in your thread, it will be terminated for the whole process!

You can access Array and Dictionary functions using DDB as well, therefor dic parameter must be the name of your function.

Related

DDB, ArrayFunctions, DictionaryFunctions, Thread, Credits

Example

#NoEnv
SetBatchLines,-1

a(var=","){ ;declare array
}

b(var="",value="",cmode="1"){ ;declare dictionary
}

DDB() ;Initialize COM and DDB

Loop 10
a("+" A_Index) ;add values to the end of array

Loop 10
b(A_Index-1,A_Index) ;add some new keys

;Retrieve all items / values separated by . and count keys/items.
MsgBox % a("$`n") "." a("?") "`n`n" b("",5,"`n") "." b("","?")

DDB() ;terminate usage of DDB and COM
ExitApp
#include %A_ScriptDir%\DDB.ahk