home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / pocketbk / utilsr / scbank23 / src / switch.opl < prev    next >
Text File  |  1994-12-21  |  1KB  |  69 lines

  1. proc switch:
  2.     local file1$(128),file2$(128),line%,c%
  3.     local from$(7),to$(7)
  4.     local handle1%,handle2%,ret%,mode%,txt$(255),address%
  5.     file1$="\opl\*.opl"
  6.     file2$="\opl\trans.opl"
  7.     dinit "Translate opl version"
  8.     dfile file1$,"From",64
  9.     dchoice c%,"Translate to","S3a,S3Classic"
  10.     dfile file2$,"To",1
  11.     if dialog
  12.         mode%=$0400 or $0020 or $0000
  13.         ret%=ioopen(handle1%,file1$,mode%)
  14.         if ret%<0
  15.             showerr:(ret%)
  16.         endif
  17.         mode%=$0100 or $0020 or $0001
  18.         ret%=ioopen(handle2%,file2$,mode%)
  19.         if ret%<0
  20.             showerr:(ret%)
  21.         endif
  22.         address%=addr(txt$)
  23.         line%=0
  24.         while 1
  25.             gat 20,20
  26.             gprintb "Line "+num$(line%,10),200
  27.             ret%=ioread(handle1%,address%+1,255)
  28.             if ret%<0
  29.                 if (ret%<>-36) rem eof condition
  30.                     showerr:(ret%)
  31.                 else
  32.                     break
  33.                 endif
  34.             endif
  35.             pokeb address%,ret%
  36.             if (c%=1)
  37.                 from$="s3z"
  38.                 to$="s3a"
  39.             elseif (c%=2)
  40.                 from$="s3a"
  41.                 to$="s3z"
  42.             endif
  43.             if (left$(txt$,7)="rem "+to$)
  44.                 txt$=right$(txt$,len(txt$)-7)+" rem "+to$
  45.             elseif (right$(txt$,8)=" rem "+from$)
  46.                 txt$="rem "+from$+left$(txt$,len(txt$)-8)
  47.             endif
  48.             ret%=iowrite(handle2%,address%+1,len(txt$))
  49.             if ret%<0
  50.                 showerr:(ret%)
  51.             endif
  52.             line%=line%+1
  53.         endwh
  54.         ret%=ioclose(handle1%)
  55.         if ret%
  56.             showerr:(ret%)
  57.         endif
  58.         ret%=ioclose(handle2%)
  59.         if ret%
  60.             showerr:(ret%)
  61.         endif
  62.     endif
  63. endp
  64.  
  65. proc showerr:(val%)
  66.     print "Error",val%,err$(val%)
  67.     get
  68. endp
  69.