Hi Tracy,
Although you have a solution from George, I thought that I would share this anyway. I found this out after pulling much hair not too long ago. The GetPrivateProfileString adds an extra Null, chr(0), at the end of the returned value. I found that doing the following solved the problems I was having with comparisons:
lcMyVal = SPACE(5)
x = GetPrivateProfilestring("DATA","dataentry","NULL",@lcMyVal,5,"Myapp.INI")
<b>lcMyVal = STRTRAN(lcMyVal,CHR(0),"")</b>
lcMyVal = ALLTRIM(lcMyVal)
- Brian
>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
VFP6 SP5, VFP8 SP1, VFP 9 SP 1 and Win XP SP 3 (unless otherwise specified)
www.wulfsden.com