Sign in to follow this  
Followers 0
james3mg

database replacement for INI functions

20 posts in this topic

#1 ·  Posted (edited)

This script is designed to be #included in the top of a script, then you can replace ALL of your calls to the built-in INI*() functions with _DBIni*() (that is, INIWrite() becomes _DBIniWrite(), etc)

All the arguments, features and returns are the same as the ini functions, but instead of storing the data in an ini file, it stores it in a database file (which can have any extension, even .ini...but it won't be notepad-readable). The benefit is that the database engine doesn't have the same limitations as Windows' handling of .ini files (32 kb limit, etc). So just by including this script and using SCIte's "Find and Replace" (Ctrl+H) function, you can rest assured that your scripts relying on reading/writing ini files won't break when the files get too big...and you never have to see the messy SQL calls!

Hope you enjoy :P Let me know if it's useful.

DBIni.au3:

#include-once
#include <SQLite.dll.au3>
#include <SQLite.au3>
_SQLite_Startup()

Func _DBIniDelete($_DBIniFilename,$_DBIniSection,$_DBIniKey="00-0000--;-0");it's unlikely that anyone will ever happen to have a key named 00-0000--;-0
    If _SQLite_Open($_DBIniFilename)=0 Then Return 0
    If $_DBIniKey=="00-0000--;-0" Then
        If _SQLite_Exec(-1,"DROP TABLE "&_SQLite_Escape($_DBIniSection)) <> $SQLite_OK Then
            _SQLite_Close()
            Return 0
        Else
            _SQLite_Close()
            Return 1
        EndIf
    Else
        If _SQLite_Exec(-1,"DELETE FROM "&_SQLite_Escape($_DBIniSection)&" WHERE `key` = "&_SQLite_Escape($_DBIniKey)) <> $SQLite_OK Then
            _SQLite_Close()
            Return 0
        Else
            _SQLite_Close()
            Return 1
        EndIf
    EndIf
EndFunc

Func _DBIniRead($_DBIniFilename,$_DBIniSection,$_DBIniKey,$_DBIniDefault)
    Local $aResult,$iRows,$iCols
    If _SQLite_Open($_DBIniFilename)=0 Then Return $_DBIniDefault
    If _SQLite_GetTable2d(-1,"SELECT `value` FROM "&_SQLite_Escape($_DBIniSection)&" WHERE `key` = "&_SQLite_Escape($_DBIniKey),$aResult,$iRows,$iCols) <> $SQLite_OK  OR $iRows <> 1 Then
        _SQLite_Close()
        Return $_DBIniDefault
    Else
        _SQLite_Close()
        Return $aResult[1][0]
    EndIf
EndFunc

Func _DBIniReadSection($_DBIniFilename,$_DBIniSection)
    Local $aResult,$iRows,$iCols
    If _SQLite_Open($_DBIniFilename)=0 Then Return SetError(1)
    If _SQLite_GetTable2d(-1,"SELECT `key`,`value` FROM "&_SQLite_Escape($_DBIniSection),$aResult,$iRows,$iCols) <> $SQLite_OK OR NOT $iRows>0 Then
        _SQLite_Close()
        Return SetError(1)
    Else
        _SQLite_Close()
        $aResult[0][0]=$iRows
        $aResult[0][1]=""
        Return $aResult
    EndIf
EndFunc

Func _DBIniReadSectionNames($_DBIniFilename)
    Local $aResult,$iRows,$iCols,$i
    If _SQLite_Open($_DBIniFilename)=0 Then Return SetError(1)
    If _SQLite_GetTable2d(-1,"Select * From SQLITE_MASTER",$aResult,$iRows,$iCols) <> $SQLite_OK OR NOT $iRows>0 Then Return SetError(1)
    _SQLite_Close()
    Local $ReturnVal[1]=["0"]
    For $i=1 To $iRows
        If $aResult[$i][0] = "Table" Then
            $returnVal[0]+=1
            ReDim $returnVal[$returnVal[0]+1]
            $returnVal[$returnVal[0]]=$aResult[$i][1]
        EndIf
    Next
    Return $returnVal
EndFunc

Func _DBIniRenameSection($_DBIniFilename,$_DBIniSection,$_DBIniNewSection,$_DBIniFlag=0)
    Local $aResult,$iRows,$iCols
    If _SQLite_Open($_DBIniFilename)=0 Then Return 0
    If _SQLite_GetTable2d(-1,"SELECT * FROM "&_SQLite_Escape($_DBIniSection),$aResult,$iRows,$iCols) <> $SQLite_OK OR NOT $iRows>0 Then
        _SQLite_Close()
        Return 0
    EndIf
    If $_DBIniFlag Then
        If _SQLite_GetTable2d(-1,"SELECT * FROM "&_SQLite_Escape($_DBIniNewSection),$aResult,$iRows,$iCols) = $SQLite_OK OR NOT $iRows>0 Then
            _SQLite_Close()
            Return SetError(1,"",0)
        EndIf
    EndIf
    _SQLite_Exec(-1,"DROP TABLE IF EXISTS "&_SQLite_Escape($_DBIniNewSection))
    If _SQLite_Exec(-1,"ALTER TABLE "&_SQLite_Escape($_DBIniSection)&" RENAME TO "&_SQLite_Escape($_DBIniNewSection)) <> $SQLite_OK Then
        _SQLite_Close()
        Return 0
    Else
        _SQLite_Close()
        Return 1
    EndIf
EndFunc

Func _DBIniWrite($_DBIniFilename,$_DBIniSection,$_DBIniKey,$_DBIniValue)
    If _SQLite_Open($_DBIniFilename)=0 Then Return 0
    If _SQLite_Exec(-1,"CREATE TABLE IF NOT EXISTS "&_SQLite_Escape($_DBIniSection)&" (`key` UNIQUE ON CONFLICT REPLACE NOT NULL,`value`)") <> $SQLite_OK Then
        _SQLite_Close()
        Return 0
    EndIf
    If _SQLite_Exec(-1,"INSERT OR REPLACE INTO "&_SQLite_Escape($_DBIniSection)&" (`key`,`value`) VALUES ("&_SQLite_Escape($_DBIniKey)&","&_SQLite_Escape($_DBIniValue)&")") <> $SQLite_OK Then
        _SQLite_Close()
        Return 0
    Else
        _SQLite_Close()
        Return 1
    EndIf
EndFunc

Func _DBIniWriteSection($_DBIniFilename,$_DBIniSection,$_DBIniData,$_DBIniIndex=1)
    Local $SplitVals, $SplitStr, $i
    If NOT IsInt($_DBIniIndex) Then Return 0
    If _SQLite_Open($_DBIniFilename)=0 Then Return 0
    If _SQLite_Exec(-1,"CREATE TABLE IF NOT EXISTS "&_SQLite_Escape($_DBIniSection)&" (`key` UNIQUE ON CONFLICT REPLACE NOT NULL,`value`)") <> $SQLite_OK Then
        _SQLite_Close()
        Return 0
    EndIf
    If IsArray($_DBIniData) Then
        If UBound($_DBIniData,0) <> 2 OR UBound($_DBIniData,2) <> 2 Then
            _SQLite_Close()
            Return SetError(0,"",1)
        EndIf
        _SQLite_Exec(-1,"BEGIN TRANSACTION")
        For $i=$_DBIniIndex To UBound($_DBIniSection)
            If _SQLite_Exec(-1,"INSERT OR REPLACE INTO "&_SQLite_Escape($_DBIniSection)&" (`key`,`value`) VALUES ("&_SQLite_Escape($_DBIniData[$i][0])&","&_SQLite_Escape($_DBIniData[$i][1])&")") <> $SQLite_OK Then
                _SQLite_Close()
                Return 0
            EndIf
        Next
        _SQLite_Close()
        Return 1
    Else
        $SplitVals=StringSplit($_DBIniData,@LF)
        For $i=1 To $SplitVals[0]
            $SplitStr=StringSplit($_DBIniData,"=")
            If UBound($SplitStr) <> 2 Then
                _SQLite_Close()
                Return SetError(1,"",0)
            EndIf
            If _SQLite_Exec(-1,"INSERT OR REPLACE INTO "&_SQLite_Escape($_DBIniSection)&" (`key`,`value`) VALUES ("&_SQLite_Escape($SplitStr[0])&","&_SQLite_Escape($SplitStr[1])&")") <> $SQLite_OK Then
                _SQLite_Close()
                Return 0
            EndIf
        Next
        _SQLite_Close()
        Return 1
    EndIf
EndFunc
Edited by james3mg

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Cool functions, nice UDF, but my _Db_* are faster, they don't use SQLite, so if you wanted to like write, 30 times, it would take a bit. Anyway, good UDF, if you wanted to check mine out, if you havn't already, the link is in my sig. Project Database v4.

EDIT: It is useful though :P

Edited by SwiftBurns

Share this post


Link to post
Share on other sites

Very nice :P

Having all info stored in a database is a good idea.

I'm sure it will come in handy sometime. Thank you.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Very nice :P

Having all info stored in a database is a good idea.

I'm sure it will come in handy sometime. Thank you.

Glad you like :(

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

Good work!

P.S. I often see mention of the 32kb limit, which amazes me, as I've always known it and experienced it as a 64kb limit. Windows XP does not have that limit ... I have ini files over 100kb and they work fine (i.e. Cdplayer.ini). I think 32kb might have been back in Win95 (or more like 3.1) days, but Win98 was definitely 64kb.

To get around that old limit, I just made an Index.ini file (or files), that referenced as many other ini files as I liked (aka a database). With the Cdplayer.ini file, when you popped a CD in the drive, my program just auto swapped that entry in for other programs to read.

I kinda like to be able to edit my database files, so not sure I like your unreadable by Notepad feature.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

I couldn't get this to work..

FileChangeDir(@ScriptDir)
FileWrite("sqlini.db", "")
_DBIniWrite("sqlini.db", "example", "iam",  "a pizza")
_DBIniWrite("sqlini.db", "example", "uare", "a taco")

MsgBox(0, '', _DBIniRead("sqlini.db", "example", "iam", "a kangaroo???"))

DBIniWrite.au3 (35) : ==> Subscript used with non-Array variable.:
Return $aResult[1][0]
Return $aResult^ ERROR

The arrays should be declared explicitly

Local $aResult[2][2],$iRows,$iCols

because on failure it will attempt to return a non existing array

Return $aResult[1][0]

After adjusting the code, it returns nothing. :P


Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Good work!

P.S. I often see mention of the 32kb limit, which amazes me, as I've always known it and experienced it as a 64kb limit. Windows XP does not have that limit ... I have ini files over 100kb and they work fine (i.e. Cdplayer.ini). I think 32kb might have been back in Win95 (or more like 3.1) days, but Win98 was definitely 64kb.

To get around that old limit, I just made an Index.ini file (or files), that referenced as many other ini files as I liked (aka a database). With the Cdplayer.ini file, when you popped a CD in the drive, my program just auto swapped that entry in for other programs to read.

I kinda like to be able to edit my database files, so not sure I like your unreadable by Notepad feature.

XP DOES have that limit, though it's not in the basic read and write functions...I believe I was told that 32kb was a hard limit in functions such as IniReadSectionNames, for instance. I have hit (in XP) various 32kb limits before, so I know it's still there.

I'm glad you have found ways around the limits, and you're welcome to not use these functions- these are for people who want basic ini capabilities in very large files without having to build the database infrastructure as you have :P And the 'unreadable by notepad' 'feature' is actually not something I have a choice in- you can't read db files as plain text. The plus side is that the files written by these SQLite functions end up smaller than a single or series of .ini files holding the exact same data (by at least half, in my experience). You can easily get in and edit the .db file by throwing together a script of your own similar to the dbviewer.au3 script I posted last year and adding some basic editing functionality...if you really want manual control over your data.

Edited by james3mg

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I couldn't get this to work..

FileChangeDir(@ScriptDir)
FileWrite("sqlini.db", "")
_DBIniWrite("sqlini.db", "example", "iam",  "a pizza")
_DBIniWrite("sqlini.db", "example", "uare", "a taco")

MsgBox(0, '', _DBIniRead("sqlini.db", "example", "iam", "a kangaroo???"))

DBIniWrite.au3 (35) : ==> Subscript used with non-Array variable.:
Return $aResult[1][0]
Return $aResult^ ERROR

The arrays should be declared explicitly

Local $aResult[2][2],$iRows,$iCols

because on failure it will attempt to return a non existing array

Return $aResult[1][0]

After adjusting the code, it returns nothing. :P

I'll look into it today...I don't think that declaring the array explicitly will make a difference, because the _SQL* functions will completely redeclare it anyway, but apparently I need more error checking.

Thanks- I'll let you know what I come up with :(...you should have an answer here within a few hours.

Edit: I think I figured out your particular problem, though I'll still look into if more error checking is needed...you're manually creating the file, and you shouldn't do that. If you try to _DBIniWrite() to a file that doesn't exist, it will be created for you AS A DATABASE FILE. Otherwise, if the file already exists, the function will try to use it as-is and it doesn't have the appropriate infrastructure to be readable by SQLite (being a blank file). I think if you check the return from your DBIniWrite() function, you'll see it returned 0, which indicates an error in both IniWrite() and _DBIniWrite(), and should be checked in your code.

Edited by james3mg

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

XP DOES have that limit, though it's not in the basic read and write functions...I believe I was told that 32kb was a hard limit in functions such as IniReadSectionNames, for instance. I have hit (in XP) various 32kb limits before, so I know it's still there.

I'm glad you have found ways around the limits, and you're welcome to not use these functions- these are for people who want basic ini capabilities in very large files without having to build the database infrastructure as you have :P And the 'unreadable by notepad' 'feature' is actually not something I have a choice in- you can't read db files as plain text. The plus side is that the files written by these SQLite functions end up smaller than a single or series of .ini files holding the exact same data (by at least half, in my experience). You can easily get in and edit the .db file by throwing together a script of your own similar to the dbviewer.au3 script I posted last year and adding some basic editing functionality...if you really want manual control over your data.

Thanks for the heads up, but I'm not sure I agree with some though ... I guess I may eventually find out? :P

Please don't get me wrong, I'm not criticising your work. :(

I also seem to have misunderstood your level of control over the unreadable feature ... my apologies!

All that said, I will check out you program properly when I get the chance ... who knows, I may even adapt the ideas for a future update of my database. I'd like to check out your dbviewer.au3 script. Does it read the Windows CD database?

I've more recently created a CDIni Database which uses my methods, and I've not experienced any issues yet ... which is not to say you are wrong, but I use every ini function in that database, and deal with the 100kb + Cdplayer.ini file, both as a checker and updater. Every artist has their own ini file at this point - some are quite big.

I seem to recall reading somewhere that the 'IniReadSectionNames' limit pertained to the function not the ini limits of XP. I also seem to recall, that the function was eventually updated? :idea:

On researching your topic posts looking for that .au3, I came across this - where you discussed the ini limits before ... Valik said they were deliberate ... thus they may be different now (as I stated in paragraph above)? Either way, it is was a 32kb buffer limit for section names, not 32kb file size limit!

Thanks for responding and sharing! :P

:)

Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

Thanks for the heads up, but I'm not sure I agree with some though ... I guess I may eventually find out? :P

Please don't get me wrong, I'm not criticising your work. :(

I also seem to have misunderstood your level of control over the unreadable feature ... my apologies!

I've more recently created a CDIni Database which uses my methods, and I've not experienced any issues yet ... which is not to say you are wrong, but I use every ini function in that database, and deal with the 100kb + Cdplayer.ini file, both as a checker and updater. Every artist has their own ini file at this point - some are quite big.

I seem to recall reading somewhere that the 'IniReadSectionNames' limit pertained to the function not the ini limits of XP. I also seem to recall, that the function was eventually updated? :idea:

All that said, I will check out you program properly when I get the chance ... who knows, I may even adapt the ideas for a future update of my database. I'd like to check out your dbviewer.au3 script. Does it read the Windows CD database?

Thanks for responding and sharing! :P

:)

It would only read the Windows CD database if it were a sqlite database...which is unlikely :P MS tends to use their own engine...understandably.

link

(note that this will probably need updating for AutoIt 3.2.10+ syntax).


"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

It would only read the Windows CD database if it were a sqlite database...which is unlikely :idea: MS tends to use their own engine...understandably.

link

(note that this will probably need updating for AutoIt 3.2.10+ syntax).

Thanks! :P

You are undoubtably right about MS, and I didn't find your file because it was code on a page and not named as an .au3. I also hadn't twigged that it was SQLite database reader, though I was beginning to draw that conclusion.

You may not have noticed, but I had just edited my previous post! :(


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

James3mg,

Running Au3 version 3.2.12.1 on Vista. Here are a couple of samples I've tried:

CODE
#include <DB_Ini.au3>

$File = (@ScriptDir & "\Users.ini")

$Write = _DBIniWrite($File, "tfl0001", "FullName", "Trident Foods Store # 1")

msgbox(0,"", $Write)

$Read = _DBIniRead($File, "tfl0001", "FullName", "None")

msgbox(0,"", $Read)

CODE
$File = (@ScriptDir & "\Users.ini")

$Write = IniWrite($File, "tfl0001", "FullName", "Trident Foods Store # 1")

msgbox(0,"", $Write)

$Read = IniRead($File, "tfl0001", "FullName", "None")

msgbox(0,"", $Read)

I copied your code from the forum page, called it "DB_Ini.au3" and placed that in my includes folder. I know my samples are pretty elementary so please forgive me.

When I run the first piece of code the first msgbox returns "0" and the second msgbox returns "None". This is the debug that Scite outputs when I run it from there:

CODE
! SQLite.au3 Error

--> Function: _SQLite_Exec

--> Query: CREATE TABLE IF NOT EXISTS ''tfl0001'' ('key' UNIQUE ON CONFLICT REPLACE NOT NULL,'value')

--> Error: near "tfl0001": syntax error

! SQLite.au3 Error

--> Function: _SQLite_GetTable2d or _SQLite_QuerySingleRow or _SQLite_Exec

--> Query: SELECT 'value' FROM ''tfl0001'' WHERE 'key' = ''FullName''

--> Error: near "''": syntax error

The second piece of code is strict Au3 and returns "1" and "Trident Foods Store # 1" as I would expect.

I made sure that "SQLLite3.dll" is created in my System folder. I'm not up to snuff on databases so could you please tell me if I am doing something incorrectly? I would greatly appreciate it. I think this function is a wonderful idea and would help out a lot of fledgling DB users like myself. Thanks.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

James3mg,

Running Au3 version 3.2.12.1 on Vista. Here are a couple of samples I've tried:

...

The second piece of code is strict Au3 and returns "1" and "Trident Foods Store # 1" as I would expect.

I made sure that "SQLLite3.dll" is created in my System folder. I'm not up to snuff on databases so could you please tell me if I am doing something incorrectly? I would greatly appreciate it. I think this function is a wonderful idea and would help out a lot of fledgling DB users like myself. Thanks.

If you copied the code when I first posted it, re-copy it now...I'd used the _SQLite_Escape() incorrectly at first and was getting errors like the ones you posted from SciTE. In the meantime, I'll try what you posted right now.

Thanks

Edit 1: I am seeing that the first piece of code's first message box returns 1 when using the latest version (posted in the OP). So that's part of your problem. However, I also see that reading it doesn't seem to work. I'll keep looking to figure out why and let you know when I've fixed it.

Edit 2: I've found the issues, and I'm trying to run some tests that I'm afraid might break with my mods...if it works then I'll update the OP.

Edit 3: Everything seemed to work great. OP has been updated with a version I believe to be bug-free. Please try it out and let me know if you find any issues :P

Edited by james3mg

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

If you copied the code when I first posted it, re-copy it now...I'd used the _SQLite_Escape() incorrectly at first and was getting errors like the ones you posted from SciTE. In the meantime, I'll try what you posted right now.

Thanks

Edit 1: I am seeing that the first piece of code's first message box returns 1 when using the latest version (posted in the OP). So that's part of your problem. However, I also see that reading it doesn't seem to work. I'll keep looking to figure out why and let you know when I've fixed it.

Edit 2: I've found the issues, and I'm trying to run some tests that I'm afraid might break with my mods...if it works then I'll update the OP.

Edit 3: Everything seemed to work great. OP has been updated with a version I believe to be bug-free. Please try it out and let me know if you find any issues :P

Appreciate that. It working for me now.

#include "DBIniWrite.au3"

$sReturn =_DBIniWrite(@ScriptDir & "\sqlini.db", "example", "i am",  "a pizza")
MsgBox(0, '', "Error: " & @error &@CRLF& "Return: " & $sReturn)

$sReturn = _DBIniRead(@ScriptDir & "\sqlini.db", "example", "i am", "a kangaroo???")
MsgBox(0, '', "Error: " & @error &@CRLF& "Return: " & $sReturn)

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()

Share this post


Link to post
Share on other sites

Thanks 4 sharing...before this, I always encrypt my .ini files to make it unreadable in notepad.

Now, I'll try yours...thanks again! :P


AUTOIT[sup] I'm lovin' it![/sup]

Share this post


Link to post
Share on other sites

Well, I played around with this last night and it seems to be working great. ReadSection and ReadSectionNames returns arrays perfectly. I was able to hand off an array to WriteSection. All other Read and Write functions act normally. All in all, this UDF performs identically to the internal Au3 INI functions with the exception of utilizing a database instead of a plain text file. James3mg, my hat's off to you.

Share this post


Link to post
Share on other sites

Well, I played around with this last night and it seems to be working great. ReadSection and ReadSectionNames returns arrays perfectly. I was able to hand off an array to WriteSection. All other Read and Write functions act normally. All in all, this UDF performs identically to the internal Au3 INI functions with the exception of utilizing a database instead of a plain text file. James3mg, my hat's off to you.

Do I have to install something to use an SQL (or SQLite ?) database?

Or are these functions all working without the need of additional software?

I've seen plenty of scripts here that are using SQLite, but never used or tested them, since I thought I'd have to install something to make them work.


You can fool some of the people all of the time, and all of the people some of the time, but you can not fool all of the people all of the time. Abraham Lincoln - http://www.ae911truth.org/ - http://www.freedocumentaries.org/

Share this post


Link to post
Share on other sites

Do I have to install something to use an SQL (or SQLite ?) database?

Or are these functions all working without the need of additional software?

I've seen plenty of scripts here that are using SQLite, but never used or tested them, since I thought I'd have to install something to make them work.

I am using AutoIt 3.2.12.1. It comes with a huge library of UDF's. One of the functions called in this script is named SQLite.dll.au3. This creates the file SQLite3.dll in your Windows system directory if it is not already there. This library is what handles all of the SQL calls in this script. This should be all you need. (Except of course, James3mg's script from the first page of this message as well).

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

I am using AutoIt 3.2.12.1. It comes with a huge library of UDF's. One of the functions called in this script is named SQLite.dll.au3. This creates the file SQLite3.dll in your Windows system directory if it is not already there. This library is what handles all of the SQL calls in this script. This should be all you need. (Except of course, James3mg's script from the first page of this message as well).

Right...as long as you've got AutoIt 3.2.10 or greater installed, you don't need anything else installed for using these functions in your script and running it either as a script or as a compiled .exe file. If you compile your script on the computer where you've got AutoIt installed, you can then run your script with these sql functions on any other XP or greater Windows computer without having AutoIt or its libraries installed at all. :(

@catdaddy- glad it worked...thanks for your bug-finding help. :P

Edited by james3mg

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0