home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxlepsom.zip / tst.cmd < prev    next >
OS/2 REXX Batch file  |  1995-09-18  |  2KB  |  83 lines

  1. /* rexx */
  2. /* This test macro receives the following arguments:
  3.     {tst "string";inrange;outrange;number}
  4.     This macro loops thru the inrange cells and performs
  5.     an addition of the given number with the value in the 
  6.     cell from the inrange and puts the concatenation of the result
  7.     and the given string to the corresponding cell from the outrange.
  8.     
  9. */
  10.  
  11.  
  12. tst.log='tst.log'
  13. signal on syntax name ErrExit
  14.  
  15. call RxFuncAdd 'LepSomLoadFuncs', 'rxlepsom', 'LepSomLoadFuncs'
  16. call LepSomLoadFuncs
  17.  
  18. parse arg args
  19. n=words(args)
  20. call lineout tst.log,'Arguments are ='args
  21. do i=1 to n 
  22.     argv.i=word(args,i)
  23. end 
  24.  
  25. lepAA=LepAAnew(argv.1)
  26. if LepGetClassName(lepAA)\='LEPArgumentsArray' then do
  27.     cr=x2c('0D');
  28.     msg='Internal error in 123REXX.DLL RexxAddMacro function.'
  29.     msg=msg||cr||'Please contact us to inform about the conditions of this error.'
  30.     rcod=LepDisplayError(msg);
  31. end
  32.  
  33. argNum=LepAAGetByNo(lepAA)
  34. lepArg.0=argNum
  35. do i=1 to argNum
  36.     lepArg.i=LepAAGetByNo(lepAA, i-1) /* Lep arguments are 
  37.                     enumerated starting from 0 */
  38.     call lineout tst.log, 'lepArg.'i' is a 'LepGetClassName(lepArg.i)
  39. end
  40.  
  41. /******************************************************************************/
  42. /*                Insert your code here                                       */
  43. /******************************************************************************/
  44. if argNum<4 then do
  45.     LepDisplayError("This macro should receive 4 arguments")
  46.     return 1
  47. end
  48.  
  49. in.sheet=LepGetRangeSheets(lepArg.2)
  50. in.col=LepGetRangeCols(lepArg.2)
  51. in.row=LepGetRangeRows(lepArg.2)
  52. number=LepGetObjValue(lepArg.4)
  53. instr=LepGetObjValue(lepArg.1)
  54.  
  55. call lineout tst.log, "Number="number
  56.  
  57. if datatype(number, 'N')\=1 then do
  58.     rcod=LepDisplayError("The last argument should be number");
  59.     return 1
  60. end
  61.  
  62. do s=1 to in.sheet
  63.  do c=1 to in.col
  64.   do r=1 to in.row
  65.     val=LepGetCell(lepArg.2, s,c,r)
  66.     if datatype(val,'N')\=1 then val=0
  67.     val=val+number
  68.     rcod=LepSetCellString(lepArg.3, s,c,r, val || instr)
  69.   end
  70.  end
  71. end
  72.  
  73. /* .... */
  74.  
  75. return
  76.  
  77. ErrExit:
  78.  msg='Error '||rc||' occured at line '||sigl||': '||errortext(rc)
  79.  call lineout tst.log, msg
  80.  rcod=LepDisplayError(msg)
  81. return
  82.  
  83.