home *** CD-ROM | disk | FTP | other *** search
/ Current Shareware 1994 January / SHAR194.ISO / dos_util / pcmcvt.zip / PCMASM.ZIP / W4DCONV.INC < prev    next >
Text File  |  1993-05-22  |  3KB  |  114 lines

  1. ;W4DCONV.INC
  2. ;Copyright (c) 1993 Jay Munro
  3. ;First Published in PC Magazine June 29 1993
  4. ;PCMCVT Conversion module for Word 5.0 & 5.5
  5. ;
  6. ;Each module is responsible for reading and writing text via the system
  7. ;buffers.  Command line flags are global and available.
  8. ;
  9. Word4DOSCVT Proc Near
  10.     Invoke Seek, SHandle, 128           ;seek to start of file
  11.     Jnc    @F
  12.     Jmp    W4DExit                      ;error, bag out
  13. @@:
  14.     Lea    SI, HeaderBuffer             ;get address of header to check
  15.     Mov    Word Ptr AX, [SI].MSWdfcMac  ;get low word of end of text
  16.     Mov    MSW4DFileEnd,AX
  17.     Mov    Word Ptr AX,[SI+2].MSWdfcMac ;and high byte
  18.     Mov    MSW4DFileEnd[2],AX
  19.  
  20.     Sub    Word Ptr MSW4DFileEnd,128    ;clear off starting point
  21.     Sbb    Word Ptr MSW4DFileEnd[2],0
  22.  
  23. ReadW4DFile:
  24.     Call   W4DReadIt                    ;go read the file
  25.  
  26. RW4DLoop:                               ;weed out control chars
  27.     LodSb                               ;grab a character
  28.     Sub    Word Ptr MSW4DFileEnd, 1
  29.     Sbb    Word Ptr MSW4DFileEnd[2], 0
  30.     Cmp    Word Ptr MSW4DFileEnd, 0
  31.     Jnz    @F
  32.     Cmp    Word Ptr MSW4DFileEnd[2], 0
  33.     Jnz    @F
  34.     Call   FlushIt
  35.     Jmp    W4DExit                      ;exit stage left
  36.  
  37. MSW4DFileEnd  DW 0,0
  38.  
  39. @@:
  40.     Cmp    AL,13                        ;a carriage return?
  41.     Jnz    @F
  42.     Call   W4DWrite
  43.     Jmp    W4DReLoop                    ;skip over
  44.     
  45. @@:
  46.     Cmp    AL,10                        ;hard cr for W4D
  47.     Jnz    @F
  48.     Call   W4DWrite                     ;write what's in AL
  49.     Jmp    W4DReLoop
  50.  
  51. @@:
  52.     Cmp    AL,11
  53.     Jnz    @F
  54.     Mov    AL,13
  55.     Call   WriteIt                      ;write what's in AL
  56.     Mov    AL,10                        ;make it a hard return
  57.     Call   WriteIt
  58.     Jmp    W4DReLoop
  59.  
  60. @@:
  61.     Cmp    AL,15                        ;em dash?
  62.     Jnz    @F                           ;nope, keep going
  63.     Mov    AL,'-'                       ;store duel hyphans
  64.     Call   W4DWrite
  65.     Mov    AL,'-'                       ;store duel hyphans
  66.     Call   W4DWrite
  67.     Jmp    W4DReLoop
  68.  
  69. @@:
  70.     Cmp    AL,2                         ;print current date;
  71.     Jnz    @F                           ;future expansion
  72. @@:
  73.     Cmp    AL,3                         ;print current time
  74.     Jnz    @F                           ;future expansion
  75. @@:
  76.     Cmp    AL,9                         ;tab
  77.     Jnz    @F
  78.     Call   DoTabs                       ;expand the tabs
  79.     Jmp    W4DReLoop
  80.     
  81. @@:
  82.     Cmp    AL,31                        ;ok, skip the rest
  83.     Jbe    W4DReLoop                    ;skip it
  84.     Cmp    AL,196                       ;two other skippers
  85.     Jz     W4DReLoop
  86.     Cmp    AL,255
  87.     Jz     W4DReLoop
  88.  
  89. ;write what's left
  90.     Call   W4DWrite                     ;call our local write module
  91.     Jmp    W4DReLoop
  92.  
  93. W4DReLoop:
  94.     Loop RW4DLoop
  95.     Jmp  ReadW4DFile                     ;go back for more
  96.  
  97. W4DWrite:
  98.     Call   WriteIt                      ;no, then write it
  99.     Jc     W4DExit
  100.     RetN
  101.  
  102. W4DReadIt:
  103.     Call   ReadIt                       ;go read the file
  104.     Jnc    @F                           ;a fine read, continue
  105.     Mov    AL,-1                        ;a bad read, quit now
  106.     Call   W4DWrite                     ;flush buffer
  107.     Jmp    W4DExit
  108. @@:
  109.     RetN
  110.  
  111. W4DExit:
  112.     Ret
  113. Word4DOSCVT  EndP
  114.