home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
basic
/
library
/
pb
/
library2
/
ljlbar39.bas
< prev
next >
Wrap
BASIC Source File
|
1990-04-04
|
13KB
|
291 lines
'00 ─────────────────────────────────────────────── Font39LandDownload sub.
'This group of routines with the function FNCode39$ defines the 128 characters
'of the Code 39 barcode set, and downloads them to the HP Laserjet II printer
'as an alternate character set. This character set is for use in the landscape
'mode only. The printer is reset by the sub Font39LandDownload, and landscape
'mode is then selected, the font set is then formated, and downloaded. The
'function FNCode39$ is used to toggle between Code 39 and normal text sent to
'the printer.
'Note: This code does not check printer ready status (online,paper,etc).
'PB 2.0 - Walter Haase
'TB 1.0 - Kent Walker
Sub Font39LandDownload
Local A%,B%,C%,D%
Lprint Chr$(27);"E"; 'reset the printer
Lprint Chr$(27);"&l1O"; 'select landscape mode
Lprint Chr$(27);"*c0F"; 'delete all current soft fonts
Lprint Chr$(27);"*c1D"; 'select font #1 for definition
Lprint Chr$(27);")s64W"; 'issue descriptor command
'build font descriptor block (fixed-length of 64 bytes, reserved bytes
'are set to null)
Lprint Chr$(0); 'byte 0 is null
Lprint Chr$(64); 'set font descriptor size (64 bytes)
Lprint Chr$(0); 'reserved - 1 byte
Lprint Chr$(0); 'set font type to 7 bit (default)
Lprint Chr$(0);Chr$(0); 'reserved - 2 bytes
Lprint Chr$(0);Chr$(&H32); 'set baseline distance (12/72*300=32h)
Lprint Chr$(0);Chr$(&HFF); 'set cell width (255d)
Lprint Chr$(0);Chr$(&HFF); 'set cell height (255d)
Lprint Chr$(1); 'set orientation to landscape
Lprint Chr$(0); 'set spacing to fixed (default)
Lprint Chr$(0);Chr$(25); 'set symbol set to Code 39
Lprint Chr$(&H01);Chr$(&H04); 'set pitch 4.6 cpi (26/120*1200=104h)
Lprint Chr$(&H01);Chr$(&H60); 'set height 21.1 (21/72*1200=160h)
Lprint Chr$(0);Chr$(0); 'set xHeight (HPLJ ignores)
Lprint Chr$(0); 'set width type (HPLJ ignores)
Lprint Chr$(0); 'set style to upright (0, 1 is Italic)
Lprint Chr$(0); 'set stroke weight medium (-7 to +7)
Lprint Chr$(0); 'set typeface (default)
Lprint Chr$(0); 'reserved - 1 byte
Lprint Chr$(0); 'set Serif style (HPLJ ignores)
Lprint Chr$(0);Chr$(0); 'reserved - 2 bytes
Lprint Chr$(0); 'set underline distance (default)
Lprint Chr$(0); 'set underline height (HPLJ ignores)
Lprint Chr$(0);Chr$(0); 'set text height (HPLJ ignores)
Lprint Chr$(0);Chr$(0); 'set text width (HPLJ ignores)
Lprint String$(4,Chr$(0)); 'reserved - 4 bytes
Lprint Chr$(0); 'set pitch extended (default)
Lprint Chr$(0); 'set height extended (default)
Lprint String$(6,Chr$(0)); 'reserved - 6 bytes
Lprint "CODE 39 "; 'issue font name (16 bytes padded)
'end of font descriptor block
'below are listed the four combinations of wid/narrow bar/space masks
'used in the 128 character Code 39 set
A%=1 'define narrow bar, narrow space mask
B%=2 'define narrow bar, wide space mask
C%=3 'define wide bar, narrow space mask
D%=4 'define wide bar, wide space mask
'define 128 character set masks, and perform character format
Call Format(0,A%,B%,B%,B%,A%,D%,A%,A%,A%,C%) '0 NUL (%U)
Call Format(1,B%,B%,B%,A%,A%,C%,A%,B%,A%,C%) '1 SOH ($A)
Call Format(2,B%,B%,B%,A%,A%,A%,C%,B%,A%,C%) '2 STX ($B)
Call Format(3,B%,B%,B%,A%,A%,C%,C%,B%,A%,A%) '3 ETX ($C)
Call Format(4,B%,B%,B%,A%,A%,A%,A%,D%,A%,C%) '4 EOT ($D)
Call Format(5,B%,B%,B%,A%,A%,C%,A%,D%,A%,A%) '5 ENQ ($E)
Call Format(6,B%,B%,B%,A%,A%,A%,C%,D%,A%,A%) '6 ACK ($F)
Call Format(7,B%,B%,B%,A%,A%,A%,A%,B%,C%,C%) '7 BEL ($G)
Call Format(8,B%,B%,B%,A%,A%,C%,A%,B%,C%,A%) '8 BS ($H)
Call Format(9,B%,B%,B%,A%,A%,A%,C%,B%,C%,A%) '9 HT ($I)
Call Format(10,B%,B%,B%,A%,A%,A%,A%,D%,C%,A%) '10 LF ($J)
Call Format(11,B%,B%,B%,A%,A%,C%,A%,A%,B%,C%) '11 VT ($K)
Call Format(12,B%,B%,B%,A%,A%,A%,C%,A%,B%,C%) '12 FF ($L)
Call Format(13,B%,B%,B%,A%,A%,C%,C%,A%,B%,A%) '13 CR ($M)
Call Format(14,B%,B%,B%,A%,A%,A%,A%,C%,B%,C%) '14 SO ($N)
Call Format(15,B%,B%,B%,A%,A%,C%,A%,C%,B%,A%) '15 SI ($O)
Call Format(16,B%,B%,B%,A%,A%,A%,C%,C%,B%,A%) '16 DLE ($P)
Call Format(17,B%,B%,B%,A%,A%,A%,A%,A%,D%,C%) '17 DC1 ($Q)
Call Format(18,B%,B%,B%,A%,A%,C%,A%,A%,D%,A%) '18 DC2 ($R)
Call Format(19,B%,B%,B%,A%,A%,A%,C%,A%,D%,A%) '19 DC3 ($S)
Call Format(20,B%,B%,B%,A%,A%,A%,A%,C%,D%,A%) '20 DC4 ($T)
Call Format(21,B%,B%,B%,A%,A%,D%,A%,A%,A%,C%) '21 NAK ($U)
Call Format(22,B%,B%,B%,A%,A%,B%,C%,A%,A%,C%) '22 SYN ($V)
Call Format(23,B%,B%,B%,A%,A%,D%,C%,A%,A%,A%) '23 ETB ($W)
Call Format(24,B%,B%,B%,A%,A%,B%,A%,C%,A%,C%) '24 CAN ($X)
Call Format(25,B%,B%,B%,A%,A%,D%,A%,C%,A%,A%) '25 EM ($Y)
Call Format(26,B%,B%,B%,A%,A%,B%,C%,C%,A%,A%) '26 SUB ($Z)
Call Format(27,A%,B%,B%,B%,A%,C%,A%,B%,A%,C%) '27 ESC (%A)
Call Format(28,A%,B%,B%,B%,A%,A%,C%,B%,A%,C%) '28 FS (%B)
Call Format(29,A%,B%,B%,B%,A%,C%,C%,B%,A%,A%) '29 GS (%C)
Call Format(30,A%,B%,B%,B%,A%,A%,A%,D%,A%,C%) '30 RS (%D)
Call Format(31,A%,B%,B%,B%,A%,C%,A%,D%,A%,A%) '31 US (%E)
Call Format(32,0,0,0,0,0,B%,C%,A%,C%,A%) '32 SPACE
Call Format(33,B%,B%,A%,B%,A%,C%,A%,B%,A%,C%) '33 ! (/A)
Call Format(34,B%,B%,A%,B%,A%,A%,C%,B%,A%,C%) '34 " (/B)
Call Format(35,B%,B%,A%,B%,A%,C%,C%,B%,A%,A%) '35 # (/C)
Call Format(36,0,0,0,0,0,B%,B%,B%,A%,A%) '36 $
Call Format(37,0,0,0,0,0,A%,B%,B%,B%,A%) '37 %
Call Format(38,B%,B%,A%,B%,A%,A%,C%,D%,A%,A%) '38 & (/F)
Call Format(39,B%,B%,A%,B%,A%,A%,A%,B%,C%,C%) '39 ' (/G)
Call Format(40,B%,B%,A%,B%,A%,C%,A%,B%,C%,A%) '40 ( (/H)
Call Format(41,B%,B%,A%,B%,A%,A%,C%,B%,C%,A%) '41 ) (/I)
Call Format(42,0,0,0,0,0,B%,A%,C%,C%,A%) '42 *
Call Format(43,0,0,0,0,0,B%,A%,B%,B%,A%) '43 +
Call Format(44,B%,B%,A%,B%,A%,A%,C%,A%,B%,C%) '44 , (/L)
Call Format(45,0,0,0,0,0,B%,A%,A%,C%,C%) '45 -
Call Format(46,0,0,0,0,0,D%,A%,A%,C%,A%) '46 .
Call Format(47,0,0,0,0,0,B%,B%,A%,B%,A%) '47 /
Call Format(48,0,0,0,0,0,A%,B%,C%,C%,A%) '48 0
Call Format(49,0,0,0,0,0,C%,B%,A%,A%,C%) '49 1
Call Format(50,0,0,0,0,0,A%,D%,A%,A%,C%) '50 2
Call Format(51,0,0,0,0,0,C%,D%,A%,A%,A%) '51 3
Call Format(52,0,0,0,0,0,A%,B%,C%,A%,C%) '52 4
Call Format(53,0,0,0,0,0,C%,B%,C%,A%,A%) '53 5
Call Format(54,0,0,0,0,0,A%,D%,C%,A%,A%) '54 6
Call Format(55,0,0,0,0,0,A%,B%,A%,C%,C%) '55 7
Call Format(56,0,0,0,0,0,C%,B%,A%,C%,A%) '56 8
Call Format(57,0,0,0,0,0,A%,D%,A%,C%,A%) '57 9
Call Format(58,B%,B%,A%,B%,A%,B%,C%,C%,A%,A%) '58 : (/Z)
Call Format(59,A%,B%,B%,B%,A%,A%,C%,D%,A%,A%) '59 ; (%F)
Call Format(60,A%,B%,B%,B%,A%,A%,A%,B%,C%,C%) '60 < (%G)
Call Format(61,A%,B%,B%,B%,A%,C%,A%,B%,C%,A%) '61 = (%H)
Call Format(62,A%,B%,B%,B%,A%,A%,C%,B%,C%,A%) '62 > (%I)
Call Format(63,A%,B%,B%,B%,A%,A%,A%,D%,C%,A%) '63 ? (%J)
Call Format(64,A%,B%,B%,B%,A%,B%,C%,A%,A%,C%) '64 @ (%V)
Call Format(65,0,0,0,0,0,C%,A%,B%,A%,C%) '65 A
Call Format(66,0,0,0,0,0,A%,C%,B%,A%,C%) '66 B
Call Format(67,0,0,0,0,0,C%,C%,B%,A%,A%) '67 C
Call Format(68,0,0,0,0,0,A%,A%,D%,A%,C%) '68 D
Call Format(69,0,0,0,0,0,C%,A%,D%,A%,A%) '69 E
Call Format(70,0,0,0,0,0,A%,C%,D%,A%,A%) '70 F
Call Format(71,0,0,0,0,0,A%,A%,B%,C%,C%) '71 G
Call Format(72,0,0,0,0,0,C%,A%,B%,C%,A%) '72 H
Call Format(73,0,0,0,0,0,A%,C%,B%,C%,A%) '73 I
Call Format(74,0,0,0,0,0,A%,A%,D%,C%,A%) '74 J
Call Format(75,0,0,0,0,0,C%,A%,A%,B%,C%) '75 K
Call Format(76,0,0,0,0,0,A%,C%,A%,B%,C%) '76 L
Call Format(77,0,0,0,0,0,C%,C%,A%,B%,A%) '77 M
Call Format(78,0,0,0,0,0,A%,A%,C%,B%,C%) '78 N
Call Format(79,0,0,0,0,0,C%,A%,C%,B%,A%) '79 O
Call Format(80,0,0,0,0,0,A%,C%,C%,B%,A%) '80 P
Call Format(81,0,0,0,0,0,A%,A%,A%,D%,C%) '81 Q
Call Format(82,0,0,0,0,0,C%,A%,A%,D%,A%) '82 R
Call Format(83,0,0,0,0,0,A%,C%,A%,D%,A%) '83 S
Call Format(84,0,0,0,0,0,A%,A%,C%,D%,A%) '84 T
Call Format(85,0,0,0,0,0,D%,A%,A%,A%,C%) '85 U
Call Format(86,0,0,0,0,0,B%,C%,A%,A%,C%) '86 V
Call Format(87,0,0,0,0,0,D%,C%,A%,A%,A%) '87 W
Call Format(88,0,0,0,0,0,B%,A%,C%,A%,C%) '88 X
Call Format(89,0,0,0,0,0,D%,A%,C%,A%,A%) '89 Y
Call Format(90,0,0,0,0,0,B%,C%,C%,A%,A%) '90 Z
Call Format(91,A%,B%,B%,B%,A%,C%,A%,A%,B%,C%) '91 [ (%K)
Call Format(92,A%,B%,B%,B%,A%,A%,C%,A%,B%,C%) '92 \ (%L)
Call Format(93,A%,B%,B%,B%,A%,C%,C%,A%,B%,A%) '93 ] (%M)
Call Format(94,A%,B%,B%,B%,A%,A%,A%,C%,B%,C%) '94 ^ (%N)
Call Format(95,A%,B%,B%,B%,A%,C%,A%,C%,B%,A%) '95 _ (%O)
Call Format(96,A%,B%,B%,B%,A%,D%,C%,A%,A%,A%) '96 ` (%W)
Call Format(97,B%,A%,B%,B%,A%,C%,A%,B%,A%,C%) '97 a (+A)
Call Format(98,B%,A%,B%,B%,A%,A%,C%,B%,A%,C%) '98 b (+B)
Call Format(99,B%,A%,B%,B%,A%,C%,C%,B%,A%,A%) '99 c (+C)
Call Format(100,B%,A%,B%,B%,A%,A%,A%,D%,A%,C%) '100 d (+D)
Call Format(101,B%,A%,B%,B%,A%,C%,A%,D%,A%,A%) '101 e (+E)
Call Format(102,B%,A%,B%,B%,A%,A%,C%,D%,A%,A%) '102 f (+F)
Call Format(103,B%,A%,B%,B%,A%,A%,A%,B%,C%,C%) '103 g (+G)
Call Format(104,B%,A%,B%,B%,A%,C%,A%,B%,C%,A%) '104 h (+H)
Call Format(105,B%,A%,B%,B%,A%,A%,C%,B%,C%,A%) '105 i (+I)
Call Format(106,B%,A%,B%,B%,A%,A%,A%,D%,C%,A%) '106 j (+J)
Call Format(107,B%,A%,B%,B%,A%,C%,A%,A%,B%,C%) '107 k (+K)
Call Format(108,B%,A%,B%,B%,A%,A%,C%,A%,B%,C%) '108 l (+L)
Call Format(109,B%,A%,B%,B%,A%,C%,C%,A%,B%,A%) '109 m (+M)
Call Format(110,B%,A%,B%,B%,A%,A%,A%,C%,B%,C%) '110 n (+N)
Call Format(111,B%,A%,B%,B%,A%,C%,A%,C%,B%,A%) '111 o (+O)
Call Format(112,B%,A%,B%,B%,A%,A%,C%,C%,B%,A%) '112 p (+P)
Call Format(113,B%,A%,B%,B%,A%,A%,A%,A%,D%,C%) '113 q (+Q)
Call Format(114,B%,A%,B%,B%,A%,C%,A%,A%,D%,A%) '114 r (+R)
Call Format(115,B%,A%,B%,B%,A%,A%,C%,A%,D%,A%) '115 s (+S)
Call Format(116,B%,A%,B%,B%,A%,A%,A%,C%,D%,A%) '116 t (+T)
Call Format(117,B%,A%,B%,B%,A%,D%,A%,A%,A%,C%) '117 u (+U)
Call Format(118,B%,A%,B%,B%,A%,B%,C%,A%,A%,C%) '118 v (+V)
Call Format(119,B%,A%,B%,B%,A%,D%,C%,A%,A%,A%) '119 w (+W)
Call Format(120,B%,A%,B%,B%,A%,B%,A%,C%,A%,C%) '120 x (+X)
Call Format(121,B%,A%,B%,B%,A%,D%,A%,C%,A%,A%) '121 y (+Y)
Call Format(122,B%,A%,B%,B%,A%,B%,C%,C%,A%,A%) '122 z (+Z)
Call Format(123,A%,B%,B%,B%,A%,A%,C%,C%,B%,A%) '123 { (%P)
Call Format(124,A%,B%,B%,B%,A%,A%,A%,A%,D%,C%) '124 | (%Q)
Call Format(125,A%,B%,B%,B%,A%,C%,A%,A%,D%,A%) '125 } (%R)
Call Format(126,A%,B%,B%,B%,A%,A%,C%,A%,D%,A%) '126 ~ (%S)
Call Format(127,A%,B%,B%,B%,A%,A%,A%,C%,D%,A%) '127 DEL (%T)
Lprint Chr$(27);"*c5F"; 'make soft font permanent
End Sub
Sub Format(AsciiValue%,A%,B%,C%,D%,E%,F%,G%,H%,I%,J%)
Lprint Chr$(27);"*c";AsciiValue%;"E"; 'assign character A,B,C,D, etc
Lprint Chr$(27);"(s731W"; 'issue char. descriptor command
'build char. format descriptor block (reserved bytes are set to null)
Lprint Chr$(4); 'set format (4 for HPLJ)
Lprint Chr$(0); 'set continuation flag (default)
Lprint Chr$(14); 'set descriptor size (14 for HPLJ)
Lprint Chr$(1); 'set class (1 for HPLJ)
Lprint Chr$(1); 'set orientation to landscape
Lprint Chr$(0); 'reserved - 1 byte
Lprint Chr$(&HFF);Chr$(&HCE); 'set left offset to -50 (FFCEh)
Lprint Chr$(0);Chr$(&H42); 'set top offset to +66 (0042h)
Lprint Chr$(0);Chr$(&H58); 'set char. width to 88 dots (11 bytes)
Lprint Chr$(0);Chr$(&H41); 'set char. heigth to 65 dots
Lprint Chr$(0);Chr$(0); 'set delta X (default)
'bytes 16 - 64 character data
'note that the following are sent in REVERSE order; this is because
'landscape fonts are defined in raster scan order
Call Decode(J%) 'send standard Code 39 masks
Call Decode(I%)
Call Decode(H%)
Call Decode(G%)
Call Decode(F%)
If A%>0 Then 'is it a special Code 39 mask ?
Call Decode(E%) 'if yes; then use $,%,+, or / masks
Call Decode(D%)
Call Decode(C%)
Call Decode(B%)
Call Decode(A%)
End If
End Sub
Sub Decode(Mask%) 'calculates byte pixel patterns from masks
Select Case Mask%
Case=1 'narrow bar, narrow space - 2 bytes
Call Download(&B00000000)
Call Download(&B11111111)
Case=2 'narrow bar, wide space - 2 bytes
Call Download(&B00000000)
Call Download(&B00000000)
Call Download(&B11111111)
Case=3 'wide bar, narrow space - 3 bytes
Call Download(&B00000000)
Call Download(&B11111111)
Call Download(&B11111111)
Case=4 'wide bar, wide space - 4 bytes
Call Download(&B00000000)
Call Download(&B00000000)
Call Download(&B11111111)
Call Download(&B11111111)
End Select
End Sub
Sub Download(BitPattern%) 'downloads bit patterns to printer
Local A%,B%
For A%=1 To 5
For B%=1 To 11
Lprint Chr$(BitPattern%);
Next B%
Next A%
End Sub
Def FNCode39$(Text$) 'builds Code 39 ASCII strings
If Len(Text$)<1 Then
FNCode39$=""
Exit Def
Else
FNCode39$=Chr$(14)+"*"+Text$+"*"+Chr$(15)
End If
End Def
'Demo starts here...
Width"LPT1:",32767 'set printer graphics width
Call Font39LandDownload 'download fonts to the HPLJ-II printer
Lprint Chr$(27);")1X"; 'select Code 39 as secondary font
Lprint Chr$(15); 'select characters from primary font
Lprint 'do a blank line
Lprint FNCode39$("THIS IS A TEST"); 'print some Code 39 stuff for test
Lprint 'do a blank line
Lprint"THIS IS A TEST" 'print some ASCII text for test
Lprint Chr$(12); 'eject the page