Attribute VB_Name = "Data" ''+-------------------------------------------+ ''| ICI style I/O database file access module | ''+-------------------------------------------+ ''| Made by Jure Sah of MesonAI | ''+-------------------------------------------+ '' ''DO NOT MODIFY WITHOUT MY PREMITION!!! '' ''Mailto:jure.sah@guest.arnes.si '' ''Feel free to use this module in your ''programs and share it with your friends. '' '' ''You will probably need it if you are ''building apps for the ICI Console. '' ''There is a external public string that ''can be defined: ''It can be used to simplify calling routines Sub xCreate(xName As String) xFile$ = "" If DataFilesPath <> "" Then xFile$ = DataFilesPath + "\" xFile$ = xFile$ + xName ''Does it already exist? If Dir(xFile$) = "" Then ''Place emptyness in new file Open xFile$ For Output As #1 Print #1, "INTERNAL FLAG = EXISTS!" Close #1 End If End Sub Sub xRemove(xName As String) xFile$ = "" If DataFilesPath <> "" Then xFile$ = DataFilesPath + "\" xFile$ = xFile$ + xName ''Does it already exist? If Dir(xFile$) <> "" Then Kill xFile$ End If End Sub Sub xSet(xName As String, xProperty As String, xValue As String) ''Set filenames xFile$ = "" If DataFilesPath <> "" Then xFile$ = DataFilesPath + "\" xFile$ = xFile$ + xName SwapFile$ = xTemporaryPath + "\ICIC.SWP" If Dir(xFile$) <> "" Then ''Find Property in file and save the remaining data in the swap file Open SwapFile$ For Output As #2 Open xFile$ For Input As #1 Found = False Do: Line Input #1, a$ ''If the thing behind the "=" is our property... If UCase$(Trim$(Mid$(a$, 1, InStr(a$, "=") - 1))) = UCase$(Trim$(xProperty)) Then Found = True Else ''Otherwise copy to the swapfile Print #2, a$ End If Loop Until EOF(1) Close #1, #2 Else Found = False End If If Not Found Then ''If property not already inside, append it Open xFile$ For Append As #2 Print #2, xProperty; "="; xValue Close #2 Else ''If property inside, put it in the swap file and switch them Open SwapFile$ For Append As #2 Print #2, xProperty; "="; xValue Close #2 Kill xFile$ Name SwapFile$ As xFile$ End If Kill xTemporaryPath + "\ICIC.SWP" End Sub Function xQuery(xName As String, xProperty As String) As String xFile$ = "" If DataFilesPath <> "" Then xFile$ = DataFilesPath + "\" xFile$ = xFile$ + xName ''Find the right Property and then extract the Value If Dir(xFile$) <> "" Then Open xFile$ For Input As #1 Found = False Do: Line Input #1, a$ 'Debug.Print "("; UCase$(Trim$(Mid$(a$, 1, InStr(a$, "=") - 1))); ")" If UCase$(Trim$(Mid$(a$, 1, InStr(a$, "=") - 1))) = UCase$(Trim$(xProperty)) Then xQuery = Trim$(Mid$(a$, InStr(a$, "=") + 1)) Exit Do End If Loop Until EOF(1) Close #1 End If End Function