1
1
Fork 0
mirror of https://github.com/FellippeHeitor/InForm.git synced 2024-07-21 11:15:13 +00:00

Cleanup INI library a bit

This commit is contained in:
Samuel Gomes 2024-01-11 19:01:18 +05:30
parent 022fd0a97f
commit 33f896aaaa
3 changed files with 32 additions and 30 deletions

View file

@ -10,8 +10,8 @@ $IF INI_BAS = UNDEFINED THEN
'$INCLUDE:'Ini.bi'
SUB IniSortSection (file$, __section$)
SHARED IniCODE, IniLastKey$, IniWholeFile$
SHARED IniDisableAutoCommit
SHARED IniCODE AS LONG, IniLastKey$, IniWholeFile$
SHARED IniDisableAutoCommit AS _BYTE
REDIM Keys(1 TO 100) AS STRING
DIM TotalKeys, tempValue$, i AS LONG, Backup$, CommitBackup
@ -63,7 +63,7 @@ $IF INI_BAS = UNDEFINED THEN
END SUB
SUB IniDeleteSection (file$, __section$)
SHARED IniNewFile$, IniCODE, currentIniFileName$
SHARED IniNewFile$, IniCODE AS LONG, currentIniFileName$
SHARED IniLF$, IniWholeFile$, currentIniFileLOF AS _UNSIGNED LONG
IniLoad file$
@ -82,7 +82,7 @@ $IF INI_BAS = UNDEFINED THEN
END SUB
SUB IniDeleteKey (file$, __section$, __key$)
SHARED IniPosition AS _UNSIGNED LONG, IniCODE
SHARED IniPosition AS _UNSIGNED LONG, IniCODE AS LONG
SHARED IniLF$, IniWholeFile$, IniSectionData$
SHARED IniLastSection$, IniLastKey$, IniNewFile$
@ -119,7 +119,7 @@ $IF INI_BAS = UNDEFINED THEN
SUB IniMoveKey (file$, __section$, __key$, __newsection$)
'A move operation is a copy operation + a delete operation
SHARED IniCODE
SHARED IniCODE AS LONG
DIM tempValue$
@ -135,7 +135,7 @@ $IF INI_BAS = UNDEFINED THEN
SUB IniCommit
SHARED currentIniFileName$, IniWholeFile$, currentIniFileLOF AS _UNSIGNED LONG
SHARED IniNewFile$, IniDisableAutoCommit, IniCODE
SHARED IniNewFile$, IniDisableAutoCommit AS _BYTE, IniCODE AS LONG
SHARED LoadedFiles$
IF currentIniFileName$ = "" THEN IniCODE = 18: EXIT SUB
@ -171,7 +171,7 @@ $IF INI_BAS = UNDEFINED THEN
END SUB
FUNCTION IniGetSection$ (__section$)
SHARED IniPosition AS _UNSIGNED LONG, IniCODE, currentIniFileName$
SHARED IniPosition AS _UNSIGNED LONG, IniCODE AS LONG, currentIniFileName$
SHARED IniLF$, IniWholeFile$, currentIniFileLOF AS _UNSIGNED LONG
IF currentIniFileName$ = "" THEN IniCODE = 18: EXIT FUNCTION
@ -244,7 +244,7 @@ $IF INI_BAS = UNDEFINED THEN
END FUNCTION
FUNCTION IniFormatSection$ (__section$)
SHARED IniCODE
SHARED IniCODE AS LONG
DIM section$
@ -265,7 +265,7 @@ $IF INI_BAS = UNDEFINED THEN
FUNCTION ReadSetting$ (file$, __section$, __key$)
SHARED IniLastSection$, IniLastKey$, IniWholeFile$, IniLF$
SHARED IniPosition AS _UNSIGNED LONG, IniSectionData$
SHARED IniCODE, IniAllowBasicComments
SHARED IniCODE AS LONG, IniAllowBasicComments AS _BYTE
SHARED currentIniFileLOF AS _UNSIGNED LONG
IniLoad file$
@ -405,7 +405,7 @@ $IF INI_BAS = UNDEFINED THEN
END FUNCTION
SUB WriteSetting (file$, __section$, __key$, __value$)
SHARED IniPosition AS _UNSIGNED LONG, IniCODE, currentIniFileName$
SHARED IniPosition AS _UNSIGNED LONG, IniCODE AS LONG, currentIniFileName$
SHARED IniLF$, IniWholeFile$, IniSectionData$
SHARED IniLastSection$, IniLastKey$, IniNewFile$
@ -563,7 +563,7 @@ $IF INI_BAS = UNDEFINED THEN
END SUB
SUB IniSetForceReload (state AS _BYTE)
SHARED IniForceReload
SHARED IniForceReload AS _BYTE
IF state THEN
IniForceReload = -1
ELSE
@ -572,7 +572,7 @@ $IF INI_BAS = UNDEFINED THEN
END SUB
SUB IniClose
SHARED IniDisableAutoCommit, currentIniFileName$
SHARED IniDisableAutoCommit AS _BYTE, currentIniFileName$
SHARED LoadedFiles$
DIM findFile AS INTEGER, fileNum AS INTEGER
@ -595,9 +595,9 @@ $IF INI_BAS = UNDEFINED THEN
END SUB
SUB IniLoad (file$)
SHARED IniCODE, currentIniFileName$, IniLF$, IniWholeFile$
SHARED IniCODE AS LONG, currentIniFileName$, IniLF$, IniWholeFile$
SHARED currentIniFileLOF AS _UNSIGNED LONG
SHARED IniForceReload
SHARED IniForceReload AS _BYTE
SHARED LoadedFiles$
DIM fileNum AS INTEGER, findFile AS INTEGER
@ -655,7 +655,7 @@ $IF INI_BAS = UNDEFINED THEN
END SUB
FUNCTION IniNextKey$
SHARED IniCODE, IniLF$, currentIniFileName$, IniSectionData$
SHARED IniCODE AS LONG, IniLF$, currentIniFileName$, IniSectionData$
SHARED IniPosition AS _UNSIGNED LONG
STATIC lastDataBlock$, position AS _UNSIGNED LONG, tempLF$
@ -698,7 +698,7 @@ $IF INI_BAS = UNDEFINED THEN
END FUNCTION
FUNCTION IniNextSection$ (file$)
SHARED IniCODE, IniLF$, IniWholeFile$
SHARED IniCODE AS LONG, IniLF$, IniWholeFile$
STATIC sectionStart AS _UNSIGNED LONG
@ -746,7 +746,7 @@ $IF INI_BAS = UNDEFINED THEN
END FUNCTION
FUNCTION IniINFO$
SHARED IniCODE
SHARED IniCODE AS LONG
SELECT CASE IniCODE
CASE 0: IniINFO$ = "Operation successful"
CASE 1: IniINFO$ = "ERROR: File not found"

View file

@ -9,21 +9,23 @@ $IF INI_BI = UNDEFINED THEN
' TODO:
' We should put all of this stuff into a single state type and then have just a single global to avoid possible name collisions.
' INI routines without namespace like prefix should also be prefixed with the "Ini_" prefix
' That should also let us make the library load multiple INI files at the same time like the GIFPlayer library.
' INI routines without namespace like prefix should also be prefixed with the "Ini_" prefix.
'Global variables declaration
DIM currentIniFileName$, LoadedFiles$
DIM currentIniFileName AS STRING
DIM LoadedFiles AS STRING
DIM currentIniFileLOF AS _UNSIGNED LONG
DIM IniWholeFile$
DIM IniSectionData$
DIM IniWholeFile AS STRING
DIM IniSectionData AS STRING
DIM IniPosition AS _UNSIGNED LONG
DIM IniNewFile$
DIM IniLastSection$
DIM IniLastKey$
DIM IniLF$
DIM IniDisableAutoCommit ' _BYTE?
DIM IniCODE ' _BYTE?
DIM IniAllowBasicComments ' _BYTE?
DIM IniForceReload ' _BYTE?
DIM IniNewFile AS STRING
DIM IniLastSection AS STRING
DIM IniLastKey AS STRING
DIM IniLF AS STRING
DIM IniDisableAutoCommit AS _BYTE
DIM IniCODE AS LONG
DIM IniAllowBasicComments AS _BYTE
DIM IniForceReload AS _BYTE
$END IF

View file

@ -6,7 +6,7 @@ $(error "OS must be set to 'lnx', 'win', or 'osx'")
endif
ifndef QB64PE_PATH
$(error "QB64PE_PATH must be path where QB64PE is installed")
$(error "QB64PE_PATH must be path where QB64-PE is installed")
endif
ifeq ($(OS),lnx)