March 04, 2021, 01:02:07 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
File Utilities
»
[bb] IniLib by JaviCervera [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bb] IniLib by JaviCervera [ 1+ years ago ] (Read 563 times)
BlitzBot
Jr. Member
Posts: 1
[bb] IniLib by JaviCervera [ 1+ years ago ]
«
on:
June 29, 2017, 12:28:39 AM »
Title :
IniLib
Author :
JaviCervera
Posted :
1+ years ago
Description :
The library is very easy to use. Just open or create the file with the standard ReadFile() and WriteFile() functions and use the library to read or write it. Here's a short description of what each command does:
IniGroup(IniHandle,Group$): Set the current group when reading INI files.
ReadIniField$(IniHandle,Key$[,DefVal$]): Reads a field in the current group. You can store the result into a Int, Float or String variable, depending on the type of data that the Ini Field stores.
WriteIniComment(IniHandle,Comment$): Writes a comment in the ini file.
WriteIniGroup(IniHandle,Group$): Creates a new group in the ini file.
WriteIniField(IniHandle,Key$,Value$): Creates a new field in th eini file.
Code :
Code: BlitzBasic
;*************************************************
; INI Access BlitzBasic library
; Written by Javier San Juan Cervera -- Jedive
; www.softiberia.tk
;*************************************************
Function
IniGroup
(
IniHandle,Group$
)
SeekFile
IniHandle,
0
If
Group$=
""
Then
Return
True
While
Not
Eof
(
IniHandle
)
If
Lower
$
(
ReadLine
$
(
IniHandle
)
)
=
"["
+
Lower
$
(
Group$
)
+
"]"
Then
Return
True
Wend
Return
False
End Function
;*************************************************
Function
ReadIniField$
(
IniHandle,Key$,DefVal$=
""
)
While
Chr
$
(
char
)
<>
"]"
And
FilePos
(
IniHandle
)
>
0
SeekFile
IniHandle,
FilePos
(
IniHandle
)
-
1
char=
ReadByte
(
IniHandle
)
If
Chr
$
(
char
)
<>
"]"
Then
SeekFile
IniHandle,
FilePos
(
IniHandle
)
-
1
Wend
ReadLine
$
(
IniHandle
)
While
Not
Eof
(
IniHandle
)
lin$=
Trim
$
(
ReadLine
$
(
IniHandle
)
)
If
Left
$
(
lin$,
1
)
=
"["
Then
Return
DefVal$
If
Left
$
(
lin$,
1
)
<>
"#"
And
Left
$
(
lin$,
1
)
<>
""
Then
If
Lower
$
(
Left
$
(
lin$,
Instr
(
lin$,
"="
,
1
)
-
1
)
)
=
Lower
$
(
Key$
)
Then
Return
Right
$
(
lin$,
Len
(
lin$
)
-
Instr
(
lin$,
"="
,
1
)
)
Wend
Return
DefVal$
End Function
;*************************************************
Function
WriteIniComment
(
IniHandle,Comment$
)
WriteLine
IniHandle,
"#"
+Comment$
End Function
;*************************************************
Function
WriteIniGroup
(
IniHandle,Group$
)
WriteLine
IniHandle,
"["
+Group$+
"]"
End Function
;*************************************************
Function
WriteIniField
(
IniHandle,Key$,Value$
)
WriteLine
IniHandle,Key$+
"="
+Value$
End Function
;*************************************************
Comments :
none...
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
File Utilities
»
[bb] IniLib by JaviCervera [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal