home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / 123rexx.zip / REXXDIAG.CMD < prev    next >
OS/2 REXX Batch file  |  1991-10-21  |  3KB  |  45 lines

  1. /*****************************************************************************/
  2. /* Lotus 1-2-3 For OS/2 sample macro command.                                */
  3. /*                                                                           */
  4. /* {REXXR "REXXDIAG",range}                                                  */
  5. /*                                                                           */
  6. /* Moves the values of the cells on the left top - right bottom diagonal of  */
  7. /* a range to the other diagonal, across the horizontal axis.  The range is  */
  8. /* defined by its left top corner only.  The diagonal is traversed until an  */
  9. /* empty, ERR or N/A cell is reached.                                        */
  10. /*                                                                           */
  11. /* {REXXR "REXXDIAG logFileName",range}                                      */
  12. /*                                                                           */
  13. /* Writes any TRACE or SAY output to a log file named 'logFileName'.         */
  14. /*                                                                           */
  15. /* Copyright (c) 1991 Lotus Development Corporation.  This code is supplied  */
  16. /* on an 'as is' basis as an example only.  This code has only received      */
  17. /* informal testing by Lotus.  Permission is granted  to copy and modify     */
  18. /* this code to your heart's content.  No warrenties expressed or implied.   */
  19. /* Remember, your mileage may vary.  Let us know if you find support of REXX */
  20. /* by 1-2-3 useful.                                                          */
  21. /*****************************************************************************/
  22.  
  23. ARG theRange
  24. IF theRange <> "RANGE1" THEN DO                   /* this should ever happen */
  25.    CALL Display123Error "First argument to REXXADD.CMD is not a range."
  26.    RETURN
  27.    END
  28. sheet = 1
  29. col = 0; row = 0
  30. DO i = 1 BY 1 UNTIL value.i = ""    /* walk the diagonal up to an empty cell */
  31.    col = col + 1; row = row + 1
  32.    value.i = Get123Cell(theRange, sheet, col, row)
  33.    SAY value.i
  34.    CALL Set123Cell theRange, sheet, col, row, "EMPTY", 0  /* set it to empty */
  35.    END
  36. num = i - 1                               /* number of cells in the diagonal */
  37. col = 0
  38. DO i = 1 TO num      /* walk the other diagonal, writing out the cell values */
  39.    col = col + 1; row = row - 1
  40.    IF Datatype(value.i) = "NUM" THEN type = "NUMBER"
  41.    ELSE type = "STRING"
  42.    CALL Set123Cell theRange, sheet, col, row, type, value.i
  43.    END
  44. RETURN
  45.