Para ello cree estas dos funciones, (utilicé ";" como separador pero se puede usar otro caracter), las incluí en mi libreria y las comparto.
Code: Select all
// Function ArrayToIni (Array) return unidimensional array values in string divided by ";"
Function ArrayToIni (aArray)
LOCAL cText := ""
LOCAL Elemento
If HMG_Len (aArray) > 0
For Each Elemento In aArray
If ValType ( Elemento) == "N" // Array only have character values but...
Elemento := AllTrim ( Str ( Elemento))
EndIf
cText := cText + Elemento + ";"
Next
EndIf
Return cText
Code: Select all
// Function IniToArray (Text from .ini file) restore unidimensional array from ArrayToIni () format
Function IniToArray (cIni)
LOCAL aArray := {}
LOCAL cText := ""
LOCAL nPos := 0
If ! Empty (cIni)
While .T.
nPos := Hb_Uat (";",cIni)
cText := Hb_UsubStr (cIni, 1, nPos - 1)
If Empty (cText)
Exit
EndIf
Aadd (aArray, cText)
cIni := Stuff (cIni, 1, nPos, "")
EndDo
EndIf
Return aArray