Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
INI section to array
Message
De
20/11/2008 09:17:15
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01362902
Message ID:
01363134
Vues:
16
>>>>Hi..
>>>>
>>>>Even with the sensation of a 'Deja vu'... I'd like to ask.. If ayone over there has a VFP function to retrieve a list of entries inside of a section into some INI file.. And don't mine to share here with us
>>>>
>>>>Some sort of:
>>>>
>>>>dimension laINIentries[1,1]
>>>>laINIentries = getinientries("myow.ini", "sectionA")
>>>>
>>>>TIA
>>>>
>>>>Claudio
>>>
>>>NOT TESTED AT ALL:
>>>
>>>laINIentries = getinientries("myow.ini", "sectionA")
>>>
>>>
>>>FUNCTION GetINIEntries(lcInitFile, lcSection)
>>>lcInitFile = FULLPATH(lcInitFile)
>>>
>>>DECLARE INTEGER  GetPrivateProfileSection IN WIN32API STRING lcSection,;
>>>                                                      STRING @lpReturnedString,;
>>>                                                      INTEGER nSize,;
>>>                                                      STRING lcINIFileName
>>>LOCAL lcString
>>>lcString = SPACE(8000)
>>>IF GetPrivateProfileSection(m.lcSection, @lcString, 8000, lcInitFile) > 0
>>>   DECLARE laLines[1]
>>>   ALINES(laLines, lcString)
>>>   RETURN @laLines
>>>ENDIF
>>>RETURN NULL
>>>
>>
>>hi Borislav... tks for your repli...
>>
>>well.... GetPrivateProfileSection(m.lcSection, @lcString, 8000, lcInitFile) doesnt give to variable lcstring any CR and/or LF... it is space (or other code) in each entry... I'm trying to figure out.. how may I separate those entries.
>>
>>is the parameter 8000 means the size of the output string?
>
>Yes, 8000 is the size of the buffer.
>BTW I think the entries are separated with CHR(0).

Yes,,, right.. So am I...

here is the the mature release working here (I had to create a property named this.lareturn) because a bug doesn't allow me to return a local array inside this method :
*FUNCTION GetINIEntries(lcInitFile, lcSection) changed to method
LPARAMETERS lcInitFile, lcSection
lcInitFile = FULLPATH(lcInitFile)

DECLARE INTEGER  GetPrivateProfileSection IN WIN32API STRING lcSection,;
                                                      STRING @lpReturnedString,;
                                                      INTEGER nSize,;
                                                      STRING lcINIFileName
LOCAL lcString, laLines,x, lnposeq 
lcString = SPACE(9000)
IF  GetPrivateProfileSection(m.lcSection, @lcString, 9000, lcInitFile) > 0
	lcString = CHRTRAN(lcString,CHR(0),CHR(13))
	*_cliptext=lcString
   DECLARE laLines[100]
   ALINES(laLines, lcString, 4)
   x=0
   FOR EACH lcline IN lalines
   		x=x+1
   		lnposeq 		 = AT('=',lcline)
   		IF  lnposeq > 0
	   		DIMENSION this.lareturn[x, 2]
   			this.lareturn[x, 1]   = ALLTRIM(SUBSTR(lcline,1,lnposeq-1))
   			this.lareturn[x, 2]   = ALLTRIM(STUFF(lcline,1,lnposeq,""))
   		ELSE
	   		DIMENSION this.lareturn[x, 2]
   			this.lareturn[x, 1]   = lcline
   			this.lareturn[x, 2]   = ""
   		ENDIF
   ENDFOR
   RETURN @this.lareturn
ENDIF
RETURN NULL
Thansk for both you and Naomi
"Now to him who is able to do immeasurably more than all we ask or imagine, according to his power that is at work within us, Ephesians 3:20
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform