Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GetIni() need enhancement
Message
 
To
02/12/2003 22:07:12
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00855280
Message ID:
00855287
Views:
13
You don't need space(40)+chr(0). Open the ini file directly using fopen() and traverse it using fgets(). Use a case statement to check the left side of the = sign i.e.

pseudo code...
local lcStr,lnParm,lnLocation

FILE = fopen(myfile)
do while !feof(FILE)
  lcStr = fgets(FILE)
  lnParm = left(lcStr,rat("=",lcStr)-1)
  do case
    case upper(lnParm) == [URL]
      lnLocation = right(lcStr,len(lcStr)-rat("=",lcStr))
  endcase
enddo
fclose(FILE)
lnLocation will be equal to anything right of the = sign and you can add lines to the ini file easily by adding more cases to the case statement.

Assuming = is a reserved character in your ini files...


>I have this function to read a value from an INI file:
>
>
>* Return the value from an INI file
>* expC1 Section
>* expC2 Key
>* expC3 INI file
>FUNCTION GetIni
>PARAMETER tcSection,tcKey,tcFile
>PRIVATE lcBuffer,lnLocation
>tcFile=IIF(TYPE('tcFile')<>'C',oApp.IniFile,tcFile)
>lcBuffer=SPACE(40)+CHR(0)
>=GetPrivateProfileString(tcSection,tcKey,'',@lcBuffer,LEN(lcBuffer),tcFile)=0
>lnLocation=AT(CHR(0),lcBuffer)
>IF lnLocation>0
>   lcBuffer=SUBSTR(lcBuffer,1,lnLocation-1)
>ENDIF
>RETURN lcBuffer
>
>
>However, if I have an INI file like this:
>
>
>[WebService]
>Url=https://www.mydomain.com/OPX_MyDir/Something.asmx
>
>
>The value returned would stop at the _ sign. Anyone knows how to enhance the GetIni() function so it would grab the entire line?
Eric Kleeman - EDS Consulting Services
MCP Visual FoxPro
MCSD C#.NET
Hua Hin Thailand
Los Angeles California
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform