home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / BDSOM1.ZIP / BUILDSOM.CMD next >
OS/2 REXX Batch file  |  1992-10-27  |  24KB  |  853 lines

  1. /**
  2. *** ╔════════════════════════════════════════════════════════════════════╗
  3. *** ║ BuildSOM v1.0                                                      ║
  4. *** ║                                                                    ║
  5. *** ║ This will process a meta language to create SOM objects on the     ║
  6. *** ║ desktop.                                                           ║
  7. *** ║                                                                    ║
  8. *** ║ See the Notes section at the end of this file.                     ║
  9. *** ║                                                                    ║
  10. *** ║ ────────────────────────────────────────────────────────────────── ║
  11. *** ║                                                                    ║
  12. *** ║               Copyright (c) 1992,  Hilbert Computing               ║
  13. *** ║                                                                    ║
  14. *** ║ ────────────────────────────────────────────────────────────────── ║
  15. *** ║                                                                    ║
  16. *** ║  Send any comments to:                                             ║
  17. *** ║                                                                    ║
  18. *** ║       Gary Murphy                                                  ║
  19. *** ║       1022 N. Cooper                                               ║
  20. *** ║       Olathe, KS 66061                                             ║
  21. *** ║                                                                    ║
  22. *** ║       CIS: [73457,365]                                             ║
  23. *** ║       BBS: 913-829-2450                                            ║
  24. *** ║                                                                    ║
  25. *** ╚════════════════════════════════════════════════════════════════════╝
  26. **/
  27.  
  28. arg MetaFile
  29.  
  30. /* Load the external DLLs for this program */
  31.  
  32. call LoadFunctions
  33.  
  34. /* Initalize the global variables */
  35.  
  36. Lex.           = ''     /* Lexical analysis global variables */
  37. Lex.Line       = 0
  38. Lex.StackLoc.0 = 0
  39. Lex.State      = 'Inline'
  40. Lex.Folder     = '<WP_DESKTOP>'
  41. Lex.Location   = '<WP_DESKTOP>'
  42. Opt.           = ''     /* Options */
  43. Obj.           = ''     /* Current object */
  44. Prf.           = ''     /* Profiles */
  45.  
  46.  
  47. CurrentDirectory = directory()
  48.  
  49. call PushLocation
  50.  
  51. /* Open the file and process the statements */
  52.  
  53. TempDir = value("TEMP",,"OS2ENVIRONMENT")
  54. if TempDir = '' then
  55.    call Error 4002
  56.  
  57. Lex.File = Open(TempDir"\BuildSom.Out", 'WRITE')
  58.  
  59. MetaFile = Open(MetaFile)
  60. if MetaFile = '' then
  61.    call Error 1001 MetaFile
  62.  
  63. Statement = linein(MetaFile)
  64. do while(lines(MetaFile) > 0)
  65.    Lex.Line = Lex.Line + 1
  66.    call ParseStatement Statement
  67.    Statement = linein(MetaFile)
  68. end
  69. Lex.Line = Lex.Line + 1
  70. call ParseStatement Statement
  71.  
  72. call Close(MetaFile)
  73.  
  74. call Close(Lex.File)
  75.  
  76. /* Process the intermediate file */
  77.  
  78. Lex.File = Open(Lex.File)
  79. if Lex.File = '' then
  80.    call Error 1001 Lex.File
  81.  
  82. do while(lines(Lex.File) > 0)
  83.    Statement = linein(Lex.File)
  84.    parse var Statement OpCode parm
  85.  
  86.    select
  87.       when OpCode = "C" then Obj.Class    = parm
  88.       when OpCode = "L" then Obj.Location = parm
  89.       when OpCode = "T" then Obj.Title    = parm
  90.       when OpCode = "S" then Obj.Setup    = parm
  91.       when OpCode = "E" then Obj.Exists   = parm
  92.       when OpCode = "." then
  93.          do
  94.          Code = SysCreateObject(Obj.Class,,
  95.                                 Obj.Title,,
  96.                                 Obj.Location,,
  97.                                 Obj.Setup,,
  98.                                 Obj.Exists)
  99.          if Code = 0 then
  100.             call Error 1013
  101.          end
  102.       otherwise
  103.          nop
  104.    end /* select */
  105. end
  106. call Close(Lex.File)
  107.  
  108. Code = directory(CurrentDirectory)
  109. exit
  110.  
  111. /**
  112. *** ┌──────────────────────────────────────────────────────────────────────┐
  113. *** │                      Lexical Analysis Routines                       │
  114. *** └──────────────────────────────────────────────────────────────────────┘
  115. **/
  116.  
  117. ParseStatement: procedure expose Obj. Opt. Prf. Lex.
  118.    /**
  119.    ***  This will parse a single statement in the meta language.
  120.    **/
  121.  
  122.    parse arg Verb Arguments
  123.  
  124.    if Verb = '' then
  125.       return
  126.  
  127.    parse upper var Verb Verb
  128.    select
  129.       when abbrev('BEGIN'      ,Verb,  3) then
  130.          call ParseBeginStatement Arguments
  131.       when abbrev('CREATE'     ,Verb,  3) then
  132.          call ParseCreateStatement Arguments
  133.       when abbrev('DIR'        ,Verb,  3) then
  134.          call ParseSetupStartupDir Arguments
  135.       when abbrev('END'        ,Verb,  3) then
  136.          call ParseEndStatement Arguments
  137.       when abbrev('ENVIRONMENT',Verb,  3) then
  138.          call ParseEnvironment Arguments
  139.       when abbrev('EXENAME'    ,Verb,  3) then
  140.          call ParseSetupExeName Arguments
  141.       when abbrev('ICONFILE'   ,Verb,  3) then
  142.          call ParseSetupIconFile Arguments
  143.       when abbrev('MINIMIZETO' ,Verb,  4) then
  144.          call ParseSetupMinWin Arguments
  145.       when abbrev('MINTO'      ,Verb,  5) then
  146.          call ParseSetupMinWin Arguments
  147.       when abbrev('MINWIN'     ,Verb,  3) then
  148.          call ParseSetupMinWin Arguments
  149.       when abbrev('PARAMETERS' ,Verb,  3) then
  150.          call ParseSetupParameters Arguments
  151.       when abbrev('PARMS'      ,Verb,  3) then
  152.          call ParseSetupParameters Arguments
  153.       when abbrev('PROGTYPE'   ,Verb,  3) then
  154.          call ParseSetupProgType Arguments
  155.       when abbrev('REM'        ,Verb,  3) then
  156.          nop /* Comment */
  157.       when abbrev('SESSIONTYPE',Verb,  4) then
  158.          call ParseSetupProgType Arguments
  159.       when abbrev('SETUP'      ,Verb,  4) then
  160.          call ParseSetupSetup  Arguments
  161.       when abbrev('STARTUPDIR' ,Verb,  7) then
  162.          call ParseSetupStartupDir Arguments
  163.       when abbrev('TYPE'       ,Verb,  4) then
  164.          call ParseSetupProgType Arguments
  165.       when abbrev('WORKINGDIR' ,Verb,  4) then
  166.          call ParseSetupStartupDir Arguments
  167.       when abbrev('#'          ,Verb,  1) then
  168.          nop /* Comment */
  169.       when abbrev('{'          ,Verb,  1) then
  170.          call ParseNestStatement Arguments
  171.       when abbrev('}'          ,Verb,  1) then
  172.          call ParseUnnestStatement Arguments
  173.       otherwise
  174.          call Error 1002 Verb
  175.    end /* select */
  176.    return
  177.  
  178.  
  179. ParseSetupIconFile: procedure expose Obj. Opt. Prf. Lex.
  180.    /**
  181.    ***  This will parse the ICONFILE statement
  182.    **/
  183.  
  184.    arg FileName .
  185.  
  186.    /* Make sure the state is valid */
  187.  
  188.    select
  189.       when Lex.State = "BeginF" then
  190.          nop
  191.       when Lex.State = "BeginP" then
  192.          nop
  193.       otherwise
  194.          call Error 1010
  195.    end /* select */
  196.  
  197.    /*  See if the file exists */
  198.  
  199.    FullName = ScanForFile(FileName, ".I")
  200.    if FullName = '' then
  201.       call Error 1009 FileName
  202.  
  203.    Obj.Setup = Obj.Setup";ICONFILE="FullName
  204.    return
  205.  
  206.  
  207. ParseSetupSetup: procedure expose Obj. Opt. Prf. Lex.
  208.    /**
  209.    ***  This will parse the SETUP statement.  This will pass the parameters
  210.    ***  unchecked to setup string.  This is coded to allow for parameters
  211.    ***  that I haven't coded special routines for yet.
  212.    **/
  213.  
  214.    arg Setup .
  215.  
  216.    /* Make sure the state is valid */
  217.  
  218.    select
  219.       when Lex.State = "BeginF" then
  220.          nop
  221.       when Lex.State = "BeginP" then
  222.          nop
  223.       otherwise
  224.          call Error 1010
  225.    end /* select */
  226.  
  227.    Obj.Setup = Obj.Setup";"Setup
  228.    return
  229.  
  230.  
  231. ParseSetupMinWin: procedure expose Obj. Opt. Prf. Lex.
  232.    /**
  233.    ***  This will parse the MINWIN statement
  234.    **/
  235.  
  236.    arg MinimizeTo .
  237.  
  238.    /* Make sure the state is valid */
  239.  
  240.    select
  241.       when Lex.State = "BeginF" then
  242.          nop
  243.       when Lex.State = "BeginP" then
  244.          nop
  245.       otherwise
  246.          call Error 1010
  247.    end /* select */
  248.  
  249.    select
  250.       when abbrev('DESKTOP',Verb,  1) then Minimize = 'DESKTOP'
  251.       when abbrev('VIEWER', Verb,  1) then Minimize = 'VIEWER'
  252.       when abbrev('HIDE',   Verb,  1) then Minimize = 'HIDE'
  253.       otherwise
  254.          call Error 1012
  255.  
  256.    Obj.Setup = Obj.Setup";MINWIN="MinimizeTo
  257.    return
  258.  
  259.  
  260. ParseSetupExeName: procedure expose Obj. Opt. Prf. Lex.
  261.    /**
  262.    ***  This will parse the EXENAME statement
  263.    **/
  264.  
  265.    arg FileName .
  266.  
  267.    /* Make sure the state is valid */
  268.  
  269.    select
  270.       when Lex.State = "BeginP" then
  271.          nop
  272.       otherwise
  273.          call Error 1010
  274.    end /* select */
  275.  
  276.    /*  See if the file exists */
  277.  
  278.    FullName = ScanForFile(FileName, ".P")
  279.    if FullName = '' then
  280.       call Error 1009 FileName
  281.  
  282.    Obj.Setup = Obj.Setup";EXENAME="FullName
  283.    return
  284.  
  285.  
  286. ParseSetupParameters: procedure expose Obj. Opt. Prf. Lex.
  287.    /**
  288.    ***  This will parse the PARAMETERS statement
  289.    **/
  290.  
  291.    parse arg Parms
  292.  
  293.    Parms = strip(Parms)
  294.  
  295.    /* Make sure the state is valid */
  296.  
  297.    select
  298.       when Lex.State = "BeginP" then
  299.          nop
  300.       otherwise
  301.          call Error 1010
  302.    end /* select */
  303.  
  304.    Obj.Setup = Obj.Setup";PARAMETERS="Parms
  305.    return
  306.  
  307.  
  308. ParseSetupProgType: procedure expose Obj. Opt. Prf. Lex.
  309.    /**
  310.    ***  This will parse the PROGTYPE statement
  311.    **/
  312.  
  313.    arg Type .
  314.  
  315.    /* Make sure the state is valid */
  316.  
  317.    select
  318.       when Lex.State = "BeginP" then
  319.          nop
  320.       otherwise
  321.          call Error 1010
  322.    end /* select */
  323.  
  324.    select
  325.       when abbrev('DOSFULLSCREEN',Type,  4) then ProgType = 'VDM'
  326.       when abbrev('DOSWINDOW'    ,Type,  4) then ProgType = 'WINDOWEDVDM'
  327.       when abbrev('OS2FULLSCREEN',Type,  4) then ProgType = 'FULLSCREEN'
  328.       when abbrev('OS2WINDOW'    ,Type,  4) then ProgType = 'WINDOWABLEVIO'
  329.       when abbrev('WINFULLSCREEN',Type,  4) then ProgType = 'WIN'
  330.       when abbrev('WINWINDOWED'  ,Type,  4) then ProgType = 'WINDOWEDWIN'
  331.       when abbrev('PM'           ,Type,  2) then ProgType = 'PM'
  332.  
  333.       when abbrev('WINDOWABLEVIO',Type,  9) then ProgType = 'WINDOWABLEVIO'
  334.       when abbrev('FULLSCREEN'   ,Type,  3) then ProgType = 'FULLSCREEN'
  335.       when abbrev('WINDOWEDWIN'  ,Type,  9) then ProgType = 'WINDOWEDWIN'
  336.       when abbrev('SEPARATEWIN'  ,Type,  3) then ProgType = 'SEPARATEWIN'
  337.       when abbrev('SEAMLESS'     ,Type,  3) then ProgType = 'SEPARATEWIN'
  338.       when abbrev('WIN'          ,Type,  3) then ProgType = 'WIN'
  339.       when abbrev('WINDOWEDVDM'  ,Type,  9) then ProgType = 'WINDOWEDVDM'
  340.       when abbrev('VDM'          ,Type,  3) then ProgType = 'VDM'
  341.       otherwise
  342.          call Error 1011
  343.    end /* select */
  344.  
  345.    Obj.Setup = Obj.Setup";PROGTYPE="ProgType
  346.    return
  347.  
  348.  
  349. ParseSetupStartupDir: procedure expose Obj. Opt. Prf. Lex.
  350.    /**
  351.    ***  This will parse the STARTUPDIR statement
  352.    **/
  353.  
  354.    arg FileName .
  355.  
  356.    /* Make sure the state is valid */
  357.  
  358.    select
  359.       when Lex.State = "BeginP" then
  360.          nop
  361.       otherwise
  362.          call Error 1010
  363.    end /* select */
  364.  
  365.    /*  See if the file exists */
  366.  
  367.    FullName = ScanForFile(FileName, "\")
  368.    if FullName = '' then
  369.       call Error 1009 FileName
  370.  
  371.    Obj.Setup = Obj.Setup";STARTUPDIR="FullName
  372.    return
  373.  
  374.  
  375. ParseCreateStatement: procedure expose Obj. Opt. Prf. Lex.
  376.    /**
  377.    ***  This will parse the CREATE statement
  378.    **/
  379.  
  380.    parse arg ObjType Arguments
  381.  
  382.    parse upper var ObjType ObjType
  383.    select
  384.       when abbrev('PROGRAM', ObjType,  4) then
  385.          call ParseCreateProgramStatement Arguments
  386.       when abbrev('PGM'    , ObjType,  3) then
  387.          call ParseCreateProgramStatement Arguments
  388.       when abbrev('FOLDER' , ObjType,  3) then
  389.          call ParseCreateFolderStatement Arguments
  390.       otherwise
  391.          call Error 1002 "CREATE" ObjType
  392.    end /* select */
  393.    return
  394.  
  395.  
  396. ParseCreateProgramStatement: procedure expose Obj. Opt. Prf. Lex.
  397.    /**
  398.    ***  This will parse the CREATE PROGRAM statements.
  399.    ***
  400.    ***      CREATE PROGRAM [ "title" [ id ]]
  401.    **/
  402.  
  403.    parse arg '"' ObjTitle '"' ObjectID
  404.  
  405.    if ObjTitle = '' then
  406.       ObjTitle = 'Program'
  407.  
  408.    parse upper var ObjectID ObjectID
  409.    ObjectID = strip(ObjectID)
  410.  
  411.    if ObjectID = '' then
  412.       ObjectID = GenerateID("Program")
  413.  
  414.    Obj.Class    = "WPProgram"
  415.    Obj.Location = Lex.Location
  416.    Obj.Title    = ObjTitle
  417.    Obj.Setup    = "OBJECTID=<"ObjectID">"
  418.  
  419.    Lex.State = "Program"
  420.    return
  421.  
  422.  
  423. ParseCreateFolderStatement: procedure expose Obj. Opt. Prf. Lex.
  424.    /**
  425.    ***  This will parse the CREATE FOLDER statements.
  426.    ***
  427.    ***      CREATE FOLDER [ "title" [ id ]]
  428.    **/
  429.  
  430.    parse arg '"' ObjTitle '"' ObjectID
  431.  
  432.    if ObjTitle = '' then
  433.       ObjTitle = 'Folder'
  434.  
  435.    parse upper var ObjectID ObjectID
  436.    ObjectID = strip(ObjectID)
  437.  
  438.    if ObjectID = '' then
  439.       ObjectID = GenerateID("Folder")
  440.  
  441.    Obj.Class    = "WPFolder"
  442.    Obj.Location = Lex.Location
  443.    Obj.Title    = ObjTitle
  444.    Obj.Setup    = "OBJECTID=<"ObjectID">"
  445.  
  446.    Lex.Folder = "<"ObjectID">"
  447.    Lex.State = "Folder"
  448.    return
  449.  
  450.  
  451. ParseBeginStatement: procedure expose Obj. Opt. Prf. Lex.
  452.    /**
  453.    ***  This will do a syntax and semantic check on the BEGIN statement
  454.    ***
  455.    ***      BEGIN
  456.    **/
  457.  
  458.    parse arg Empty
  459.  
  460.    if Empty <> '' then
  461.       call Error 4001 Empty
  462.  
  463.    /* Semantic check.  Make sure this is in the correct context */
  464.  
  465.    select
  466.       when Lex.State = "Program" then
  467.          Lex.State = "BeginP"
  468.       when Lex.State = "Folder" then
  469.          Lex.State = "BeginF"
  470.       otherwise
  471.          call Error 1003
  472.    end /* select */
  473.  
  474.    return
  475.  
  476.  
  477. ParseEndStatement: procedure expose Obj. Opt. Prf. Lex.
  478.    /**
  479.    ***  This will do a syntax and semantic check on the END statement
  480.    ***
  481.    ***      END
  482.    **/
  483.  
  484.    parse arg Empty
  485.  
  486.    if Empty <> '' then
  487.       call Error 4001 Empty
  488.  
  489.    /* Semantic check.  Make sure this is in the correct context */
  490.  
  491.    select
  492.       when Lex.State = "BeginP" then
  493.          Lex.State = "Program"
  494.       when Lex.State = "BeginF" then
  495.          Lex.State = "Folder"
  496.       otherwise
  497.          call Error 1005
  498.    end /* select */
  499.  
  500.    /* Output the current object info */
  501.  
  502.    call OutputObject
  503.  
  504.    return
  505.  
  506.  
  507. ParseNestStatement: procedure expose Obj. Opt. Prf. Lex.
  508.    /**
  509.    ***  This will do a syntax and semantic check on the '{' statement
  510.    ***
  511.    ***      {
  512.    **/
  513.  
  514.    parse arg Empty
  515.  
  516.    if Empty <> '' then
  517.       call Error 4001 Empty
  518.  
  519.    /* Semantic check.  Make sure this is in the correct context */
  520.  
  521.    select
  522.       when Lex.State = "Folder" then
  523.          Lex.State = "Inline"
  524.       otherwise
  525.          call Error 1006
  526.    end /* select */
  527.  
  528.    /* Save the current folder on the stack */
  529.  
  530.    call PushLocation
  531.    return
  532.  
  533.  
  534. ParseUnnestStatement: procedure expose Obj. Opt. Prf. Lex.
  535.    /**
  536.    ***  This will do a syntax and semantic check on the '}' statement
  537.    ***
  538.    ***      }
  539.    **/
  540.  
  541.    parse arg Empty
  542.  
  543.    if Empty <> '' then
  544.       call Error 4001 Empty
  545.  
  546.    /* Semantic check.  Make sure this is in the correct context */
  547.  
  548.    call PopLocation
  549.    return
  550.  
  551.  
  552. ParseTitle: procedure
  553.    /**
  554.    ***  This will parse a title as an optionally quote-delimited string
  555.    ***  value
  556.    **/
  557.  
  558.    parse arg RawTitle
  559.  
  560.    First = left(RawTitle, 1)
  561.    select
  562.       when First = '"' then
  563.          parse var RawTitle '"' Title '"' Empty
  564.       when First = "'" then
  565.          parse var RawTitle "'" Title "'" Empty
  566.       otherwise
  567.          parse var RawTitle Title Empty
  568.    end /* select */
  569.  
  570.    /* Check for extraneous characters */
  571.  
  572.    if Empty <> '' then
  573.       call Error 4001 Empty
  574.    return Title
  575.  
  576.  
  577. OutputObject: procedure expose Obj. Lex.
  578.    /**
  579.    ***  This will dump the intermediate lexical code to a temp file
  580.    **/
  581.  
  582.    call lineout Lex.File, "C" Obj.Class
  583.    call lineout Lex.File, "L" Obj.Location
  584.    call lineout Lex.File, "T" Obj.Title
  585.    call lineout Lex.File, "S" Obj.Setup
  586.    call lineout Lex.File, "E FailIfExists"
  587.    call lineout Lex.File, "."
  588.    return
  589.  
  590.  
  591. ParseEnvironment: procedure expose Lex.
  592.    /**
  593.    ***  This will parse the ENVIRONMENT verb and set the environment
  594.    ***  variable as appropriate
  595.    **/
  596.  
  597.    parse arg variable value
  598.  
  599.    value = strip(value)
  600.    Ret = value(variable, value,"OS2ENVIRONMENT")
  601.    return
  602.  
  603.  
  604. PushLocation: procedure expose Lex.
  605.    /**
  606.    ***  This will push a new folder location on the stack.  The stem variable
  607.    ***  Lex.Location is always the same as the top of the stack and makes
  608.    ***  refers to the current folder into which things are being placed.
  609.    **/
  610.  
  611.    Lex.StackLoc.0 = Lex.StackLoc.0 + 1
  612.    i = Lex.StackLoc.0
  613.  
  614.    Lex.StackLoc.i = Lex.Folder
  615.    Lex.Location = Lex.Folder
  616.    return
  617.  
  618.  
  619. PopLocation: procedure expose Lex.
  620.    /**
  621.    ***  This will pop the folder from the stack
  622.    **/
  623.  
  624.    if Lex.StackLoc.0 > 1 then
  625.       Lex.StackLoc.0 = Lex.StackLoc.0 - 1
  626.    else
  627.       call Error 1004
  628.  
  629.    i = Lex.StackLoc.0
  630.    Lex.Location = Lex.StackLoc.i
  631.    Lex.Folder   = Lex.StackLoc.i
  632.    return
  633.  
  634.  
  635. GenerateID: procedure
  636.    /**
  637.    ***  This will generate a name for the object if none is specified
  638.    **/
  639.  
  640.    arg ObjectType .
  641.  
  642.    NextID = SysIni('USER', 'BuildSOM', 'NextObjID')
  643.    if NextID = 'ERROR:' then
  644.       NextID = 0
  645.  
  646.    NextID = NextID + 1
  647.    Code = SysIni('USER', 'BuildSOM', 'NextObjID', NextID)
  648.    if Code <> '' then
  649.       call Error 1008
  650.  
  651.    ObjectID = "UWP_"ObjectType || right(NextID, 4, '0')
  652.    return ObjectID
  653.  
  654.  
  655. ScanForFile: procedure
  656.    /**
  657.    ***  This will scan for the filename passed in the places that were
  658.    ***  listed in the second parameter.  The syntax is:
  659.    ***
  660.    ***        FullName = ScanForFile(Name, "[.][D][P][L]")
  661.    ***
  662.    ***   where:
  663.    ***        .   - Check for existence as is
  664.    ***        \   - Check for existence of the directory
  665.    ***        D   - Check for existence in DPATH
  666.    ***        P   - Check for existence in PATH
  667.    ***        I   - Check for existence in ICONS
  668.    ***        L   - Check for existence in LIBPATH (Not Implemented yet)
  669.    ***
  670.    **/
  671.  
  672.    arg FileName, Locs
  673.  
  674.    FullName = FileName
  675.  
  676.    do i = 1 to length(Locs)
  677.       Location = substr(Locs, i, 1)
  678.       select
  679.          when Location = "." then
  680.             do
  681.             if Exists(FileName) then
  682.                FullName = FileName
  683.             else
  684.                FullName = ''
  685.             end
  686.          when Location = "\" then
  687.             do
  688.             Current  = directory()
  689.             FullName = directory(FileName)
  690.             Current  = directory(Current)
  691.             end
  692.          when Location = "P" then
  693.             FullName = SysSearchPath('PATH', FileName)
  694.          when Location = "D" then
  695.             FullName = SysSearchPath('DPATH', FileName)
  696.          when Location = "I" then
  697.             FullName = SysSearchPath('ICONS', FileName)
  698.          otherwise
  699.             nop
  700.       end /* select */
  701.  
  702.       if FullName <> '' then
  703.          return FullName
  704.    end /* do */
  705.  
  706.    return FullName
  707.  
  708.  
  709. /**
  710. *** ┌────────────────────────────────────────────────────────────────────┐
  711. *** │                      Error Handling Routines                       │
  712. *** └────────────────────────────────────────────────────────────────────┘
  713. **/
  714.  
  715. Error: procedure expose Opt. Lex.
  716.    /**
  717.    *** Error handling routine
  718.    **/
  719.  
  720.    parse arg Code Arguments
  721.  
  722.    select
  723.       when Code = 1001 then
  724.          say "Error["Code"]: Can't open" Arguments"."
  725.       when Code = 1002 then
  726.          say "Error["Code"]: Syntax error.  Invalid verb" Arguments "at line" Lex.Line"."
  727.       when Code = 1003 then
  728.          say "Error["Code"]: Unexpected BEGIN at line" Lex.Line"."
  729.       when Code = 1004 then
  730.          say "Error["Code"]: Nesting Error at" Lex.Line"."
  731.       when Code = 1005 then
  732.          say "Error["Code"]: Unexpected END at line" Lex.Line"."
  733.       when Code = 1006 then
  734.          say "Error["Code"]: Unexpected '{' at line" Lex.Line"."
  735.       when Code = 1007 then
  736.          say "Error["Code"]: The object ID is missing at line" Lex.Line"."
  737.       when Code = 1008 then
  738.          say "Error["Code"]: Error querying the INI file. Object IDs may be incorrectly generated"
  739.       when Code = 1009 then
  740.          say "Error["Code"]: Cannot find file '"Arguments"' at line" Lex.Line"."
  741.       when Code = 1010 then
  742.          say "Error["Code"]: Statement valid only between BEGIN/END at line" Lex.Line"."
  743.       when Code = 1011 then
  744.          say "Error["Code"]: Invalid session type at line" Lex.Line"."
  745.       when Code = 1012 then
  746.          say "Error["Code"]: Invalid 'minimize to' value at line" Lex.Line"."
  747.       when Code = 1013 then
  748.          say "Error["Code"]: Create of" Obj.Title "failed."
  749.       when Code = 4001 then
  750.          say "Warning["Code"]: Extra characters after verb found. ("Arguments") at" Lex.Line"."
  751.       when Code = 4002 then
  752.          do
  753.          say "Warning["Code"]: The 'BuildSom.out' file is placed in root.  Set the TEMP"
  754.          say "   environment variable to the directory you want the intermediate file"
  755.          say "   placed in."
  756.          end
  757.       otherwise
  758.          say "Error["Code"]:" Arguments"."
  759.    end /* select */
  760.  
  761.    /* This will get more sophisticated later, but for now terminate on */
  762.    /* errors and pass on warnings.                                     */
  763.  
  764.    if Code < 4000 then
  765.       exit
  766.    return
  767.  
  768.  
  769. /**
  770. *** ┌────────────────────────────────────────────────────────────────────┐
  771. *** │                      General Purpose Routines                      │
  772. *** └────────────────────────────────────────────────────────────────────┘
  773. **/
  774.  
  775.  
  776. Open: procedure
  777.  
  778.    parse arg file rw
  779.  
  780.    file_ = stream(file,c,'QUERY EXIST')
  781.  
  782.    /* If the file is opened for WRITE access, delete it first */
  783.  
  784.    if (file_ \= '') then
  785.       do
  786.       if (rw = 'WRITE') then
  787.          '@erase' file
  788.       file = file_
  789.       end
  790.  
  791.    message = stream(file,c,'OPEN' rw)
  792.    if (message \= 'READY:') then
  793.       do
  794.       say 'Error: Open failure on' file'.' message
  795.       exit
  796.       end
  797.    return file
  798.  
  799.  
  800. Close: procedure
  801.  
  802.    parse arg file
  803.    message = stream(file,c,'CLOSE')
  804.    if (message \= 'READY:') & (message \= '') then
  805.       do
  806.       say 'Error: Close failure on' file'.' message
  807.       exit
  808.       end
  809.    return file
  810.  
  811.  
  812. Exists: procedure
  813.  
  814.    parse arg file
  815.  
  816.    file = stream(file,c,'QUERY EXIST')
  817.    if (file = '') then
  818.       return 0
  819.    else
  820.       return 1
  821.  
  822. LoadFunctions: procedure
  823.    /**
  824.    ***   This will load the DLL for the Rexx system functions supplied
  825.    ***   with OS/2 v2.0
  826.    **/
  827.    call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  828.    call SysLoadFuncs
  829.    return
  830.  
  831. /**
  832. *** ╔══════════════════════════════════════════════════════════════════════╗
  833. *** ║ There are a couple of anomolies in this program that will be         ║
  834. *** ║ handled in future releases.  In the meantime, here are some          ║
  835. *** ║ circumventions.                                                      ║
  836. *** ║                                                                      ║
  837. *** ║    o  If you specify "*" for a program name (to invoke either the    ║
  838. *** ║       OS/2, DOS or Windows shell), you MUST also specify a           ║
  839. *** ║       SESSIONTYPE for that object well.                              ║
  840. *** ║    o  The BEGIN/END pairs are required after a CREATE PROGRAM or     ║
  841. *** ║       CREATE FOLDER statement.  There is no problem having nothing   ║
  842. *** ║       between the BEGIN and the END statements.  I will make the     ║
  843. *** ║       parser smarter in the next release.                            ║
  844. *** ║                                                                      ║
  845. *** ║ ──────────────────────────────────────────────────────────────────── ║
  846. *** ║                                                                      ║
  847. *** ║ Change Log                                                           ║
  848. *** ║                                                                      ║
  849. *** ║    10/23/1992   v1.0   Base code                                     ║
  850. *** ║                                                                      ║
  851. *** ╚══════════════════════════════════════════════════════════════════════╝
  852. **/
  853.