>I have a requirement to pull settings from an ini file created and maintained by another application that is NOT under MY control, so storing information in the registry is not an option. I'm using the function below to get the information which 99% of the time is successful. The problem I am having is with the return string--it is an extra byte longer so when I do a string comparison with the same characters stored in a variable in my VFP app-they do not match. If this function below returns variable xReturn and xReturn="GW38329" and I compare that with variable x which equals "GW38329" for instance, they will not match. In fact, the length of xReturn will be 8 and the len of x will be 7. Anyone have any ideas on how to convert the return the value? I've tried strconv() and isleading() to no avail. I've verified the codepages match so that should not be the problem. This works by the way using low-level file access FGETS(). Here is the function portion of my prg (I included
>the parameters section for information):
>
>
>** GET_INI.PRG
>PARAMETERS xinifile,xinisection,xiniitem
>
> * GETPRIVATEPROFILESTRING win32api Parameters:
> * xIniSection = pointer to a null-terminated string that specifies the name of the
> * section containing the key name.
> * xIniItem = Pointer to the null-terminated string specifying the name of the
> * key whose associated string is to be retrieved.
> * xDefaultItem = Pointer to a null-terminated default string.
> * xReturn = Pointer to the buffer that receives the retrieved string.
> * xSize = Specifies the size, in TCHARS, of the buffer pointed to by the
> * xReturn parameter.
> * xIniFile = Pointer to a null-terminated string that specifies the name of the
> * the initialization file.
>
> *--Retrieve the key's string
> LOCAL xSize
> xSize=0
> xReturn=SPACE(255)
> DECLARE integer GetPrivateProfileString IN Win32API AS GetINI ;
> string xIniSection,string xIniItem,string xDefaultItem,;
> string xReturn,integer xSize,string xIniFile
> xSize=GETINI(@xIniSection,@xIniItem,"",@xReturn,LEN(xReturn)+1,xIniFile)
> IF xSize>0 && did we successfully retrieve the key's string?
> IF LEN(ALLTRIM(xReturn))=0
> xreturn = ' '
> RETURN xReturn
> ENDIF
> RETURN ALLTRIM(xReturn)
> ELSE
> xreturn = ' '
> RETURN xReturn
> ENDIF
>
>
>
>Any help is greatly appreciated!
Tracy,
Try looking at my
INI Files Class from the download section.
George
Ubi caritas et amor, deus ibi est