It is just a method in a wwWebPage, reading the value from a field in an instance of wwBusiness. I resolved it by using CAST() instead of STR(). STR() fails if the value is a string. CAST() works either way. Just kind of strange that the value of the field is 1. One time VFP sees it as a string and the next time VFP sees it as a numeric.
Not sure, I've never seen that... I think you need to do a bit more sleuthing. I've had stuff like this happen myself and invariably it turns out there's something doing a conversion (like an Access value or a constructor or, or, or...).
Don't trust the debugger either - the debugger often will show the type for a value that was initially held, if the type changes it's not uncommon for the type to still show the old type.
+++ Rick ---
Hi,
I have a problem that VFP is interpreting a variable's datatype, differently.
THIS.oEntry is an instance of wwBusiness. I am trying to concat THIS.oEntry.oData.FK_PROVIDER into a string. FK_PROVIDER is a 32-bit integer.
Within a single method, one time VFP interprets the datatype as numeric. Therefore, I have to cast it to STR(THIS.oEntry.oData.FK_PROVIDER). However, the next time that the method executes, VFP returns an error, because it sees THIS.oEntry.oData.FK_PROVIDER as a character type.
Looking at the Watch list:
Watch Name = THIS.oEntry.oData.FK_PROVIDER
Value = "1"
Type = C
Watch Name = TYPE(THIS.oEntry.oData.FK_PROVIDER)
Value ="N"
I tried storing THIS.oEntry.oData.FK_PROVIDER into a local variable and testing the variable.
sTemp = THIS.oEntry.oData.FK_PROVIDER
Watch Name = sTemp
Value = "1"
Type = C
Watch Name = TYPE(sTemp)
Value ="N"
I tried writing this a few ways. Here is my current code:
sTemp = THIS.oEntry.oData.FK_PROVIDER
IF TYPE(sTemp) = "N" THEN
sProvider = ALLTRIM(STR(sTemp))
ELSE
sProvider = ALLTRIM(sTemp)
ENDIF
*** Check Record Number for datatype too.
sTemp = THIS.oEntry.oData.RECORD_NUMBER
IF TYPE(sTemp) = "N" THEN
sRecord = ALLTRIM(STR(sTemp))
ELSE
sRecord = ALLTRIM(sTemp)
ENDIF
sSQL = "SELECT * FROM roi.v_PATIENT_LIST WHERE FK_PROVIDER = " + sProvider + ;
" AND RECORD_NUMBER = '" + sRecord + "'"
In this case, IF TYPE(sTemp) = "N" THEN returns .T. However, VFP produces the error: "Function argument value, type, or count is invalid." If I just call ALLTRIM(sTemp), it will work this time. However, when I press a button and the method executes again, it will fail.
How can I get this to work consistently?
Thanks,
David