home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxhll.zip / WPS.REX < prev   
OS/2 REXX Batch file  |  1993-08-20  |  3KB  |  120 lines

  1. /* #include <wps.rex> */
  2.  
  3. /**
  4. ***  ┌───────────────────────────────────────────────────────────────────────┐
  5. ***  │                 This code will manipulate WPS objects                 │
  6. ***  └───────────────────────────────────────────────────────────────────────┘
  7. **/
  8.  
  9. InitObjectProcedures: procedure expose Obj.
  10.    /**
  11.    ***  This will initialize the global 'Obj.' variable
  12.    **/
  13.  
  14.    Obj. = ''
  15.    Obj.Location = "<WP_DESKTOP>"
  16.    return 0
  17.  
  18.  
  19. RunObject: procedure
  20.  
  21.    /* This will open (run) a Workplace Shell object */
  22.  
  23.    arg Object
  24.  
  25.    call SysSetObjectData '<'Object'>', 'OPEN=DEFAULT';
  26.    return result
  27.  
  28.  
  29. CreateProgramObject: procedure expose Obj.
  30.    /**
  31.    ***  This will create a program in 'Obj.Location'.
  32.    **/
  33.  
  34.    parse arg Title, Icon, Pgm, Parameter, WorkDir, SetupParms, ObjectId
  35.  
  36.    if Title = '' then
  37.       Title = 'Program'
  38.  
  39.    Setup = ''
  40.    if Icon <> '' then
  41.       Setup = Setup';ICONFILE='Icon
  42.  
  43.    if Pgm = '' then
  44.       Setup = Setup';EXENAME=*'
  45.    else
  46.       Setup = Setup';EXENAME='Pgm
  47.  
  48.    if Parameter <> '' then
  49.       Setup = Setup';PARAMETERS='Parameter
  50.  
  51.    if WorkDir <> '' then
  52.       Setup = Setup';STARTUPDIR='WorkDir
  53.  
  54.    if SetupParms <> '' then
  55.       Setup = Setup';'SetupParms
  56.  
  57.    if ObjectId = '' then
  58.       do
  59.  
  60.       /* Generate an object ID */
  61.  
  62.       ObjectId = "UWP_PROGRAM"right(Obj.Id, 4, '0')
  63.       Obj.Id = Obj.Id + 1
  64.       end
  65.    else
  66.       do
  67.       ObjectId = strip(ObjectId, 'Trailing','>')
  68.       ObjectId = strip(ObjectId, 'Leading' ,'<')
  69.       end
  70.    Setup = Setup';OBJECTID=<'ObjectId'>'
  71.  
  72.    Setup = strip(Setup, 'Leading', ';')
  73.  
  74.    Code = SysCreateObject("WPProgram",Title,Obj.Location,Setup,"FailIfExists")
  75.    return Code
  76.  
  77.  
  78. CreateFolderObject: procedure expose Obj.
  79.    /**
  80.    ***  This will create a folder in 'Obj.Location' and will change the
  81.    ***  current object's location to this folder.
  82.    **/
  83.  
  84.    parse arg Title, Icon, SetupParms, ObjectId
  85.  
  86.    /* Convert the parameters into a format compatible with SysCreateObject */
  87.  
  88.    if Title = '' then
  89.       Title = 'Folder'
  90.  
  91.    Setup = ''
  92.    if Icon <> '' then
  93.       Setup = Setup';ICONFILE='Icon
  94.  
  95.    if SetupParms <> '' then
  96.       Setup = Setup';'SetupParms
  97.  
  98.    if ObjectId = '' then
  99.       do
  100.  
  101.       /* Generate an object ID */
  102.  
  103.       ObjectId = "UWP_FOLDER"right(Obj.Id, 4, '0')
  104.       Obj.Id = Obj.Id + 1
  105.       end
  106.    else
  107.       do
  108.       ObjectId = strip(ObjectId, 'Trailing','>')
  109.       ObjectId = strip(ObjectId, 'Leading' ,'<')
  110.       end
  111.    Setup = Setup';OBJECTID=<'ObjectId'>'
  112.    Setup = strip(Setup, 'Leading', ';')
  113.  
  114.    Code = SysCreateObject("WPFolder",Title,Obj.Location,Setup,"FailIfExists")
  115.    if Code = 0 then
  116.       say "Error: Create of '"Title"' failed."
  117.  
  118.    Obj.Location = '<'ObjectId'>'
  119.    return Code
  120.