home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / changecd.zip / ChangeCD.CMD next >
OS/2 REXX Batch file  |  1994-01-25  |  8KB  |  244 lines

  1. /*  REXX program to allow sysops to rotate CD-ROMS on their MAXIMUS BBS  */
  2. /*  Requires: VREXX (available on most OS/2 BBSs)      
  3.                    A CD-ROM in designated drives 
  4.                          - (doesn't have to be the correct one)
  5.              
  6.  
  7.     I wrote this program to make it easier for me to rotate my cd-roms on
  8.     my BBS, as I have more cd-roms than drives. Since I figured other sysops
  9.     were facing the same problem, I have made some changes to allow you 
  10.     to configure it for your settup. Some things are mandatory though. 
  11.     This program assumes that there is a "filearea.ctl" for each cd-rom
  12.     called driveX.ctl, where X is the drive the cd-rom will be in. (eg. driveD.ctl)
  13.     I set it up this way because I wanted the ability to put any cd-rom in any
  14.     drive without going and changing the DOWNLOAD drive designations in all 
  15.     the .CTL files. If you don't want to do it this way, feel free to change the 
  16.     program to suit your needs, although I should warn you that this was my 
  17.     first attempt at writing a REXX program and you may not be able to follow
  18.     the wierd things I have done. Don't let my previous sentence scare you from
  19.     using this program though. I did extensive testing and it works great, on
  20.     MY system. In other words, you USE THIS PROGRAM AT YOUR OWN RISK! I AM 
  21.            NOT RESPONSIBLE FOR ANY PROBLEMS AND/OR DAMAGE TO YOUR SYSTEM!
  22. */
  23. /* -----------------------------------------------------------------------*/
  24.  
  25. /*---------------------CONFIGURATION AREA-------------------------------*/
  26.  
  27. /*  Your MAXIMUS path, directory and filearea.ctl  */
  28. areafile = 'C:\MAX\FILEAREA.CTL'             
  29.  
  30. /*   Your MAXIMUS path, directory and filearea.ctl FOR YOUR HARD DRIVE AREAS */
  31. hdd = 'C:\MAX\FILEAREA.HDD'
  32.  
  33. /*------------DESIGNATE NAME OF CD-ROM AND ENTIRE PATH OF -----------------
  34.    ------------THE CD-ROM AREA CONTROL FILE----------------------------------*/
  35.  
  36. cd_rom.0 = 7                                   /*  Enter the total number of CD-ROMS here  */
  37. cd_rom.1 = "Swine Review 93"
  38. cd_rom.1.path = 'C:\MAX\SW93\'            /* TRAILING BACKSLASH MUST BE INCLUDED */
  39. cd_rom.2 = "Secrets of the Universe"
  40. cd_rom.2.path = 'C:\MAX\CRAP\'            /* These paths are NOT checked, so if a */
  41. cd_rom.3 = "10001 Recipes for Snake"    /* certain cd-rom does not show up in */
  42. cd_rom.3.path = 'C:\MAX\SNAKE\'           /* the final 'filearea.ctl', then the path */
  43. cd_rom.4 = "Neurotic Encounters"          /* is wrong                                       */
  44. cd_rom.4.path = 'C:\MAX\LOONEY\'
  45. cd_rom.5 = "Swine Reference Library"
  46. cd_rom.5.path = 'C:\MAX\SWINE\'
  47. cd_rom.6 = "Hobbes OS/2"
  48. cd_rom.6.path = 'C:\MAX\HOBBES1\'
  49. cd_rom.7 = "Monster Disk #2"
  50. cd_rom.7.path = 'C:\MAX\MONSTER1\'
  51.  
  52.  
  53. /*-----DESIGNATE WHICH DRIVES ARE CD-ROMS------------*/
  54.  
  55. drive.0 = 3                   /* Enter total number of drives here */
  56. drive.1 = "E"                /* Enter drive letters like this  */
  57. drive.2 = "F"
  58. drive.3 = "G"
  59. /*drive.4 = "H"
  60.    drive.5 = "I"
  61.    drive.6 = "J" */
  62.  
  63. /*-------------------END OF CONFIGURATION AREA---------------------------*/
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71. /*---------------------BEGINNING OF PROGRAM-------------------------------*/
  72.  
  73. /* initialize VREXX */
  74.  
  75.    call RxFuncAdd 'VInit','VREXX','VINIT'
  76.    initcode = VInit()
  77.     if initcode = "ERROR" then signal CLEANUP
  78.  
  79.     signal on failure name CLEANUP
  80.     signal on halt name CLEANUP
  81.     signal on syntax name CLEANUP
  82.  
  83. /* initialize REXX functions */
  84.  
  85.    call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
  86.    call SysLoadFuncs
  87.  
  88.  
  89.  
  90.  
  91. /* check to see if the designated drives are cd-roms  */
  92.    Do i = 1 to drive.0
  93.      driveinfo = SysDriveInfo(drive.i)
  94.      drivespace = subword(driveinfo, 2 ,1)
  95.      if drivespace <> 0 then signal nocd
  96.    end
  97.  
  98. /* position of info window */
  99.    pos.left = 25
  100.    pos.bottom = 25
  101.    pos.right = 75
  102.    pos.top = 75
  103.  
  104.  
  105. /* create the intro window */
  106.    new_id = VOpenWindow(' ',white,pos)
  107.  
  108. /* Set font and color */
  109.    call VSetFont ' ','TIMEB',55
  110.    call VForeColor ' ',BLUE
  111.    call VSay " ",180,800,'ChangeCD'
  112.    call VSetFont ' ','TIME',15
  113.    call VForeColor ' ',BLACK
  114.    call VSay " ",315,600,'By ROGER DEMPSEY'
  115.    call VSetFont ' ','TIME',15
  116.    call VForeColor ' ',PINK
  117.    call VSay " ",290,500,'BANANA REPUBLIC BBS'
  118.    call VSetFont ' ','TIME',15
  119.    call VForeColor ' ',BLACK
  120.    call VSay " " ,275,450,'New Westminster, BC, Canada'
  121.    call VSay " " ,390,400,'(604) 524-6990'
  122.    call SysSleep 5 
  123.    call VCloseWindow (' ')
  124.  
  125.  
  126. /* position of info window  (adjust for number of drives) */
  127.    pos.left = 2
  128.    pos.bottom = 43 + drive.0
  129.    pos.right = 50
  130.    pos.top = 90
  131.  
  132. /* Set font and color */
  133.    new_id = VOpenWindow('ChangeCD',white,pos)
  134.    call VSetFont 'ChangeCD','TIME',15
  135.    call VForeColor 'ChangeCD',RED
  136.  
  137. /* position of radio box  */
  138.    call VDialogPos 64,50
  139.  
  140. /* loop back if they made a mistake */
  141. oops:
  142.  
  143. /* find out what cd-rom will be in each drive and display it in info window */
  144.    x= 800
  145.    Do i = 1 to drive.0
  146.      call VRadioBox 'CD-ROM in drive 'drive.i'?',cd_rom,1    
  147.        Do k = 1 to cd_rom.0
  148.          if cd_rom.vstring = cd_rom.k then areapath.i =cd_rom.k.path'drive'drive.i'.ctl'
  149.        end
  150.      call VForeColor 'ChangeCD',BLACK
  151.      call VSay "ChangeCD",100,x,'The CD in drive 'drive.i' is/will be: '
  152.      call VForeColor 'ChangeCD',RED
  153.      call VSay "ChangeCD",560,x,cd_rom.vstring
  154.      x = x - 60
  155.    end
  156.  
  157. /* double check the info */  
  158.    prompt.0 = 1
  159.    prompt.1 = '       Are these correct?'
  160.    call VDialogPos 60, 50
  161.    button = VMsgBox('ChangeCD', prompt, 6)
  162.    
  163.    if button = 'NO' 
  164.       then call VClearWindow ('ChangeCD')
  165.    if button = "NO"
  166.       then signal oops
  167.  
  168. /* delete the current filearea.ctl */
  169.    rc = SysFileDelete(areafile)
  170.    if rc <> 0 
  171.         then signal nofile
  172.    call VForeColor 'ChangeCD',PINK
  173.    call VSay "ChangeCD",100,x-60,areafile' has been deleted!'
  174.    call VSay "ChangeCD",100,x-120,'Creating new 'areafile
  175.  
  176. /* Create the new filearea.ctl */
  177. /* Add the hard drive areas */
  178.    line = lines(hdd)
  179.    Do while line <> 0 
  180.       data = linein(hdd)
  181.       rc = lineout(areafile, data)   
  182.       if rc <> 0 then signal cleanup
  183.       line = lines(hdd)
  184.    end
  185.  
  186. /* now add the cd-rom areas */   
  187.    Do i = 1 to drive.0
  188.       line = lines(areapath.i)
  189.       Do while line <> 0 
  190.          data = linein(areapath.i)
  191.          rc = lineout(areafile, data)
  192.           if rc <> 0 then signal cleanup
  193.          line = lines(areapath.i)
  194.       end
  195.    end
  196.  
  197. /* let them know how it went  */
  198.    call VSay "ChangeCD",100,x-180, 'New 'areafile 'has been created'
  199.    call VForeColor 'ChangeCD',BLUE
  200.    call VSay "ChangeCD",100,x-240, 'Install the cd-roms and run'
  201.    call VSay "ChangeCD",100,x-300, '      SILTP MAX'
  202.    call VSay "ChangeCD",100,x-360, 'to initialize these changes.'
  203.  
  204. /* prompt to end program */
  205.    prompt.0 = 1
  206.    prompt.1 = ' '
  207.    call VDialogPos 60, 50
  208.    button = VMsgBox('ChangeCD', prompt, 1)
  209.    
  210.  
  211.  
  212.  
  213. /* if there was a problem or the program is done then come here */
  214.    CLEANUP:
  215.     call VExit
  216.  
  217.     exit
  218.  
  219.  
  220.  
  221. /* one of the designated drives is not a cd-rom */
  222.    nocd:
  223.    prompt.0 = 3
  224.    prompt.1 = '      Drive 'drive.i 'is not a CD-ROM!'
  225.    prompt.2 = '      Or there is no CD-ROM in that drive!'
  226.    prompt.3 = '      Please check the drives you have designated!'
  227.    call VDialogPos 50,50
  228.    button = VmsgBox('ChangeCD', prompt, 1)
  229.    signal CLEANUP
  230.  
  231. /* problem with deleteing the filearea.ctl */
  232.    nofile:
  233.    prompt.0 = 2
  234.    if rc = 2 then prompt.1 = '      ChangeCD could not find 'areafile
  235.    if rc = 3 then prompt.1 = '      ChangeCD could not find the path to 'areafile
  236.    if rc = 5 then prompt.1 = '      ChangeCD was denied access to 'areafile
  237.    if rc > 5 then prompt.1 = '      Unknown problem accessing 'areafile
  238.    if rc <= 3 then prompt.2 = '      Please check what you have designated!'
  239.    if rc = 5 then prompt.2 = '       Please check if it is write protected!'
  240.    if rc > 5 then prompt.2 = '       Oh Oh! Tell author rc = 'rc
  241.    call VDialogPos 50,50
  242.    button = VmsgBox(' ', prompt, 1)
  243.    signal CLEANUP
  244.