home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rox.zip / roxload.cmd < prev    next >
OS/2 REXX Batch file  |  1993-08-31  |  4KB  |  159 lines

  1. /*------------------------------------------------------------------
  2.  * roxload.cmd :
  3.  *------------------------------------------------------------------
  4.  * 08-19-93 originally by Patrick J. Mueller
  5.  *------------------------------------------------------------------*/
  6.  
  7. trace off
  8. parse source . how .
  9.  
  10. if (how = "COMMAND") then
  11.    Usage()
  12.  
  13. if RxFuncQuery("RoxLoadFuncs") then
  14.    do
  15.    rc = RxFuncAdd("RoxLoadFuncs","Rox","RoxLoadFuncs")
  16.    rc = RoxLoadFuncs()
  17.    end
  18.  
  19. if RxFuncQuery("SysLoadFuncs") then
  20.    do
  21.    rc = RxFuncAdd("SysLoadFuncs","RexxUtil","SysLoadFuncs")
  22.    rc = SysLoadFuncs()
  23.    end
  24.  
  25. /*------------------------------------------------------------------
  26.  * get file name, check for existance
  27.  *------------------------------------------------------------------*/
  28. fileName = arg(1)
  29.  
  30. pathName = SysSearchPath("ROXPATH",fileName)
  31. if (pathName <> "") then
  32.    fileName = pathName
  33.  
  34. if ("" = stream(fileName,"C","QUERY EXISTS")) then
  35.    do
  36.    say "File '"fileName"' does not exist."
  37.    return 1
  38.    end
  39.  
  40. /*------------------------------------------------------------------
  41.  * read the file
  42.  *------------------------------------------------------------------*/
  43. line.0 = 0
  44.  
  45. do i = 1 by 1 while (lines(fileName) > 0)
  46.    line = linein(fileName)
  47.  
  48.    line.0 = i
  49.    line.i = line
  50. end
  51.  
  52. o = line.0 + 1
  53. line.0 = o
  54. line.o = ":*"
  55.  
  56. rc = stream(fileName,"C","CLOSE")
  57.  
  58. /*------------------------------------------------------------------
  59.  * start processing
  60.  *------------------------------------------------------------------*/
  61. class      = ""
  62. methodCode = ""
  63. methodName = ""
  64. inMethod   = 0
  65. crlf       = d2c(13) || d2c(10)
  66.  
  67. do lineNo = 1 to line.0
  68.    line = line.lineNo
  69.  
  70.    /*---------------------------------------------------------------
  71.     * keyword found?
  72.     *---------------------------------------------------------------*/
  73.    if (substr(line,1,1) <> ":") then
  74.       do
  75.       if (inMethod) then
  76.          methodCode = methodCode || line || crlf
  77.       end
  78.  
  79.    else
  80.       do
  81.  
  82.       /*------------------------------------------------------------
  83.        * end method, if we're in one
  84.        *------------------------------------------------------------*/
  85.       if (inMethod) then
  86.          do
  87.          inMethod = 0
  88.          rc = RoxClassAddMethod(class,methodName,methodCode)
  89.          methodCode = ""
  90.          methodName = ""
  91.          end
  92.  
  93.       if (substr(line,1,2) = ":*") then
  94.          iterate
  95.  
  96.       /*------------------------------------------------------------
  97.        * handle keyword line
  98.        *------------------------------------------------------------*/
  99.       parse var line ":" key rest
  100.       parse var rest rest1 .
  101.  
  102.       key = translate(key)
  103.       select
  104.          when (key = "CLASS") then
  105.             do
  106.             class = rest1
  107.             rc = RoxAddClass(class)
  108.             end
  109.  
  110.          when (key = "INCLUDE") then
  111.             do
  112.             rc = RoxLoad(rest1)
  113.             end
  114.  
  115.          when (key = "INHERITS") then
  116.             do i = 1 to words(rest)
  117.                var = word(rest,i)
  118.                rc = RoxClassAddInherit(class,var)
  119.             end
  120.  
  121.          when (key = "VARS") then
  122.             do i = 1 to words(rest)
  123.                var = word(rest,i)
  124.                rc = RoxClassAddVar(class,var)
  125.             end
  126.  
  127.          when (key = "METHOD") then
  128.             do
  129.             inMethod   = 1
  130.             methodName = rest1
  131.             methodCode = ""
  132.             end
  133.  
  134.          when (substr(key,1,1) = "*") then
  135.             nop
  136.  
  137.          otherwise
  138.             say "RoxLoad error : error in line '"line"'."
  139.             return 0
  140.             nop
  141.       end
  142.       end
  143.  
  144. end
  145.  
  146. return 0
  147.  
  148. /*------------------------------------------------------------------
  149.  * some simple help
  150.  *------------------------------------------------------------------*/
  151. Usage: procedure
  152.    parse source os . me .
  153.  
  154.    if (os = "OS/2") then
  155.       parse value filespec("name",me) with me "." .
  156.  
  157.    say "RoxLoad is intended to be used as a REXX function."
  158.    exit
  159.