Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using eval and dot notation
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00366714
Message ID:
00366771
Views:
22
>>>>>>>Mixing dot notation and macro expansion or eval() always trips me up.
>>>>>>>In the "condition" field of the patient table is a logical expression that I want to evaluate to .T. or .F. Note: I need to refer to both the table and name since in my actual code there are two tables.
>>>>>>>
>>>>>>>select patient.name from patient where eval(patient.condition)
>>>>>
>>>>>>Give us a sample of the contents of the condition field.
>>>>>
>>>>>I can be ".T."
>>>>>or it can an expression that evaluations to T/F such as "HepBStatus(id) = 2"
>>>>
>>>>The first will work. The second won't unless HepBStatus is a program.
>>>
>>>HepBStatus() is a valid function that is loaded. What do you mean by "a program"? A function/procedure?
>>
>>Yep! Is id a field in the table?
>
>Yes. Will that be a problem?

It shouldn't. I was able to execute the following with no problem.
CREATE CURSOR Foo (somenum N, condition c(50))
APPEND BLANK
REPLACE somenum WITH 1, condition WITH ".T."
REPLACE somenum WITH 2, condition WITH "Goo(somenum) = 1"
SELECT * FROM Foo WHERE EVAL(condition) && Returns 2 records
GO BOTTOM
REPLACE somenum WITH 2, condition WITH "Goo(somenum) = 2"
SELECT * FROM Foo WHERE EVAL(condition) && Returns 1 record

* Exists in current directory
FUNCTION Goo
  LPARAMETER Junk
  RETURN Junk - 1
ENDFUNC
The above seems to work just fine and as expected.
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform