jsbasic/samples/sample.codabar.txt
2022-10-23 15:04:43 -07:00

84 lines
3.1 KiB
Plaintext

1 REM CODABAR BARCODE GENERATOR BY GOLDEN CHILD
2 REM ALL INFO NEEDED FROM WIKIPEDIA ARTICLE ON CODABAR
3 TEXT : HOME
4 PRINT "CODABAR GENERATOR" : ?
5 PRINT "LEGAL CHARACTERS ARE: "
6 PRINT " 0123456789 ./+-$: ABCD" : ?
7 PRINT " BEGIN AND END WITH ABCD STOP CODES" : ?
8 PRINT " ADD # AS FIRST CHAR FOR CHECK DIGIT" : ?
9 PRINT "EXAMPLES: A1234A A5678B" : ? " #A1234A (WITH CHECK DIGIT)":?
10 DIM HB$(4),HS$(6)
20 DIM CB(128),CS(128),CK(128)
100 FOR I = 1 TO 4 : READ HB$(I) : NEXT : REM HORIZ BAR PATTERN
105 FOR I = 1 TO 4 : READ IB$(I) : NEXT : REM INVERT BAR PATTERN
110 FOR I = 1 TO 6 : READ HS$(I) : NEXT : REM HORIZ SPACE PATTERN
120 READ CH$ : IF CH$ = "END" THEN GOTO 150
130 C = ASC(CH$) : READ CB(C),CS(C),CK(C)
140 GOTO 120
150 REM DONE READING
160 FOR I = 1 TO 128
165 REM IF CB(I)<>0 OR CS(I) <> 0 THEN PRINT CHR$(I),CB(I),CS(I)
170 NEXT
176 X0 = 20 : X=X0 : Y0 = 5 : Y=Y0 : Y1=20 : Y2 = 20
180 W0 = 1 : REM DEFAULT WIDTH
200 PRINT " (# FOR CHECK DIGIT, USE | FOR :)":INPUT "BARCODE:";A$ : CS = 0
205 IF MID$(A$,1,1)<>"#" THEN GOTO 210 : REM SKIP CHECKSUM
206 A$=MID$(A$,2,LEN(A$)-1) : FOR I = 1 TO LEN(A$) : C = ASC(MID$(A$,I,1)) : ? "CHAR="C" CHECKSUM="CS : CS=CS+CK(C) : NEXT
207 IF CS > 16 THEN CS = CS - 16 : GOTO 207
208 A$ = MID$(A$,1,LEN(A$)-1) + MID$("0123456789-$:/.+",(16-CS)+1,1) + MID$(A$,LEN(A$),1) : REM ADD CHECKSUM DIGIT JUST BEFORE END
210 F$ = MID$(A$,1,1) : IF F$ <> "A" AND F$ <> "B" AND F$ <> "C" AND F$ <> "D" THEN PRINT "NEED START CODES (ABCD)" : GOTO 200
211 F$ = MID$(A$,LEN(A$),1) : IF F$ <> "A" AND F$ <> "B" AND F$ <> "C" AND F$ <> "D" THEN PRINT "NEED END CODES (ABCD)" : GOTO 200
215 IF SF=0 THEN HGR: HCOLOR=3 : FOR I = 0 TO 191 : HPLOT 0,I TO 279,I : NEXT : SF=1 : VTAB 23
216 FOR I = 1 TO LEN(A$) : C = ASC(MID$(A$,I,1)) : ? "CHAR="C
220 B = CB(C) : S = CS(C) : REM B=BAR TYPE, SPACE= SPACE TYPE
230 FOR BI = 1 TO 4
235 W = W0 : BA$ = HB$(B) : IF HS$(S)="0000" THEN BA$=IB$(B) : REM IB IS INVERT BARCODE PATTERN
240 IF MID$(BA$,BI,1)="1" THEN W = W0 * 3
250 X1 = X : X2 = X1 + W : FOR X = X1 TO X2-1 : HCOLOR=0: HPLOT X,Y TO X,Y+Y1 : NEXT : X = X2
260 W = W0 : IF MID$(HS$(S),BI,1)="1" THEN W = W0 * 3
270 X = X + W
280 NEXT
290 NEXT
300 ? "BARCODE="A$
350 X=X0 : Y=Y+Y1+Y2
360 IF Y > 160-Y2 THEN SF=0 : Y=Y0 : REM CHECK TO SEE IF WE ARE AT BOTTOM
400 GOTO 200
2000 REM BAR PATTERN DATA
2001 DATA 0001,0010,0100,1000
2002 REM INVERT BAR PATTERN DATA FOR WHEN SPACES = 0000
2003 DATA 1110,1101,1011,0111
2009 REM SPACE PATTERN DATA
2010 DATA 0010,0100,1000,0110,1100,0000
2020 DATA 0,1,1,0 : REM CHAR 0 IS BAR 1 SPACE 1 CHECKSUM 0
2021 DATA 1,2,1,1 : REM CHAR 1 IS BAR 2 SPACE 1 CHECKSUM 1
2022 DATA 4,3,1,4
2023 DATA 5,4,1,5
2024 DATA 2,1,2,2
2025 DATA -,2,2,10
2026 DATA "$",3,2,11
2027 DATA 9,4,2,9
2028 DATA 6,1,3,6
2029 DATA 7,2,3,7
2030 DATA 8,3,3,8
2031 DATA 3,4,3,3
2032 DATA C,1,4,18
2033 DATA D,2,4,19
2034 DATA A,3,4,16
2035 DATA F,4,4,17 : REM EFGH IS ABCD REVERSE
2036 DATA B,1,5,17
2037 DATA E,2,5,16
2038 DATA H,3,5,19
2039 DATA G,4,5,18
2040 DATA ".",1,6,14
2041 DATA /,2,6,13
2042 DATA ":",3,6,12
2043 DATA +,4,6,15
2044 DATA "|",3,6,12 : REM APPLESOFT DOESN'T LET YOU TYPE COLONS
2050 DATA END