home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / UNIFLEX / UNIFLEX / UniFLEX_Std.Utils1.tar.Z / UniFLEX_Std.Utils1.tar / utils1 / uplow < prev    next >
Text File  |  1981-09-01  |  3KB  |  172 lines

  1.  ttl Convert file to lower case
  2.  opt pag
  3. ***  Convert file to lower case.
  4.  lib sysdef
  5.  lib syserrors
  6.  sttl Main program.
  7.  pag
  8. **   Main program.
  9.  
  10.  org 0
  11.  
  12. rem ldx 2,s get address of program name
  13.  stx aptr save argument address
  14.  lda #write initialize write block
  15.  sta wblk
  16.  ldx #wbuf
  17.  stx wblk+1
  18.  
  19. rem1 jsr onf open next file
  20.  beq exit if end of arguments
  21.  jsr osf open scratch file
  22.  jsr cpy copy file
  23.  jsr ren rename files
  24.  bra rem1 loop for next file
  25.  
  26. exit clra terminate
  27.  clrb
  28.  sys term
  29.  sttl Subroutines
  30.  pag
  31. **   Subroutines.
  32.  spc 2
  33. **   cpy - copy file, converting case
  34.  spc 2
  35. cpy ldd rfd read data
  36.  sys read,rbuf,1024
  37.  bes cpyerr if error during read
  38.  std rcc save character count
  39.  beq cpyxit if end of data
  40.  clra clear "write character count"
  41.  clrb
  42.  std wcc
  43.  ldy #rbuf
  44.  ldu #wbuf
  45.  
  46. cpy1 lda 0,y+ get a character
  47.  cmpa #'A
  48.  blo cpy2 if not upper case
  49.  cmpa #'Z
  50.  bhi cpy2 if not upper case
  51.  ora #$20 convert to lower case
  52. cpy2 sta 0,u+
  53.  ldx wcc
  54.  leax 1,x count character
  55.  stx wcc
  56.  ldx rcc
  57.  leax -1,x count character
  58.  stx rcc
  59.  bne cpy1 loop through buffer
  60.  ldx wcc set write count
  61.  stx wblk+3
  62.  beq cpy if no data
  63.  ldx #wblk dump buffer
  64.  ldd wfd
  65.  sys indx
  66.  bra cpy loop through file
  67.  
  68. cpyxit rts return
  69.  
  70. cpyerr pshs d
  71.  ldd #1
  72.  sys write,cpya,cpyal
  73.  puls d
  74.  sys term
  75.  
  76. cpya fcc 'Error during copy',$d
  77. cpyal equ *-cpya
  78.  spc 4
  79. **   onf - open next file.
  80. *    exit  eq set if no more names
  81.  spc 2
  82. onf ldx aptr skip current file name
  83. onf1 lda 0,x+
  84.  bne onf1
  85.  stx aptr update pointer
  86.  lda 0,x check character
  87.  beq onfxit if no more files
  88.  ldy #0
  89.  lda #open
  90.  pshs a,x,y build function block
  91.  leax 0,s
  92.  sys indx
  93.  leas 5,s
  94.  bes onf2 if error during open
  95.  std rfd save descriptor
  96. onfxit rts return
  97.  
  98. onf2 pshs d
  99.  ldd #1
  100.  sys write,onfa,onfal
  101.  puls d
  102.  sys term
  103.  
  104. onfa fcc 'Error opening data file',$d
  105. onfal equ *-onfa
  106.  spc 4
  107. **   osf - open scratch file.
  108.  spc 2
  109. osf sys create,osfa,%011011
  110.  bes osf1 if error
  111.  std wfd store descriptor
  112.  rts return
  113.  
  114. osf1 pshs d
  115.  ldd #1
  116.  sys write,osfb,osfbl
  117.  puls d
  118.  sys term
  119.  
  120. osfa fcc 'scratch',0
  121. osfb fcc 'Error opening scratch file',$d
  122. osfbl equ *-osfb
  123.  spc 4
  124. **   ren - rename files.
  125.  spc 2
  126. ren leas -5,s reserve function block space
  127.  ldx aptr build unlink call
  128.  stx 1,s
  129.  lda #unlink
  130.  sta 0,s
  131.  leax 0,s
  132.  sys indx unlink old file
  133.  bes ren1 if error
  134.  ldy 1,s build link block
  135.  sty 3,s
  136.  ldy #osfa store new name
  137.  sty 1,x
  138.  lda #link link new name
  139.  sta 0,x
  140.  sys indx
  141.  bes ren1 if error
  142.  lda #unlink unlink scratch file
  143.  sta 0,x
  144.  sys indx
  145.  bes ren1 if error
  146.  ldd rfd close files
  147.  sys close
  148.  ldd wfd
  149.  sys close
  150.  leas 5,s
  151.  rts return
  152.  
  153. ren1 pshs d
  154.  ldd #1
  155.  sys write,rena,renal
  156.  puls d
  157.  sys term
  158.  
  159. rena fcc 'Error renaming files',$d
  160. renal equ *-rena
  161. **   Variable definitions.
  162.  spc 2
  163. aptr rmb 2 argument pointer
  164. rfd rmb 2 read file descriptor
  165. wfd rmb 2 write file descriptor
  166. wblk rmb 5 "write" function block
  167. rcc rmb 2 read buffer character count
  168. wcc rmb 2 write buffer character count
  169. rbuf rmb 1024 read buffer
  170. wbuf rmb 1024 write buffer
  171.  end rem
  172.