Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
#DEFINE problem
Message
From
07/02/2006 16:05:23
 
 
To
07/02/2006 15:58:56
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01094430
Message ID:
01094435
Views:
12
This message has been marked as a message which has helped to the initial question of the thread.
Hi Tracy,
Because #DEFINE's work different than variables. You can't EVALUATE() a #DEFINE because the text (at least in OTHER languages) is evaluated when the code is compiled, and not on the fly at run-time. I believe Fox interprets these the same way.

#DEFINE myName "Paul"

At compile time, everywhere myName is found in code, it is replaced with "Paul". When the code is run, it doesn't know that myName exists anymore. It just knows 'Paul'. Putting in a breakpoint and checking for UGI_CCONFEE in your locals should confirm this. It won't be there.


>I have in a method of a form:
>
>FOR m.icounter = 1 TO THISFORM.ControlCount
>	oControl = ThisForm.Controls[m.icounter]
>	IF ALLTRIM(UPPER(oControl.Baseclass)) = "TEXTBOX"
>		IF !EMPTY(oControl.Tag) .and. !EMPTY(oControl.controlsource)
>			TRY
>				qtag = ocontrol.Tag
>				qnewval = EVALUATE(oControl.controlSource)
>				qtype = TYPE('EVALUATE(oControl.controlsource)')
>				qsysnum = thisform.ca_sysnum
>				qagnum = thisform.ca_ag_num
>                                *UWUSRCreate is a program part of which is shown below
>				=UWUSRCreate(qTag,qnewval,qtype,qsysnum,qagnum)
>			CATCH
>			ENDTRY
>		ENDIF
>	ENDIF
>ENDFOR
>
>A snapshot of the UWUSRCreate function:
>
>LPARAMETERS tRecord, tValue, tType, tCoId, tAgId
>
>*I verified that at this point the following values are correct:
>*tRecord = "UGI_CCONFEE"
>*tValue = 1.15
>*tType = "N"
>*tcoId = 12
>*tAgId = ""
>
>#DEFINE UGI_CCONFEE        8159760   && Contract Fee
>
>TRY
>   iGroupID = EVALUATE(tRecord)
>CATCH
>   iGroupID = 0  && I land here because UGI_CCONFEE is undefined why?
>ENDTRY
>
>Yet this works from the command window:
>
>UGI_CCONFEE = 8159760
>trecord = "UGI_CCONFEE"
>?EVALUATE(trecord) && returns 8159760 as it should
>
>Why does it not work in my program using #DEFINE? I must be overlooking something basic... ?
>
>TIA,
>Tracy
Paul A. Busbey
Victoria Insurance
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform