home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / SNOBOL / SNOBOL_C.ZIP / CASE.SNO < prev    next >
Encoding:
Text File  |  1986-12-23  |  1.6 KB  |  46 lines

  1. -PLUSOPS 1
  2. *
  3. *  This SNOBOL4+ utility program converts text files containing upper and
  4. *  lower case ASCII alphabetic text to all-upper-case or all-lower-case.
  5. *  It also can swap both simultaneously to perform case inversion.
  6. *   The program is written simply (it could be considerably shorter) to
  7. *  demonstrate simple SNOBOL4+ programming techniques.  It shows just how
  8. *  easy it is to manipulate and filter text files using SNOBOL4+.
  9. *   This program has been written to accept command line options to permit
  10. *  the same program to do the work of what might otherwise be three separate
  11. *  programs.  However, it is interesting to note that each of those three
  12. *  separate programs, written in SNOBOL4+, would be only two lines long
  13. *  (and, one of those is simply the END statement!)
  14. *   Sample command line to run this program:
  15. *
  16. *     SNORUN CASE <ASMLC.ASM >ASMUC.ASM;/U
  17. *
  18.     SCREEN = "CASE 1.0  Alphabetic Case Conversion Program"
  19.     SCREEN = "  Copyright 1986, Gordon E. Peterson II"
  20.     INPUT(.INPUT,,"R,1000")
  21.     OUTPUT(.OUTPUT,,"W,1000")
  22. *
  23.     UPARM = REPLACE(&PARM,&LCASE,&UCASE)
  24.     &TRIM = 1
  25. *
  26.     UPARM BREAKX("/") LEN(1) "U"    :S(TOUPPER)
  27.     UPARM BREAKX("/") LEN(1) "L"    :S(TOLOWER)
  28.     SCREEN =
  29.     SCREEN = "Usage:  CASE  <inputfile >outputfile;<options>"
  30.     SCREEN = "  <options> = /L and/or /U"
  31.     SCREEN = "  /L  =  convert to lower case"
  32.     SCREEN = "  /U  =  convert to upper case"
  33.     SCREEN = "  (both)  = invert case"        :(END)
  34. *
  35. TOUPPER FROM = &LCASE
  36.     TO = &UCASE            
  37.     UPARM BREAKX("/") LEN(1) "L"    :F(CVTIT)
  38. *
  39. TOLOWER    FROM = FROM &UCASE
  40.     TO = TO &LCASE
  41. *
  42. CVTIT    OUTPUT = REPLACE(INPUT,FROM,TO)        :S(CVTIT)
  43. END
  44.  
  45.  
  46.