Evaluating User variables at runtime (OpenInsight Specific)
At 05 MAR 1998 04:03:07AM Peter Richards wrote:
Hi,
Sometimes there is a need to use a user variable in a function/event
but I do not want to hard code it. That is, I do not want to have
code like:
Company_Name=@USER0
when @USER0 is set on main menu create. Therefore, the user variables
are not known at compile time, but may be something like:
Globals=@USER0":@FM:"@RECURS0":@FM:"@RECURS0"
For b=1 to cnt
Locate Column_Values in Globals using @FM setting pos thenTemp=GlobalsColumn_Values=Temp ;* doesn't evaluateEndOf course the value of variable Temp is @USER0 when it finds one, but
I want to 'force' evaluation of @USER0 at runtime. I looked at the
'Function' function and that concept is what I am looking for, just
in a variable.
I think AREV had a command called EVAL or something like that.
How do I do it in OI ?
Peter
At 05 MAR 1998 04:36AM Oystein Reigem wrote:
Peter,
I found the following in my multi-megabyte scrapbook of possibly useful stuff scavenged off the CompuServe Revelation Forum and the RevSoft web-site (this is from the forum). I've never had use for it but maybe you will.
- Oystein -
#: 122673 S10/OI for Workgroups
17-Feb-96 23:34:58Sb: #122622-#COMPILE
Fm: Vernon Systems Ltd 100033,673
To: BILL NORTH 100334,2371 (X)
Bill,
I've written a little SP 'EVAL' to do this type of thing (to replicate ARev's
EVAL TCL command). You pass it some Basic+ code, using @ANS to return any
result. I also wrote it to evaluate various mathematical formula. It's also
very useful in the Exec line for testing Basic+ behaviour with certain
statements, looking at labelled common variables, and it's really handy for
unlocking any records that remain locked (RUN EVAL 'UNLOCK ALL'). Within a
program, you can declare it as either a subroutine or a function. If you use it
as a function, it returns whatever you set @ANS to in your formula. If you
think this might be useful, I could send you the code.
Matt.
There is 1 Reply.
#: 122724 S10/OI for Workgroups
19-Feb-96 13:42:47Sb: #122673-#COMPILE
Fm: BILL NORTH 100334,2371
To: Vernon Systems Ltd 100033,673 (X)
Matt,
Yes that sounds as if it would be perfect. I would appreciate if you could send
me the SP.
Regards
Bill North
Ardbrook Ltd
Dublin, Ireland
There is 1 Reply.
#: 122751 S10/OI for Workgroups
19-Feb-96 21:51:06Sb: #122724-#COMPILE
Fm: Vernon Systems Ltd 100033,673
To: BILL NORTH 100334,2371 (X)
Bil,
I've dug up the routine. It's quite short so I'll just put up the source code.
…
Function Eval (Formula)
/* Matthew Crozier 19 Jun 1995
Vernon Systems LtdExecute a line of BASIC+ source code. The return value is the contentsof @ANS as set in the formula.*/
Declare subroutine RTP5
Declare function unassigned
Equ label$ to '%EVAL%'
Common label$ seq
Open 'SYSOBJ' to sysobj thenIf unassigned( seq) then seq=1 else seq += 1code.id=label$: '.': @station: '.': seqcode=formula: @fm: 'END'RTP5( '', code, label$: @fm: 'SETCUL', result, 'M')If result thenWrite code to sysobj, '$': code.id thenCall @code.idTransfer @ans to resultDelete sysobj, '$': code.id else nullEnd else result=Can't write object code"End elseTransfer code to resultEndEnd else result=Can't open SYSOBJ"Return result
There is 1 Reply.
#: 122785 S10/OI for Workgroups
20-Feb-96 08:45:41Sb: #122751-COMPILE
Fm: BILL NORTH 100334,2371
To: Vernon Systems Ltd 100033,673
Matt,
Many Thanks, I will give the code a try.
Regards
Bill North
Ardbrook Ltd
Dublin, Ireland
At 05 MAR 1998 07:33AM Cameron Revelation wrote:
Peter,
Sometimes there is a need to use a user variable in a function/event but I do not want to hard code it.
Use a labelled common block:
<code> x=any string" common //x// value1, value2</code>
When you are done using the common block:
<code> x=any string" freecommon x</code>
Cameron Purdy
info@revelation.com
At 05 MAR 1998 10:01PM Peter Richards wrote:
Cameron & Oystein,
Thank you both for your help on this one.
Peter