Heheh... there's always someone out there who would want to
invent the perpetual motion machine or write self-modifying
code... but while the former is a pipe dream, the latter is
possible in MapBasic. They way to do it is to ensure that all
your expressions in the table lookup are actual expression that
evaluate to either True of False (i.e. all variables are declared
by runtime, and that they are syntactically correct expressions.
The hard way is to write your own recursive descent parser and
evaluate each, updating symbol tables as needed, as if your
expressions were lines of code. That's harder, but you can
implement your own language and make up any rules you like that
way.
Try entering this in the MapBasic window to see how the "run
command" statement can be used to evaluate simple expressions:
-----
dim iSAMPLE as integer
dim sExpression as string
dim bTruth as logical
iSAMPLE = 10
sExpression = "iSAMPLE = 10"
run command "bTruth = (" + sExpression + ")"
'The expression should be true here
print bTruth
iSAMPLE = 7
run command "bTruth = (" + sExpression + ")"
'The expression should be false now
print bTruth
-----
Good luck!
- Bill Thoen
"Gary S. Spring" wrote:
>
> I'm writing code that requires that I be able to store expressions in a
> table. So, for example, let's say I do the following:
>
> ' Get the contents of row 1, col 1 from table GARY and
> ' put them into a variable called sVALUE
>
> fetch first from GARY
> sVALUE = GARY.COL1
>
> Let's assume that the cell contains "iSAMPLE = 10" thus sVALUE would
> take on that string value. Nothing unusual so far. But, now I would
> like to use the string as a precondition in an IF statement. For
> example, say I have an integer variable called iSAMPLE that has been
> assigned a specific value. I want to use the contents of sVALUE to see
> if it equals 10.
>
> IF sVALUE THEN X = 2
>
> So if iSAMPLE = 10, then X would equal 2.
>
> Is this possible in MB, and if so, what type of variable would sVALUE
> be?
----------------------------------------------------------------------
To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]