/* test15.rexx */

finalmsg = 'Program aborted!'

call pragma 'D','PG:'
options results
numeric digits 8

if  ~show('P', "PolyMeas.Host")  then do
   say 'Loading PolyGraph.V20.0'
   address COMMAND 'run polygraph.v20.0 -Xl0 -Xr50 -Yl-1.5 -Yr2.5 -PM -WB -t1 -p2048 -z8'
end
do  i=1 to 40
   if  show('P', "PolyMeas.Host")  then leave i
   address COMMAND 'Wait 2'
end i
if  ~show('P', "PolyMeas.Host")  then exit
address 'PolyMeas.Host'

'MeasToBack'
'GraphToBack'
'GiveInfo' 'Please enter DataFile in ARexx-Input Window '
say 'DataFile ?'
parse pull file

'LoadConfig pg:cfg/test.cfg'
if  rc > 0  then exit
'DataFile' file

'Start 0'                 /* pmind set to 1, but not starting */
if  rc ~= 10 then exit

do forever
   signal ON BREAK_C
   'MeasBlock'
   if  rc > 0 then exit
   i = result
   'GiveInfo' 'Index='i
   if  i = 2   then 'ShowData'
   if  i = 24  then
      do
         i = 25
         'GiveInfo' 'Storing Value at Index = 'i
         value = '1.2345E-6'
         'StoreValue' i 1
         'StoreValue' i/10+10 2
         'StoreValue' i/100+1 3
         'StoreValue' value 4
         'SendData' i
         'ShowData'
      end
   else
      if  i = 50 then leave
   end

newfile = 'ram:New.cfg'

'SaveConfig' newfile 'OverWrite'
if  rc > 0  then say 'Could not save config!'
address COMMAND 'delete ram:new.cfg'
finalmsg = 'program finished'

BREAK_C:
'GiveInfo' 'Please check ARexx-Input Window '
'MeasToBack'
'GraphToBack'
say 'Do you want to close PolyGraph (Y|N) ?'
pull answ
if answ = 'Y' then 'StopPoly'
else say finalmsg
exit
