home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / samples / rexx / wps / wpsorxcl.cmd next >
OS/2 REXX Batch file  |  1999-05-11  |  4KB  |  90 lines

  1. /******************************************************************************/
  2. /*  WPSORXCl                 Object REXX Samples                              */
  3. /*                                                                            */
  4. /*  A workplace shell example.                                                */
  5. /*                                                                            */
  6. /*  This program demonstrates how to use the OS/2 workplace shell folders to  */
  7. /*  represent the OORexx classes. This is presented in a tree view where an   */
  8. /*  OORexx class is a folder and subclasses are subfolders. The top folder    */
  9. /*  title is updated as classes are added for a progress indicator.           */
  10. /*  Methods in a class can be represented as abstract WPS objects; but the    */
  11. /*  default is not to create them; since it is quite time consuming.          */
  12. /******************************************************************************/
  13. trace o
  14. wantMethods=0                               /* 0= do not create method object */
  15.                                             /* 1= create method abstract objs */
  16. wpAbstract = .wps~import('WPAbstract')
  17. if importerror('WPAbstract',wpAbstract) then exit 8
  18.  
  19. call wpconst
  20. xcl= .wpfolder~new('OORexx .Object Class','',.wpdesktop,1)
  21. xcl~wpsetup('NODELETE=NO')
  22. xcl~wpSetDefaultView(.wpconst[OPEN_TREE])
  23. status = xcl 
  24. xcl~wpopen(0,0,0)
  25. call classfolders .object,xcl
  26. xcl~wpSetTitle('OORexx .Object Class')
  27. return 0
  28.  
  29.  
  30. /******************************************************************************/
  31. /* This routine will just check the object by using the string method on      */
  32. /* itself. If the value returned is of the form: 'The xxxxxx class'; then the */
  33. /* import is assumed ok. A 0 is returned if the import was ok; non-zero       */
  34. /* otherwise.                                                                 */
  35. /******************************************************************************/
  36. importerror: procedure 
  37. trace o
  38. use arg classname, testobject
  39. x = testobject~string
  40. validstring = 'The 'classname' class'
  41. if (x = validstring) then return 0
  42. say '**** Error in importing class: 'classname
  43. return 8
  44.  
  45.  
  46. /******************************************************************************/
  47. /* This routine will get all the OORExx subclasses of the class passed in; and*/
  48. /* either build an folder if there are no subclasses of it, or a folder with  */
  49. /* subfolders (using a recursive call). If wantMethods=1; then an abstract    */
  50. /* object will be created in each folder for every class method.              */
  51. /******************************************************************************/
  52. classfolders: procedure expose wpAbstract status wantmethods
  53. use arg inClass, pfolder
  54. do class over inClass~subclasses
  55.    status~wpSetTitle('Adding class 'class)
  56.    if ((class~subclasses~size)=0) then
  57.    do
  58.      /* this class has no subclasses; add it */
  59.      y = .wpfolder~new(class~string,'',pfolder,1)
  60.      if wantMethods=1 then
  61.      DO
  62.        allmethods = class~methods
  63.        do while allmethods~available
  64.          status~wpSetTitle('Adding class method 'allmethods~index' for 'class)
  65.          x = wpAbstract~new(allmethods~index,'',y,1)
  66.          x~wpsetup('NODELETE=NO')
  67.          allmethods~next
  68.        end /* do */
  69.      end/* if wantMethods=1 */
  70.    end
  71.    else
  72.    DO 
  73.      /* this class has subclasses */
  74.      y = .wpfolder~new(class~string,'',pfolder,1) 
  75.      y~wpSetDefaultView(.wpconst[OPEN_TREE])
  76.      call classfolders class,y
  77.      allmethods = class~methods
  78.      if wantMethods=1 then
  79.      DO
  80.        do while allmethods~available
  81.          status~wpSetTitle('Adding class method 'allmethods~index' for 'class)
  82.          x = wpAbstract~new(allmethods~index,'',y,1)
  83.          x~wpsetup('NODELETE=NO')
  84.          allmethods~next
  85.        end /* do */
  86.      end/* if wantMethods=1 */
  87.    end /* do */
  88. end /* do */
  89. return 0
  90.