heres what i did for my gui:
Strict
' Test out some functions
Local myTestFile:TStream = ReadFile("testini.ini")
Local bExit:Byte
While bExit = False
Select Upper(HiReadTag(myTestFile))
Case "START"
bExit = False
Case "SOME VARS"
Local myInt% = HiReadInt(myTestFile)
Print myInt
Local myByte:Byte = HiReadByte(myTestFile)
Print myByte
Local myFloat# = HiReadFloat(myTestFile)
Print myFloat
Local myDouble! = HiReadDouble(myTestFile)
Print myDouble
Local myString$ = HiReadString(myTestFile)
Print myString
Case "SOME ARRAYS"
Local myIntAr:Int[]
myIntAr = HiReadIntArray(myTestFile)
For Local myInt% = EachIn myIntAr
Print myInt
Next
Local myByteAr:Byte[]
myByteAr = HiReadByteArray(myTestFile)
For Local myByte:Byte = EachIn myByteAr
Print myByte
Next
Local myFloatAr#[]
myfloatAr = HiReadFloatArray(myTestFile)
For Local myfloat# = EachIn myfloatAr
Print myfloat
Next
Local myDoubleAr![]
myDoubleAr = HiReadDoubleArray(myTestFile)
For Local myDouble! = EachIn myDoubleAr
Print myDouble
Next
Local myStringAr$[]
myStringAr = HiReadStringArray(myTestFile)
For Local myString$ = EachIn myStringAr
Print myString
Next
Case "END"
bExit = True
End Select
Wend
CloseFile(myTestFile)
' HiReadTag(kFile:TStream)
' =======================
Function HiReadTag:String(kFile:TStream = Null)
Local sLine:String = ReadLine(kFile)
Local sTag:String
Local iPos
If Mid(sLine, 1, 1) = "[" Then
For iPos = 2 To Len(sLine) - 1
sTag:+ Mid(sLine, iPos, 1)
Next
EndIf
Return sTag
End Function
' HiReadIntArray(kFile:TStream)
' ============================
Function HiReadIntArray:Int[](kFile:TStream = Null)
Local sLine:String = ReadLine(kFile)
Local iVarSize = 1
Local sVarSize:String = ""
Local sVar:String = ""
Local bReadSize:Byte = False
Local iPos:Int, iVarReadStart:Int
For iPos = 1 To Len(sLine)
If bReadSize = True Then
If Mid(sLine, iPos, 1) <> "]" Then
sVarSize:+ Mid(sLine, iPos, 1)
Else
iVarReadStart = iPos + 3
Exit
EndIf
End If
If Mid(sLine, iPos, 1) = "[" Then
bReadSize = True
End If
Next
iVarSize = Int(sVarSize)
Local iVar:Int[iVarSize]
Local iCount:Int
For iPos = iVarReadStart To Len(sLine)
If Mid(sLine, iPos, 1) <> "," Then
sVar:+ Mid(sLine, iPos, 1)
Else
iVar[iCount] = Int(sVar)
sVar = ""
iCount:+ 1
End If
Next
iVar[iCount] = Int(sVar)
sVar = ""
Return iVar
End Function
' HiReadByteArray(kFile:TStream)
' ============================
Function HiReadByteArray:Byte[](kFile:TStream = Null)
Local sLine:String = ReadLine(kFile)
Local iVarSize = 1
Local sVarSize:String = ""
Local sVar:String = ""
Local bReadSize:Byte = False
Local iPos:Int, iVarReadStart:Int
For iPos = 1 To Len(sLine)
If bReadSize = True Then
If Mid(sLine, iPos, 1) <> "]" Then
sVarSize:+ Mid(sLine, iPos, 1)
Else
iVarReadStart = iPos + 3
Exit
EndIf
End If
If Mid(sLine, iPos, 1) = "[" Then
bReadSize = True
End If
Next
iVarSize = Int(sVarSize)
Local iVar:Byte[iVarSize]
Local iCount:Int
For iPos = iVarReadStart To Len(sLine)
If Mid(sLine, iPos, 1) <> "," Then
sVar:+ Mid(sLine, iPos, 1)
Else
iVar[iCount] = Byte(sVar)
sVar = ""
iCount:+ 1
End If
Next
iVar[iCount] = Byte(sVar)
sVar = ""
Return iVar
End Function
' HiReadFloatArray(kFile:TStream)
' ============================
Function HiReadFloatArray:Float[](kFile:TStream = Null)
Local sLine:String = ReadLine(kFile)
Local iVarSize = 1
Local sVarSize:String = ""
Local sVar:String = ""
Local bReadSize:Byte = False
Local iPos:Int, iVarReadStart:Int
For iPos = 1 To Len(sLine)
If bReadSize = True Then
If Mid(sLine, iPos, 1) <> "]" Then
sVarSize:+ Mid(sLine, iPos, 1)
Else
iVarReadStart = iPos + 3
Exit
EndIf
End If
If Mid(sLine, iPos, 1) = "[" Then
bReadSize = True
End If
Next
iVarSize = Int(sVarSize)
Local iVar:Float[iVarSize]
Local iCount:Int
For iPos = iVarReadStart To Len(sLine)
If Mid(sLine, iPos, 1) <> "," Then
sVar:+ Mid(sLine, iPos, 1)
Else
iVar[iCount] = Float(sVar)
sVar = ""
iCount:+ 1
End If
Next
iVar[iCount] = Float(sVar)
sVar = ""
Return iVar
End Function
' HiReadDoubleArray(kFile:TStream)
' ============================
Function HiReadDoubleArray:Double[](kFile:TStream = Null)
Local sLine:String = ReadLine(kFile)
Local iVarSize = 1
Local sVarSize:String = ""
Local sVar:String = ""
Local bReadSize:Byte = False
Local iPos:Int, iVarReadStart:Int
For iPos = 1 To Len(sLine)
If bReadSize = True Then
If Mid(sLine, iPos, 1) <> "]" Then
sVarSize:+ Mid(sLine, iPos, 1)
Else
iVarReadStart = iPos + 3
Exit
EndIf
End If
If Mid(sLine, iPos, 1) = "[" Then
bReadSize = True
End If
Next
iVarSize = Int(sVarSize)
Local iVar:Double[iVarSize]
Local iCount:Int
For iPos = iVarReadStart To Len(sLine)
If Mid(sLine, iPos, 1) <> "," Then
sVar:+ Mid(sLine, iPos, 1)
Else
iVar[iCount] = Double(sVar)
sVar = ""
iCount:+ 1
End If
Next
iVar[iCount] = Double(sVar)
sVar = ""
Return iVar
End Function
Function HiReadStringArray:String[](kFile:TStream = Null)
Local sLine:String = ReadLine(kFile)
Local iVarSize = 1
Local sVarSize:String = ""
Local sVar:String = ""
Local bReadSize:Byte = False
Local iPos:Int, iVarReadStart:Int
For iPos = 1 To Len(sLine)
If bReadSize = True Then
If Mid(sLine, iPos, 1) <> "]" Then
sVarSize:+ Mid(sLine, iPos, 1)
Else
iVarReadStart = iPos + 3
Exit
EndIf
End If
If Mid(sLine, iPos, 1) = "[" Then
bReadSize = True
End If
Next
iVarSize = Int(sVarSize)
Local iVar:String[iVarSize]
Local iCount:Int
For iPos = iVarReadStart To Len(sLine)
If Mid(sLine, iPos, 1) <> "," Then
sVar:+ Mid(sLine, iPos, 1)
Else
iVar[iCount] = String(sVar)
sVar = ""
iCount:+ 1
End If
Next
iVar[iCount] = String(sVar)
sVar = ""
Return iVar
End Function
' HiReadInt(kFile:TStream)
' ============================
Function HiReadInt:Int(kFile:TStream = Null)
Local sLine:String = ReadLine(kFile)
Local sVar:String = ""
Local bReadSize:Byte = False
Local iPos:Int, iVarReadStart:Int
Local iVar:Int
For iPos = 1 To Len(sLine)
If Mid(sLine, iPos, 1) = "=" Then
iVarReadStart = iPos + 2
End If
Next
For iPos = iVarReadStart To Len(sLine)
sVar:+ Mid(sLine, iPos, 1)
Next
iVar = Int(sVar)
sVar = ""
Return iVar
End Function
' HiReadByte(kFile:TStream)
' ============================
Function HiReadByte:Byte(kFile:TStream = Null)
Local sLine:String = ReadLine(kFile)
Local sVar:String = ""
Local bReadSize:Byte = False
Local iPos:Int, iVarReadStart:Int
Local iVar:Byte
For iPos = 1 To Len(sLine)
If Mid(sLine, iPos, 1) = "=" Then
iVarReadStart = iPos + 2
End If
Next
For iPos = iVarReadStart To Len(sLine)
sVar:+ Mid(sLine, iPos, 1)
Next
iVar = Byte(sVar)
sVar = ""
Return iVar
End Function
' HiReadFloat(kFile:TStream)
' ============================
Function HiReadFloat:Float(kFile:TStream = Null)
Local sLine:String = ReadLine(kFile)
Local sVar:String = ""
Local bReadSize:Byte = False
Local iPos:Int, iVarReadStart:Int
Local iVar:Float
For iPos = 1 To Len(sLine)
If Mid(sLine, iPos, 1) = "=" Then
iVarReadStart = iPos + 2
End If
Next
For iPos = iVarReadStart To Len(sLine)
sVar:+ Mid(sLine, iPos, 1)
Next
iVar = Float(sVar)
sVar = ""
Return iVar
End Function
' HiReadDouble(kFile:TStream)
' ============================
Function HiReadDouble:Double(kFile:TStream = Null)
Local sLine:String = ReadLine(kFile)
Local sVar:String = ""
Local bReadSize:Byte = False
Local iPos:Int, iVarReadStart:Int
Local iVar:Double
For iPos = 1 To Len(sLine)
If Mid(sLine, iPos, 1) = "=" Then
iVarReadStart = iPos + 2
End If
Next
For iPos = iVarReadStart To Len(sLine)
sVar:+ Mid(sLine, iPos, 1)
Next
iVar = Double(sVar)
sVar = ""
Return iVar
End Function
' HiReadString(kFile:TStream)
' ============================
Function HiReadString:String(kFile:TStream = Null)
Local sLine:String = ReadLine(kFile)
Local sVar:String = ""
Local bReadSize:Byte = False
Local iPos:Int, iVarReadStart:Int
For iPos = 1 To Len(sLine)
If Mid(sLine, iPos, 1) = "=" Then
iVarReadStart = iPos + 2
End If
Next
For iPos = iVarReadStart To Len(sLine)
sVar:+ Mid(sLine, iPos, 1)
Next
Return sVar
End Function testini.ini
[start]
[some vars]
myint= 1024
mybyte= 7
myfloat= 4.7
mydouble= 99.92
mystring= a string in an ini file
[some arrays]
myintarray[10]= 1,2,3,4,5,6,7,8,9,10
mybytearray[10]= 1,2,3,4,5,6,7,8,9,10
myfloatarray[10]= 1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5,10.5
mydoublearray[10]= 1.07,2.07,3.07,4.07,5.07,6.07,7.07,8.07,9.07,10.07
mystringarray[10]= a1,b2,c3,d4,e5,f6,g7,h8,i9,j10
[end]
i'm have trouble with the arrays at the mo but once thats fixed it'll be done. and bmax doesnt like float/double ethier.
Edit - Fixed it now. It didn't cause of how i was going through the file. i forgot i made it easy to read the file in one go.
Edit 2 - you'll notice that you need a start and end tag. I put this in to make easy entry/exit code
enjoy.