Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Strange function behavior
Message
From
23/06/1999 11:13:27
Jolene Dicks
Human Resources Development Canada
St. John's, Newfoundland, Canada
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Strange function behavior
Miscellaneous
Thread ID:
00233004
Message ID:
00233004
Views:
76
Hi,

I have a program that does a bunch of replace statements and replaces with the return value of a function. The function basically is passed a field name and a field value and then looks both up in a table for a matching value for that field and value. The code looks like this:


Replace DataFile.Sex withThisFormSet.CjsConvert("SEX",
UpdFile.Sex,type,"DataFile"+".sex"),"CLIENT.SEX")

Replace DataFile.NtvGrp with ThisFormSet.CjsConvert("NATIVE_CD",UpdFile.Native_cd,Type
("DataFile"+".NtvGrp"),"CLIENT.NTVGRP")

Replace DataFile.DisGrp with ThisFormSet.CjsConvert("DISABLE_CD",UpdFile.Disable_cd,Type("DataFile"+".DisGrp"),"CLIENT.DISGRP")

Replace DataFile.LangSpoke with ThisFormSet.CjsConvert("LANG_SPOKE",UpdFile.Lang_Spoke,Type("DataFile"+".LangSpoke"),"CLIENT.LANGSPOKE")

Replace DataFile.LangWrite with ThisFormSet.CjsConvert("LANG_WRIT",UpdFile.Lang_Writ,Type("DataFile"+".LangWrite"),"CLIENT.LANGWRITE")


Then the function code for CjsConvert looks like this:


Parameters PCJSField, PCJSValue, PFldType,PCATSField


Select Convert && This is the table that contains the fields names
Go Top && and field values.

Locate for Allt(Convert.CjsFld) = Allt(PCjsField) and Convert.CjsValue=PCjsValue

If Found()
If PFldType="N"
CharVar=.F.
CCATSVal=Convert.CatsValue
Endif
If PFldType="C"
CharVar=.T.
CCATSVal=Convert.CatsValue
Endif

Else
CCATSVal=DBGetProp(PCATSField,"Field","DefaultValue")
If PFldType="N"
CharVar=.F.
Endif
If PFldType="C"
CharVar=.T.
Endif
Endif
If CharVar=.F.
Return Val(CCATSVal)
Endif
If CharVar=.T.
Return CCATSVal
Endif

If it finds the field and value in that table it returns the predefined CATS value from the table. But if it doesn't find it in the convert table, I used the DBGETPROP() to pick up the default value for that field. This seems to work. However, once the replace statement is executed in the main program, the replace doesn't seem to excecute. Anyone have any suggestions on what to try.
Next
Reply
Map
View

Click here to load this message in the networking platform