home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / textutil / jgpsuite / Docs / JGCodeInfo < prev    next >
Encoding:
Text File  |  1993-04-20  |  6.0 KB  |  154 lines

  1. The following two chunks of code may be of interest to programmers. They have
  2. been selected since they can most easily be understood in isolation from the
  3. rest of JGPrint's code. I give no gaurentee that the actual code will be
  4. identical to what is shown here.
  5.  
  6. This first chunk sorts out what code to send to the printer for a requested
  7. horizontal movement, according to the 'size' and 'code' (Controlsptr) settings
  8. of the configuration file.
  9.  
  10. The Second handles %X (for the various allowable Xs) to interpret how parameters
  11. in the various code calls (see e.g. Wcd( hmi, d1, ?, x ) below) can be
  12. interpreted as the sequence of bytes required by particular printers.
  13.  
  14.  
  15. and Hmi(d) be
  16.  $( let Cp = Controlsptr                        // Vector of Codes
  17.     let spw = Propcharw('*s')
  18.     if Noword | Nowrite | (Laybase=0 & Inbody \= ib.ft) return  // Skipping
  19.     d +:= Hspacecarry                           // Leftover last time
  20.     if d=0 do                                   // Write1 is char output routine
  21.      $( HSpacecarry := 0; return $)
  22.     if (d>0 -> c.rc, c.lc)!cp \= 0 do
  23.      $( let Wo = Writeto
  24.         let d1 = false
  25.         if Write1=Writescr do Writeto, d1 := Writescr, true
  26.         if Write1=Writefl & IsDoc=id.scr do Writeto, d1 := Write1, true
  27.         if d1 do
  28.          $( test d > 0                          // c.rc, c.lc, Cw are cursor,
  29.              do while d >= Cw do                // right, left, Character Width
  30.                  $( WrtoF( c.rc!cp ); d -:= Cw $)
  31.              or while d < 0 do
  32.                  $( WrtoF( c.lc!cp ); d +:= Cw $)
  33.             HSpacecarry := d                    // Left to next time
  34.             Writeto := Wo
  35.             return
  36.          $)
  37.      $)
  38.     if c.hmi!cp = 0 | s.abshor!Sizes=0 | FillJust <= 2
  39.      do while d >= spw do                    // Use Spaces forward, in terms
  40.          $( Write1('*s'); d -:= spw $)       // of Printer's spw(idth)
  41.     test d do
  42.      $( let d1 = HutoC( d )                     // Express d in Printer's units
  43.         Hspacecarry := Writeit = Writescr -> d, Result2
  44.         test d >=0 & c.Horbyte!Cp               // Daisy-wheel style move
  45.          do Wcd( c.Horbyte, d )
  46.          or test c.hmi!Cp do                    // Can Move?
  47.              $( let x = c.fwd!Cp                // Repeat Fwd if needed
  48.                 if x & d < 0
  49.                  do test c.bwd!Cp
  50.                      do d1, x := -d1, c.bwd!Cp  // Repeat bwd
  51.                      or d1 := HutoC( Dobs( d, spw ) )// Make parameter +ve.
  52.                 if s.decimal!Sizes do
  53.                  $( x := Muldiv( Hspacecarry, 100, HUnits )
  54.                     unless Writeit = Writepr do Hspacecarry := Result2/100
  55.                  $)                             // Two significant figures
  56.                 if d1 | x do
  57.                 Wcd( c.hmi, d1, ?, x ) // x decimals | fwd/bwd
  58.              $)
  59.              or test d < 0
  60.                  do Hspacecarry := Dobs( d, spw ) or
  61.                  $( d1 := spw
  62.                     until d1 > d do
  63.                      $( Write1('*s'); d-:=d1 $)  // Dobs is backspacing routine
  64.                     HSpacecarry := d
  65.                  $)
  66.      $)
  67.      or HSpaceCarry := 0
  68.  $)
  69.  
  70. /*
  71. B Epson two-byte specified repetition.
  72. E As two bytes for large numbers; used by Epson for Graphics etc.
  73. G +/-ve byte, b<0 -> '@'-b; Qume/Toshiba Program mode Carriage commands.
  74. H Byte value minus 1; used by Qume & Toshiba for Tabs etc.
  75. I As a byte; used by Epson & IBM
  76. J As a numeral; used by HP laser codes
  77. K Direct graphical repetition; used by Juki.
  78. S Hex+Decimal numerals; used by Toshiba for space increments.
  79. T Three digit +/-ve pseudo hex; used by Toshiba for relative motion.
  80. N Numeral specified repetition.
  81. M One-byte specified repetition.
  82. V Signed Numeral; used by HP for relative motion
  83. */
  84. and Printswitch( b, p, Atr2, Dorg ) be
  85.  $( let g = false
  86.     switchon b into
  87.      $( default:
  88.             Code1( b )
  89.             return
  90.         case 'B':                   // Motion
  91.             g := true
  92.         case 'E':                   //Epson bytecount
  93.             if p = Minint do p := Rdn0( Atr2 )
  94.             Noneg(p)
  95.             Code1( pÿ ); Code1( p>>Bitsperbyte )
  96.             endcase
  97.         case 'S':                   // Tosh/Qume space increments
  98.             if p = Minint do p := Rdn0( Atr2 )
  99.             b := p/10
  100.             Code1( b + (b >= 10 -> '@'-9, '0') )
  101.             Code1( p rem 10 + '0' )
  102.             return
  103.         case 'T':                   //Toshiba Relative motion
  104.             if p = Minint do p := Rdn0( Atr2 )
  105.              $( let Pos = p > 0
  106.                 unless Pos do p := -p
  107.                 Code1( p/256 + (Pos -> '@', 'P') )
  108.              $)
  109.             p rem:= 256
  110.             Code1( p/16 + '@' )
  111.             Code1( p rem 16 + '@' )
  112.             return
  113.         case 'H':                   // Tosh/Qume byte val - 1
  114.             b := 0
  115.         case 'M':                   // Byte Count graph
  116.             if b do g := true
  117.         case 'I':                   // Byte
  118.             noneg(p);
  119.             Code1(p)
  120.             endcase
  121.         case 'G':
  122.             if p = Minint do p := Rdn0( Atr2 )
  123.             Noneg(p)
  124.             if b = 'G' & p < 0 do p := '@' - p
  125.             Code1( b -> p, p+1 )
  126.             endcase
  127.         case 'N':                   // Numeral Count Graph
  128.             g := true
  129.         case 'J': case 'V':
  130.             if p = Minint do p := Rdn0( Atr2 )
  131. //            b := Result2//temp        // Decimal not worked out
  132.             test p < 0 do
  133.              $( Code1('-'); p := -p $)
  134.              or if b = 'V' do Code1('+')
  135.             Cd1n(p)                 // Numeral w. decimal n/a for count
  136.             if s.decimal!Sizes & g=0 do
  137.              $( Code1('.'); Cd1n( Dorg ) $)
  138.             endcase
  139.         case 'K':                   // No count graph
  140.             g := true
  141.      $)
  142.     if g                            // Repitition
  143.      do for i = 1 to p              // porg Controlsptr address
  144.          do for j = 1 to Dorg%0 do Code1( Dorg%i )
  145.  $)
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.