I am learning to write AHK scripts; I have to say, it is an awesome language!
My challenge is: a "database" program: creating, deleting, displaying (in a GUI / grid / Listview), editing, reading, writing, all of it.
I found some examples, in the docs, forums, how to read a csv / text file. (see code below)
Now for the rest of it - how to get the contents in an internal Array / Object / Structure? How to display in a 2-dimensional grid, what to do to add / delete / edit records, fields?
How to write the content back to disk, to retrieve?
What is the best / easiest method? In csv / text format, or binary file, or use SQL database-like methods?
Any tip is welcome!
Thank you,
Ad
Code: Select all
; Parse a comma separated (CSV) file: (nested Loops)
Loop, Read, email.csv ; InputFile should not be in quotes
{
LineNumber = %A_Index%
Loop, Parse, A_LoopReadLine, CSV, %A_Space%
{
MsgBox, 4,, Field %LineNumber%-%A_Index% is:`n%A_LoopField%`n`nContinue?
IfMsgBox, No
Break
}
}
; Create an array, initially empty:
Array := Object()
; Write to the array:
Loop, Read, email.csv ; This loop retrieves each line from the file, one at a time.
{
Array.Insert(A_LoopReadLine) ; Append this line to the array.
}
; Read from the array:
for index, element in Array ; Recommended approach in most cases.
{
MsgBox % "Element number " index " is " element
}