teststem2.nrx 29.11.2002 16:04:12
/* Teststem2: test stems, the main program has been generated by Rexx2Nrx, */
/* but the method testnrx has been manually added to see what happens */
/* in the Java/NetRexx environment (especially testing the 'exists' method */
/* of NetRexx (which is totally different to Java exists() for files) !! */
/***************************************************************************/
import Rexx2Nrx.Rexx2RT.RexxMsg
class teststem2 uses RexxMsg
properties public static
/* ... Declare Global Stems / Arrays */
abc = Rexx 'abc undefined' /*Stem!*/
method main(args=String[]) static
arg=Rexx(args) -- program arguments as single string
arg=arg -- avoid NetRexx warning
abc = 'abc undefined'
RexxMsg.log('teststem2') /* force LOG to teststem2.log*/
RexxMsg.pause('ON') /* force pause after full screen */
RexxMsg.info2('Testing NetRexx Stem member occupation')
RexxMsg.info('abc is our stem, and all values except abc.7.8.9')
RexxMsg.info('should have the the index as a value, except the last')
RexxMsg.info('which is undefined!')
abc[1,2] = '1.2'
abc[2,3] = '2.3'
abc[4] = '4'
abc[5] = '5'
abc[5,6,7] = '5.6.7'
RexxMsg.info("abc.1.2='1.2' :="||abc[1,2])
RexxMsg.info("abc.2.3='2.3' :="||abc[2,3])
RexxMsg.info("abc.4='4' :="||abc[4])
RexxMsg.info("sbc.5=' :="||abc[5])
RexxMsg.info("abc.5.6.7='5.6.7' :="||abc[5,6,7])
RexxMsg.info("abc.7.8.9 :="||abc[7,8,9])
info('we are now trying to access abc (by reference) in a subroutine')
nrxtest(abc)
closelog() /* flush & close the log file! */
exit
method nrxtest(xyz=Rexx) static /* simply toi try the NetRexx exists() function*/
known_values=''
loop ii=1 to 10
if xyz.exists(ii) then do
info('xyz.'ii 'exists!')
known_values=known_values' 'xyz[ii]
end
else do
info('xyz.'ii 'does NOT exist!')
end
info(' now, more complicated, the second level')
xyz2=xyz[ii]
info(' ii=' ii 'xyz2=' xyz2)
/* note that exists can only be called with ONE index */
loop jj=1 to 10
if xyz2.exists(jj) then do
info(' xyz.'ii'.'jj 'exists=' xyz2.exists(jj) 'value is:' xyz[ii,jj])
known_values=known_values' 'xyz[ii,jj]
end /* if */
loop kk=1 to 10
xyz3=xyz2[jj]
if xyz3.exists(kk) then do
info(' xyz.'ii'.'jj'.'kk' exists,')
info(' value is:' xyz[ii,jj,kk] 'which should be equal to:' xyz3[kk])
known_values=known_values xyz[ii,jj,kk]
end
end
end
end
known_values=known_values.strip
info2('at end of nrxtest, known values are:')
info(known_values)
return