Kevin wrote:
>Well, I had hope the ^DIM would work for me.  Unfortunately it imposes
>SAC (SAAC? SACC?) restrictions.  It I try this"
>
>set X="SET TEMP=$GET(k)" do ^DIM
>
>X will be deleted.  I assume this is because lowercase variables are
>not allowed.
>My debugger is not designed to be VA specific, so allow a user to use
>variables with lower case.
>
>I'll have to keep looking for a solution.  My next plan is to $piece
>through the parts of a reference to ensure no null nodes.

If that's all you want, how about this for a start?

eval(k) ;function - evaluate a simple array reference
        if k'?.1"^"1(1"%",1A).7AN1"("1.ANP1")" q "ERROR: not an array reference"
        n subs s subs=$e(k,$f(k,"("),$l(k)-1)
        n i,j,sub,error
        f i=1:1 d  q:subs=""!$d(error)
        . f j=1:1:$l(subs,",") s sub=$p(subs,",",1,j) q:$l(sub,"""")#2
        . s subs=$p(subs,",",j+1,$l(subs,","))
        . if sub="" s error="missing subscript" q
        . e  if $l(sub,"""")#2=0 s error="unbalanced quotes" q
        . e  if sub?.1"-"1.n,sub=+sub q  ;canonic number OK
        . e  if sub?1(1"%",1A).7AN d  q  ;simple variable name OK if defined
        . . if $d(@sub)#2=0 s error="variable '"_sub_"' undefined"
        . e  if sub'?1""""1.e1"""" s error="malformed subscript" q
        if $d(error) q "ERROR: "_error_", subscript "_i_"."
        q $g(@k)

Examples---

 ^DIC(1,0,"GL")           ^DIC(
 ^DIC(1,,"GL")            ERROR: missing subscript, subscript 2.
 ^DIC(1,x,"GL")           ERROR: variable 'x' undefined, subscript 2.
 ^DIC(1,0,"GL)            ERROR: unbalanced quotes, subscript 3.
 ^DIC(1,0X,"GL")          ERROR: malformed subscript, subscript 2.
 ^DIC(1,00,"GL")          ERROR: malformed subscript, subscript 2.

---------------------------------------
Jim Self
Systems Architect, Lead Developer
VMTH Computer Services, UC Davis
(http://www.vmth.ucdavis.edu/us/jaself)


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Hardhats-members mailing list
Hardhats-members@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hardhats-members

Reply via email to