mirror of
https://github.com/FellippeHeitor/InForm.git
synced 2025-01-14 11:39:33 +00:00
Cleanup INI library a bit
This commit is contained in:
parent
022fd0a97f
commit
33f896aaaa
3 changed files with 32 additions and 30 deletions
|
@ -10,8 +10,8 @@ $IF INI_BAS = UNDEFINED THEN
|
||||||
'$INCLUDE:'Ini.bi'
|
'$INCLUDE:'Ini.bi'
|
||||||
|
|
||||||
SUB IniSortSection (file$, __section$)
|
SUB IniSortSection (file$, __section$)
|
||||||
SHARED IniCODE, IniLastKey$, IniWholeFile$
|
SHARED IniCODE AS LONG, IniLastKey$, IniWholeFile$
|
||||||
SHARED IniDisableAutoCommit
|
SHARED IniDisableAutoCommit AS _BYTE
|
||||||
|
|
||||||
REDIM Keys(1 TO 100) AS STRING
|
REDIM Keys(1 TO 100) AS STRING
|
||||||
DIM TotalKeys, tempValue$, i AS LONG, Backup$, CommitBackup
|
DIM TotalKeys, tempValue$, i AS LONG, Backup$, CommitBackup
|
||||||
|
@ -63,7 +63,7 @@ $IF INI_BAS = UNDEFINED THEN
|
||||||
END SUB
|
END SUB
|
||||||
|
|
||||||
SUB IniDeleteSection (file$, __section$)
|
SUB IniDeleteSection (file$, __section$)
|
||||||
SHARED IniNewFile$, IniCODE, currentIniFileName$
|
SHARED IniNewFile$, IniCODE AS LONG, currentIniFileName$
|
||||||
SHARED IniLF$, IniWholeFile$, currentIniFileLOF AS _UNSIGNED LONG
|
SHARED IniLF$, IniWholeFile$, currentIniFileLOF AS _UNSIGNED LONG
|
||||||
|
|
||||||
IniLoad file$
|
IniLoad file$
|
||||||
|
@ -82,7 +82,7 @@ $IF INI_BAS = UNDEFINED THEN
|
||||||
END SUB
|
END SUB
|
||||||
|
|
||||||
SUB IniDeleteKey (file$, __section$, __key$)
|
SUB IniDeleteKey (file$, __section$, __key$)
|
||||||
SHARED IniPosition AS _UNSIGNED LONG, IniCODE
|
SHARED IniPosition AS _UNSIGNED LONG, IniCODE AS LONG
|
||||||
SHARED IniLF$, IniWholeFile$, IniSectionData$
|
SHARED IniLF$, IniWholeFile$, IniSectionData$
|
||||||
SHARED IniLastSection$, IniLastKey$, IniNewFile$
|
SHARED IniLastSection$, IniLastKey$, IniNewFile$
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ $IF INI_BAS = UNDEFINED THEN
|
||||||
SUB IniMoveKey (file$, __section$, __key$, __newsection$)
|
SUB IniMoveKey (file$, __section$, __key$, __newsection$)
|
||||||
'A move operation is a copy operation + a delete operation
|
'A move operation is a copy operation + a delete operation
|
||||||
|
|
||||||
SHARED IniCODE
|
SHARED IniCODE AS LONG
|
||||||
|
|
||||||
DIM tempValue$
|
DIM tempValue$
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ $IF INI_BAS = UNDEFINED THEN
|
||||||
|
|
||||||
SUB IniCommit
|
SUB IniCommit
|
||||||
SHARED currentIniFileName$, IniWholeFile$, currentIniFileLOF AS _UNSIGNED LONG
|
SHARED currentIniFileName$, IniWholeFile$, currentIniFileLOF AS _UNSIGNED LONG
|
||||||
SHARED IniNewFile$, IniDisableAutoCommit, IniCODE
|
SHARED IniNewFile$, IniDisableAutoCommit AS _BYTE, IniCODE AS LONG
|
||||||
SHARED LoadedFiles$
|
SHARED LoadedFiles$
|
||||||
|
|
||||||
IF currentIniFileName$ = "" THEN IniCODE = 18: EXIT SUB
|
IF currentIniFileName$ = "" THEN IniCODE = 18: EXIT SUB
|
||||||
|
@ -171,7 +171,7 @@ $IF INI_BAS = UNDEFINED THEN
|
||||||
END SUB
|
END SUB
|
||||||
|
|
||||||
FUNCTION IniGetSection$ (__section$)
|
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
|
SHARED IniLF$, IniWholeFile$, currentIniFileLOF AS _UNSIGNED LONG
|
||||||
|
|
||||||
IF currentIniFileName$ = "" THEN IniCODE = 18: EXIT FUNCTION
|
IF currentIniFileName$ = "" THEN IniCODE = 18: EXIT FUNCTION
|
||||||
|
@ -244,7 +244,7 @@ $IF INI_BAS = UNDEFINED THEN
|
||||||
END FUNCTION
|
END FUNCTION
|
||||||
|
|
||||||
FUNCTION IniFormatSection$ (__section$)
|
FUNCTION IniFormatSection$ (__section$)
|
||||||
SHARED IniCODE
|
SHARED IniCODE AS LONG
|
||||||
|
|
||||||
DIM section$
|
DIM section$
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ $IF INI_BAS = UNDEFINED THEN
|
||||||
FUNCTION ReadSetting$ (file$, __section$, __key$)
|
FUNCTION ReadSetting$ (file$, __section$, __key$)
|
||||||
SHARED IniLastSection$, IniLastKey$, IniWholeFile$, IniLF$
|
SHARED IniLastSection$, IniLastKey$, IniWholeFile$, IniLF$
|
||||||
SHARED IniPosition AS _UNSIGNED LONG, IniSectionData$
|
SHARED IniPosition AS _UNSIGNED LONG, IniSectionData$
|
||||||
SHARED IniCODE, IniAllowBasicComments
|
SHARED IniCODE AS LONG, IniAllowBasicComments AS _BYTE
|
||||||
SHARED currentIniFileLOF AS _UNSIGNED LONG
|
SHARED currentIniFileLOF AS _UNSIGNED LONG
|
||||||
|
|
||||||
IniLoad file$
|
IniLoad file$
|
||||||
|
@ -405,7 +405,7 @@ $IF INI_BAS = UNDEFINED THEN
|
||||||
END FUNCTION
|
END FUNCTION
|
||||||
|
|
||||||
SUB WriteSetting (file$, __section$, __key$, __value$)
|
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 IniLF$, IniWholeFile$, IniSectionData$
|
||||||
SHARED IniLastSection$, IniLastKey$, IniNewFile$
|
SHARED IniLastSection$, IniLastKey$, IniNewFile$
|
||||||
|
|
||||||
|
@ -563,7 +563,7 @@ $IF INI_BAS = UNDEFINED THEN
|
||||||
END SUB
|
END SUB
|
||||||
|
|
||||||
SUB IniSetForceReload (state AS _BYTE)
|
SUB IniSetForceReload (state AS _BYTE)
|
||||||
SHARED IniForceReload
|
SHARED IniForceReload AS _BYTE
|
||||||
IF state THEN
|
IF state THEN
|
||||||
IniForceReload = -1
|
IniForceReload = -1
|
||||||
ELSE
|
ELSE
|
||||||
|
@ -572,7 +572,7 @@ $IF INI_BAS = UNDEFINED THEN
|
||||||
END SUB
|
END SUB
|
||||||
|
|
||||||
SUB IniClose
|
SUB IniClose
|
||||||
SHARED IniDisableAutoCommit, currentIniFileName$
|
SHARED IniDisableAutoCommit AS _BYTE, currentIniFileName$
|
||||||
SHARED LoadedFiles$
|
SHARED LoadedFiles$
|
||||||
DIM findFile AS INTEGER, fileNum AS INTEGER
|
DIM findFile AS INTEGER, fileNum AS INTEGER
|
||||||
|
|
||||||
|
@ -595,9 +595,9 @@ $IF INI_BAS = UNDEFINED THEN
|
||||||
END SUB
|
END SUB
|
||||||
|
|
||||||
SUB IniLoad (file$)
|
SUB IniLoad (file$)
|
||||||
SHARED IniCODE, currentIniFileName$, IniLF$, IniWholeFile$
|
SHARED IniCODE AS LONG, currentIniFileName$, IniLF$, IniWholeFile$
|
||||||
SHARED currentIniFileLOF AS _UNSIGNED LONG
|
SHARED currentIniFileLOF AS _UNSIGNED LONG
|
||||||
SHARED IniForceReload
|
SHARED IniForceReload AS _BYTE
|
||||||
SHARED LoadedFiles$
|
SHARED LoadedFiles$
|
||||||
DIM fileNum AS INTEGER, findFile AS INTEGER
|
DIM fileNum AS INTEGER, findFile AS INTEGER
|
||||||
|
|
||||||
|
@ -655,7 +655,7 @@ $IF INI_BAS = UNDEFINED THEN
|
||||||
END SUB
|
END SUB
|
||||||
|
|
||||||
FUNCTION IniNextKey$
|
FUNCTION IniNextKey$
|
||||||
SHARED IniCODE, IniLF$, currentIniFileName$, IniSectionData$
|
SHARED IniCODE AS LONG, IniLF$, currentIniFileName$, IniSectionData$
|
||||||
SHARED IniPosition AS _UNSIGNED LONG
|
SHARED IniPosition AS _UNSIGNED LONG
|
||||||
STATIC lastDataBlock$, position AS _UNSIGNED LONG, tempLF$
|
STATIC lastDataBlock$, position AS _UNSIGNED LONG, tempLF$
|
||||||
|
|
||||||
|
@ -698,7 +698,7 @@ $IF INI_BAS = UNDEFINED THEN
|
||||||
END FUNCTION
|
END FUNCTION
|
||||||
|
|
||||||
FUNCTION IniNextSection$ (file$)
|
FUNCTION IniNextSection$ (file$)
|
||||||
SHARED IniCODE, IniLF$, IniWholeFile$
|
SHARED IniCODE AS LONG, IniLF$, IniWholeFile$
|
||||||
|
|
||||||
STATIC sectionStart AS _UNSIGNED LONG
|
STATIC sectionStart AS _UNSIGNED LONG
|
||||||
|
|
||||||
|
@ -746,7 +746,7 @@ $IF INI_BAS = UNDEFINED THEN
|
||||||
END FUNCTION
|
END FUNCTION
|
||||||
|
|
||||||
FUNCTION IniINFO$
|
FUNCTION IniINFO$
|
||||||
SHARED IniCODE
|
SHARED IniCODE AS LONG
|
||||||
SELECT CASE IniCODE
|
SELECT CASE IniCODE
|
||||||
CASE 0: IniINFO$ = "Operation successful"
|
CASE 0: IniINFO$ = "Operation successful"
|
||||||
CASE 1: IniINFO$ = "ERROR: File not found"
|
CASE 1: IniINFO$ = "ERROR: File not found"
|
||||||
|
|
|
@ -9,21 +9,23 @@ $IF INI_BI = UNDEFINED THEN
|
||||||
|
|
||||||
' TODO:
|
' 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.
|
' 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
|
'Global variables declaration
|
||||||
DIM currentIniFileName$, LoadedFiles$
|
DIM currentIniFileName AS STRING
|
||||||
|
DIM LoadedFiles AS STRING
|
||||||
DIM currentIniFileLOF AS _UNSIGNED LONG
|
DIM currentIniFileLOF AS _UNSIGNED LONG
|
||||||
DIM IniWholeFile$
|
DIM IniWholeFile AS STRING
|
||||||
DIM IniSectionData$
|
DIM IniSectionData AS STRING
|
||||||
DIM IniPosition AS _UNSIGNED LONG
|
DIM IniPosition AS _UNSIGNED LONG
|
||||||
DIM IniNewFile$
|
DIM IniNewFile AS STRING
|
||||||
DIM IniLastSection$
|
DIM IniLastSection AS STRING
|
||||||
DIM IniLastKey$
|
DIM IniLastKey AS STRING
|
||||||
DIM IniLF$
|
DIM IniLF AS STRING
|
||||||
DIM IniDisableAutoCommit ' _BYTE?
|
DIM IniDisableAutoCommit AS _BYTE
|
||||||
DIM IniCODE ' _BYTE?
|
DIM IniCODE AS LONG
|
||||||
DIM IniAllowBasicComments ' _BYTE?
|
DIM IniAllowBasicComments AS _BYTE
|
||||||
DIM IniForceReload ' _BYTE?
|
DIM IniForceReload AS _BYTE
|
||||||
|
|
||||||
$END IF
|
$END IF
|
||||||
|
|
|
@ -6,7 +6,7 @@ $(error "OS must be set to 'lnx', 'win', or 'osx'")
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifndef QB64PE_PATH
|
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
|
endif
|
||||||
|
|
||||||
ifeq ($(OS),lnx)
|
ifeq ($(OS),lnx)
|
||||||
|
|
Loading…
Reference in a new issue