5

I am interfacing with a fis-gtm based mumps system and I needed some test data on my local Linux installaion (fis-gtm V6.2 on CENTOS 7).

So I read the manuals and came up with:--

set nword(1)="one"
set nword(2)="two"
set nword(3)="three"
set nword(4)="four"
set nword(5)="five"
set nword(6)="six"
set nword(7)="seven"
set nword(8)="eight"
set nword(9)="nine"
set nword(10)="ten"
set rn=^runcount+1
FOR i=1:1:10  DO    
. FOR j=1:1:10  DO    
.. set val="run:"_nword(rn)_" transaction:"_nword(i)_" update:"_nword(j)
.. w val,!

Which seems simple enough -- but I cannot get it to accept the inner DO loop.

Whatever I try I get:-

GTM>. FOR j=1:1:10  DO
%GTM-E-CMD, Command expected but not found
    . FOR j=1:1:10  DO
    ^-----

I basically wasted a whole morning on this before giving up and downloading the perl bindings.

Is it at all possible to combine a nested DO with a simple FOR? If so what was I doing wrong?

Bizarre -- the "." type nesting option works if you define a routine and compile but not for direct execution!

Solved eventually.

James Anderson
  • 27,109
  • 7
  • 50
  • 78

2 Answers2

7

There should not be two spaces after your FOR iteration arguments, only one.

FOR i=1:1:10 DO
. FOR...
TIMOOOO
  • 116
  • 5
  • 5
    Actually tried that already -- problems was that I was running interactively. The interpreter only recognizes the DO followed by "."on the next line sometimes. Works fine when I "ZLINK" then execute. Go figure. – James Anderson Feb 06 '15 at 00:41
0

I know nothing about Mumps but here is a snippet I found online. Maybe it will help.

NESTLOOP
     ;.../loops/nested
     ;set up the 2D array with random values
     NEW A,I,J,K,FLAG,TRIGGER
     SET K=15 ;Magic - just to give us a size to work with
     SET TRIGGER=20 ;Magic - the max value, and the end value
     FOR I=1:1:K FOR J=1:1:K SET A(I,J)=$RANDOM(TRIGGER)+1
     ;Now, search through the array, halting when the value of TRIGGER is found
     SET FLAG=0
     SET (I,J)=0
     FOR I=1:1:K Q:FLAG  W ! FOR J=1:1:K WRITE A(I,J),$SELECT(J'=K:", ",1:"") SET FLAG=(A(I,J)=TRIGGER) Q:FLAG
     KILL A,I,J,K,FLAG,TRIGGER
     QUIT
Reenactor Rob
  • 1,508
  • 1
  • 11
  • 20
  • All very well putting everything on one line but I will need to add some TSTART and TCOMMIT in there plus some other stuff that will not fit on a single line. – James Anderson Feb 05 '15 at 03:42