home *** CD-ROM | disk | FTP | other *** search
- The following two chunks of code may be of interest to programmers. They have
- been selected since they can most easily be understood in isolation from the
- rest of JGPrint's code. I give no gaurentee that the actual code will be
- identical to what is shown here.
-
- This first chunk sorts out what code to send to the printer for a requested
- horizontal movement, according to the 'size' and 'code' (Controlsptr) settings
- of the configuration file.
-
- The Second handles %X (for the various allowable Xs) to interpret how parameters
- in the various code calls (see e.g. Wcd( hmi, d1, ?, x ) below) can be
- interpreted as the sequence of bytes required by particular printers.
-
-
- and Hmi(d) be
- $( let Cp = Controlsptr // Vector of Codes
- let spw = Propcharw('*s')
- if Noword | Nowrite | (Laybase=0 & Inbody \= ib.ft) return // Skipping
- d +:= Hspacecarry // Leftover last time
- if d=0 do // Write1 is char output routine
- $( HSpacecarry := 0; return $)
- if (d>0 -> c.rc, c.lc)!cp \= 0 do
- $( let Wo = Writeto
- let d1 = false
- if Write1=Writescr do Writeto, d1 := Writescr, true
- if Write1=Writefl & IsDoc=id.scr do Writeto, d1 := Write1, true
- if d1 do
- $( test d > 0 // c.rc, c.lc, Cw are cursor,
- do while d >= Cw do // right, left, Character Width
- $( WrtoF( c.rc!cp ); d -:= Cw $)
- or while d < 0 do
- $( WrtoF( c.lc!cp ); d +:= Cw $)
- HSpacecarry := d // Left to next time
- Writeto := Wo
- return
- $)
- $)
- if c.hmi!cp = 0 | s.abshor!Sizes=0 | FillJust <= 2
- do while d >= spw do // Use Spaces forward, in terms
- $( Write1('*s'); d -:= spw $) // of Printer's spw(idth)
- test d do
- $( let d1 = HutoC( d ) // Express d in Printer's units
- Hspacecarry := Writeit = Writescr -> d, Result2
- test d >=0 & c.Horbyte!Cp // Daisy-wheel style move
- do Wcd( c.Horbyte, d )
- or test c.hmi!Cp do // Can Move?
- $( let x = c.fwd!Cp // Repeat Fwd if needed
- if x & d < 0
- do test c.bwd!Cp
- do d1, x := -d1, c.bwd!Cp // Repeat bwd
- or d1 := HutoC( Dobs( d, spw ) )// Make parameter +ve.
- if s.decimal!Sizes do
- $( x := Muldiv( Hspacecarry, 100, HUnits )
- unless Writeit = Writepr do Hspacecarry := Result2/100
- $) // Two significant figures
- if d1 | x do
- Wcd( c.hmi, d1, ?, x ) // x decimals | fwd/bwd
- $)
- or test d < 0
- do Hspacecarry := Dobs( d, spw ) or
- $( d1 := spw
- until d1 > d do
- $( Write1('*s'); d-:=d1 $) // Dobs is backspacing routine
- HSpacecarry := d
- $)
- $)
- or HSpaceCarry := 0
- $)
-
- /*
- B Epson two-byte specified repetition.
- E As two bytes for large numbers; used by Epson for Graphics etc.
- G +/-ve byte, b<0 -> '@'-b; Qume/Toshiba Program mode Carriage commands.
- H Byte value minus 1; used by Qume & Toshiba for Tabs etc.
- I As a byte; used by Epson & IBM
- J As a numeral; used by HP laser codes
- K Direct graphical repetition; used by Juki.
- S Hex+Decimal numerals; used by Toshiba for space increments.
- T Three digit +/-ve pseudo hex; used by Toshiba for relative motion.
- N Numeral specified repetition.
- M One-byte specified repetition.
- V Signed Numeral; used by HP for relative motion
- */
- and Printswitch( b, p, Atr2, Dorg ) be
- $( let g = false
- switchon b into
- $( default:
- Code1( b )
- return
- case 'B': // Motion
- g := true
- case 'E': //Epson bytecount
- if p = Minint do p := Rdn0( Atr2 )
- Noneg(p)
- Code1( pÿ ); Code1( p>>Bitsperbyte )
- endcase
- case 'S': // Tosh/Qume space increments
- if p = Minint do p := Rdn0( Atr2 )
- b := p/10
- Code1( b + (b >= 10 -> '@'-9, '0') )
- Code1( p rem 10 + '0' )
- return
- case 'T': //Toshiba Relative motion
- if p = Minint do p := Rdn0( Atr2 )
- $( let Pos = p > 0
- unless Pos do p := -p
- Code1( p/256 + (Pos -> '@', 'P') )
- $)
- p rem:= 256
- Code1( p/16 + '@' )
- Code1( p rem 16 + '@' )
- return
- case 'H': // Tosh/Qume byte val - 1
- b := 0
- case 'M': // Byte Count graph
- if b do g := true
- case 'I': // Byte
- noneg(p);
- Code1(p)
- endcase
- case 'G':
- if p = Minint do p := Rdn0( Atr2 )
- Noneg(p)
- if b = 'G' & p < 0 do p := '@' - p
- Code1( b -> p, p+1 )
- endcase
- case 'N': // Numeral Count Graph
- g := true
- case 'J': case 'V':
- if p = Minint do p := Rdn0( Atr2 )
- // b := Result2//temp // Decimal not worked out
- test p < 0 do
- $( Code1('-'); p := -p $)
- or if b = 'V' do Code1('+')
- Cd1n(p) // Numeral w. decimal n/a for count
- if s.decimal!Sizes & g=0 do
- $( Code1('.'); Cd1n( Dorg ) $)
- endcase
- case 'K': // No count graph
- g := true
- $)
- if g // Repitition
- do for i = 1 to p // porg Controlsptr address
- do for j = 1 to Dorg%0 do Code1( Dorg%i )
- $)
-
-
-
-
-
-
-
-
-