Indirection (@) issues: Difference between revisions
From VistApedia
Jump to navigationJump to search
No edit summary |
No edit summary |
||
| (3 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
Back to [[Programming VistA Issues]] | |||
Jim Self | Jim Self | ||
>Kevin wrote: | >Kevin wrote: | ||
>I posted about this once before, and it seems that someone had an | >I posted about this once before, and it seems that someone had an | ||
>answer. But I can't find that post now. | >answer. But I can't find that post now. | ||
That was me. It was in response to Nancy's question about indirection. | |||
>I am trying to use indirection (@) to execute a callback function. | |||
>But it looks like the indirection is limited to 8 characters. | |||
The form of indirection you are trying is not standard nor is it supported by GT.M. | |||
> | |||
>e.g. | |||
> | |||
>GTM>w $$SIMPLE^TMGTEST("hello") | |||
>You said:hello | |||
>GTM>set x="SIMPLE^TMGTEST" | |||
> | |||
>GTM>w $$@x@("hello") | |||
>%GTM-E-LABELMISSING, Label referenced but not defined: SIMPLE^T | |||
> | |||
>GTM> | |||
> | |||
> | |||
>How should I do this? | |||
Try putting the "$$" inside the quotes. | |||
I don't think this is standard either (or documented in GT.M for that matter), but this | |||
works for me. | |||
s test="$$ucase^%zString" | |||
w @test@("hello kevin") | |||
HELLO KEVIN | |||
Jim Self | |||
> | Gregory wrote: | ||
> | >the syntax you were trying to use is subscript indirection. It | ||
> | >is used to access arrays when the array name and subscript (or | ||
> | >subscripts) are stored in variables. Though there is a surface | ||
>similarity between this syntax and that used to invoke an extrinsic | |||
>function, function calls and array references are very different | |||
>things in MUMPS. | |||
> | |||
> | |||
Right. That is why I was suprised to find that it works at all in GT.M. | |||
Did you try it in Cache' or MUMPS_V1 or MSM? | |||
hmmm. I just tried another test with disappointing (but not unexpected) results. | |||
s func="$$ucase^%zString" | |||
s Y=@func@("hello kevin") | |||
w Y | |||
That gives an error - variable expected in this context. | |||
However, the following does work. | |||
s | s func="$$ucase^%zString" | ||
s @("Y="_func)@("hello kevin") | |||
w Y | |||
The key in the examples I have tried seems to be that (in GT.M at least) if you start out | |||
with a standard form of indirection, such as argument indirection, then you can use the | |||
second @ to append subscripts or arguments to functions or subroutines. | |||
Latest revision as of 16:37, 18 September 2005
Back to Programming VistA Issues
Jim Self
>Kevin wrote:
>I posted about this once before, and it seems that someone had an
>answer. But I can't find that post now.
That was me. It was in response to Nancy's question about indirection.
>I am trying to use indirection (@) to execute a callback function.
>But it looks like the indirection is limited to 8 characters.
The form of indirection you are trying is not standard nor is it supported by GT.M.
>
>e.g.
>
>GTM>w $$SIMPLE^TMGTEST("hello")
>You said:hello
>GTM>set x="SIMPLE^TMGTEST"
>
>GTM>w $$@x@("hello")
>%GTM-E-LABELMISSING, Label referenced but not defined: SIMPLE^T
>
>GTM>
>
>
>How should I do this?
Try putting the "$$" inside the quotes.
I don't think this is standard either (or documented in GT.M for that matter), but this works for me.
s test="$$ucase^%zString"
w @test@("hello kevin")
HELLO KEVIN
Jim Self Gregory wrote: >the syntax you were trying to use is subscript indirection. It >is used to access arrays when the array name and subscript (or >subscripts) are stored in variables. Though there is a surface >similarity between this syntax and that used to invoke an extrinsic >function, function calls and array references are very different >things in MUMPS.
Right. That is why I was suprised to find that it works at all in GT.M. Did you try it in Cache' or MUMPS_V1 or MSM?
hmmm. I just tried another test with disappointing (but not unexpected) results.
s func="$$ucase^%zString"
s Y=@func@("hello kevin")
w Y
That gives an error - variable expected in this context. However, the following does work.
s func="$$ucase^%zString"
s @("Y="_func)@("hello kevin")
w Y
The key in the examples I have tried seems to be that (in GT.M at least) if you start out with a standard form of indirection, such as argument indirection, then you can use the second @ to append subscripts or arguments to functions or subroutines.