home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 375.lha / ArexxExamples / getdiskname.rexx < prev    next >
OS/2 REXX Batch file  |  1990-05-02  |  3KB  |  73 lines

  1. /*
  2. This ARexx function gets the actual name of a disk.
  3. I use this along with my fixdisk program to automatically check a new
  4. unwarped disk for viruses, move ARP material to the volume, check and modify
  5. the startup-sequence on that disk and numerous other things.
  6. The main reason I need the actual name of the disk is that I save all
  7. non-standard boot blocks, just in case I run across a new virus or something
  8. else of interest. Since some disknames have a space in them, I put quotes
  9. around the name to allow the real name to be saved.
  10. I have a special directory to save all my non-standard boot blocks in,
  11. and after I'm sure the ware runs with a standard boot block, I can delete
  12. the non-standard block after looking at it.
  13. */
  14.  
  15. /*...........................THE FUNCTION .............. */
  16.  
  17. /* gdname.rexx....Gets name of disk  */
  18. /*                arg = vol          */
  19.  
  20. gdname:
  21. arg vol
  22.  
  23. call setclip('DNAME',"")
  24.                 /* GET INFO FOR THAT FLOPPY DRIVE */
  25. ""'info 'vol' | execio from 4 for 1 var diskinfo'
  26. /* The above line gets one line of information about the disk you want
  27.  to check...
  28.  DF0:      880K       2    1756   0%   0  Read Only  EMPTY 1 2 3
  29.  This is the line it gets and all I have to do through ARexx is to
  30.  look for Read/Write (seventh word on a disk that is not write-protected),
  31.  and on the above disk, which is read-only (it's write protected) I look for
  32.  'Only' which is the eighth word. Therefore, the actual name of the disk
  33.  begins with the ninth word and continues to the end of the string.
  34.  If you are unfamiliar with the 1.3 INFO command, study it. You can save
  35.  time by aliasing in your shell to
  36.  alias i = info df[]:
  37.  
  38.  To get INFO on one floppy all you have to type is:
  39.  i 0
  40.  . . . for INFO on the disk in df0:
  41.  i 1
  42.  . . . for INFO on the disk in df1:
  43.  
  44.  I also use:
  45.  alias ih = info dh[]:
  46.  . . . to get INFO on individual hard drive partions, since mine are
  47.  dh0: dh1: dh2: dh3: all I have to type is
  48.  Ih 0 .. IH 1 ... Ih 2.. IH 3... etc.
  49.  THe Rexx setclip/getclip is something like getenv/setenv from CBM.
  50.  If I used setenv, I could actually use it in a DOS script, but
  51.  since ARexx is faster and has more features, I rarely use DOS scripts
  52.  except for very very simple things.
  53. */
  54.  
  55. if compare(word(diskinfo,8),'Only') == 0 then diskname = subword(diskinfo,9,)
  56. else diskname = subword(diskinfo,8,)
  57. call setclip('DNAME','"' || diskname || '"')
  58. return
  59.  
  60.  
  61. /*..............................A CALLING TEST PROGRAM ............*/
  62. /* test.rexx */
  63. arg vol
  64.  
  65. call gdname vol      /* call the aOve function to get the name of the disk */
  66. say getclip('DNAME') /* say in Rexx is like the ECHO cmd */
  67.  
  68. /*
  69. NOTE: again you can use ARexx without running wshell
  70. by using Rx on the ARexx Disk.
  71. you have to type "RX (rexx program name) args (if any)"
  72. */
  73.