{{tag>category:"OpenInsight Specific"}} [[https://www.revelation.com/|Sign up on the Revelation Software website to have access to the most current content, and to be able to ask questions and get answers from the Revelation community]] ==== 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 then Temp=Globals Column_Values=Temp ;* doesn't evaluate End Of 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:58 Sb: #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:47 Sb: #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:06 Sb: #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 Ltd Execute a line of BASIC+ source code. The return value is the contents of @ANS as set in the formula. */ Declare subroutine RTP5 Declare function unassigned Equ label$ to '%EVAL%' Common //label$// seq Open 'SYSOBJ' to sysobj then If unassigned( seq) then seq=1 else seq += 1 code.id=label$: '.': @station: '.': seq code=formula: @fm: 'END' RTP5( '', code, label$: @fm: 'SETCUL', result, 'M') If result then Write code to sysobj, '$': code.id then Call @code.id Transfer @ans to result Delete sysobj, '$': code.id else null End else result=Can't write object code" End else Transfer code to result End End else result=Can't open SYSOBJ" Return result There is 1 Reply. #: 122785 S10/OI for Workgroups 20-Feb-96 08:45:41 Sb: #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, [i]Sometimes there is a need to use a user variable in a function/event but I do not want to hard code it.[/i] Use a labelled common block: x=any string" common //x// value1, value2 When you are done using the common block: x=any string" freecommon x 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 [[https://www.revelation.com/revweb/oecgi4p.php/O4W_HANDOFF?DESTN=O4W_RUN_FORM&INQID=NONWORKS_READ&SUMMARY=1&KEY=CBF66141A221FBAC852565BE0031B972|View this thread on the forum...]]