Sub ReadLanguageText(Language, Section, Key, Macro, Default) As String
Dim Item As String
Dim pos1 As Int
Dim pos2 As Int
Dim Blanks As Int
Dim li As String
Dim re As String
Item = ""
If File.Exists(cLngPath, Language) = True Then
Item = ReadLanguageFile(cLngPath, Language, Section, Key, Default)
If Item.IndexOf("<LF>") > -1 Then
Do While Item.IndexOf("<LF>") > -1
Item = Item.Replace("<LF>", CRLF)
Loop
End If
If Macro.Length > 0 AND Item.IndexOf("<DATA>") > -1 Then
Item = Item.Replace("<DATA>", Macro)
End If
pos1 = Item.IndexOf("#")
pos2 = Item.IndexOf2("#", pos1 + 1)
If pos1 > -1 AND pos2 > -1 Then
li = Item.SubString2(0, pos1)
re = item.SubString(pos2 + 1)
Blanks = Item.SubString2(pos1 + 1, pos2)
For i = 0 To Blanks
re = " " & re
Next
Item = li & re
End If
Else
Item = "?"
End If
Return Item
End Sub
Sub Replace(text As String, search As String, exchange As String) As String
Dim Item As String
Item = ""
If text.IndexOf(search) > -1 Then
Do While text.IndexOf(search) > -1
Item = text.Replace(search, exchange)
Loop
End If
Return Item
End Sub
Sub ReadLanguageFile(directory As String, fileINI As String, session As String, key As String, default As String)
Dim value As String
Dim rSECTION As String
Dim flgSESSION As Boolean
Dim rKEY As String
Dim flgKey As Boolean
Dim rdTEXT As TextReader
Dim p As Int
Dim k As String
LastError = ""
value = default
If File.Exists(directory, fileINI) = True Then
rSECTION = ""
flgSESSION = False
flgKEY = False
rKEY = ""
rdTEXT.Initialize2(File.OpenInput(directory, fileINI), "ISO-8859-1")
rSECTION = rdTEXT.ReadLine.Trim
Do While rSECTION <> Null
If (rSECTION <> "") AND (rSECTION.CharAt(0) <> ";") Then
If rSECTION.CompareTo("[" & session & "]") = 0 Then
flgSESSION = True
rKEY = rdTEXT.ReadLine
Do While rKEY <> Null
If rKEY <> "" Then
p = rKEY.IndexOf("=")
If p > -1 Then
If rKEY.SubString2(0, 0) <> "[" Then
k = rKEY.SubString2(0, p)
If key.CompareTo(k) = 0 Then
flgKEY = True
value = rKEY.SubString(p + 1)
Exit
End If
End If
End If
End If
rKEY = rdTEXT.ReadLine
Loop
End If
End If
If flgSESSION = True Then
Exit
Else
rSECTION = rdTEXT.ReadLine
End If
Loop
rdTEXT.Close
If flgSESSION = False Then
LastError = "SectionFoundError"
Else If flgKEY = False Then
LastError = "KeyFoundError"
End If
Else
LastError = "FileNotFoundError"
End If
Return value
End Sub