home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / ASSOCT.ZIP / ASSOCT.CMD
OS/2 REXX Batch file  |  1993-01-04  |  4KB  |  126 lines

  1. /*****************************************************************************
  2.  *                                         *
  3.  *               Define/delete an association type             *
  4.  *                                         *
  5.  *****************************************************************************/
  6. '@echo off'
  7.  
  8.     say ' '
  9.     parse arg AssocType
  10.     AT = translate(AssocType)
  11.     PMAssocApp = 'PMWP_ASSOC_TYPE'
  12.  
  13.     /* Register the REXXUTIL functions */
  14.     Call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SYSLOADFUNCS'
  15.     rc=SysLoadFuncs()
  16.  
  17.     k = pos('/L',AT) ; if k<>0 then signal ListAssoc
  18.     k = pos('/D',AT) ; if k<>0 then signal DeleteAssoc
  19.     signal DefineAssoc
  20.  
  21. /*****************************************************************************/
  22.  
  23. ListAssoc:                    /* List all defined types         */
  24.     say 'Listing all association types'
  25.     say ' '
  26.  
  27.     /* Get the list */
  28.     Call SysIni 'USER', PMAssocApp, 'ALL:', 'Assoc'
  29.     If Assoc.0<2 then return
  30.  
  31.     /* See if we have anything */
  32.     If Assoc.0=0 then do
  33.       say 'No association types currently defined'
  34.       say ' '
  35.       exit
  36.       end
  37.     say Assoc.0 'association types defined'
  38.     say ' '
  39.  
  40.     /* Sort the list */
  41.     do i = 1 to Assoc.0-1
  42.       do j=i+1 to Assoc.0
  43.     if Assoc.i > Assoc.j then do
  44.       Temp = Assoc.i ; Assoc.i = Assoc.j ; Assoc.j = Temp
  45.       end
  46.     end
  47.       end
  48.  
  49.     /* Print the list out */
  50.     say 'Currently defined types:'
  51.     k = trunc(Assoc.0 / 2)
  52.     kd = k ; if k*2<>Assoc.0 then kd = kd + 1
  53.     do i=1 to k
  54.       k1 = i + kd
  55.       say left(Assoc.i,39) Assoc.k1
  56.       End
  57.     k1 = Assoc.0
  58.     if k*2 <> k1 then say Assoc.kd
  59.  
  60.     say ' '
  61.     exit
  62.  
  63. /*****************************************************************************/
  64.  
  65. DefineAssoc:                    /* Define an association type    */
  66.     AssocType = strip(AssocType)
  67.     say 'Defining association type:' AssocType
  68.     say ' '
  69.  
  70.     rc=SysIni('USER', PMAssocApp, AssocType, ' ')
  71.  
  72.     Msg = 'Type "'AssocType'" defined'
  73.     if left(rc,6)='ERROR:' then Msg = 'Error return from define'
  74.     say Msg
  75.  
  76.     say ' '
  77.     exit
  78.  
  79. /*****************************************************************************/
  80.  
  81. DeleteAssoc:                    /* Delete an association type    */
  82.     if k=1 then AssocType = substr(AssocType,3)
  83.        else AssocType = substr(AssocType,1,k-1)
  84.     AssocType = strip(AssocType)
  85.     say 'Deleting association type:' AssocType
  86.     say ' '
  87.  
  88.     rc=SysIni('USER', PMAssocApp, AssocType,'DELETE:')
  89.     Msg = 'Type "'AssocType'" deleted'
  90.     If LEFT(rc,6)='ERROR:' Then Msg = 'Error during delete or not defined'
  91.     say Msg
  92.  
  93.     say ' '
  94.     exit
  95.  
  96. /*****************************************************************************/
  97.  
  98. /*
  99.  
  100.                    ASSOCTYPE
  101.          An OS/2 Association Type Maintenance Routine
  102.  
  103. ASSOCTYP.CMD is a REXX command that allows you to create your own
  104. association types.  For instance, I have created a special type for
  105. my favorite word processor and my financial planning application.  By
  106. doing this, I can ensure that the program that will process these files
  107. will start when I select the files regardless of the name that I may assign
  108. to the files.  This extends the set of associtions shipped with OS/2 and
  109. allows you to customize to your liking.
  110.  
  111. The syntax of the command is simple -- there are three supported functions:
  112.  
  113.   Create an association type:       ASSOCTYPE type name text
  114.   Delete an association type:       ASSOCTYPE type name text /D
  115.   List current association types:  ASSOCTYPE /L
  116.  
  117.  (Note: The /D and /L above can be upper or lower case and the /D can come
  118.     either first or last in the string.)
  119.  
  120. This CMD uses the SYSINI function of the REXXUTIL package which is shipped
  121. with OS/2 so no special other software is required.
  122.  
  123. First uploaded: 1/2/93
  124.  
  125. */
  126.