Bitstream Technologies, Inc.

This is the basic program giving to us to as a model of how to print barcodes on the Star Micronics Printer.

DEFINT A-Z
DIM CODEDATA(0 TO 9) AS STRING

CLS

Leader1$ = "1010"
Trailer$ = "11101"

CODEDATA(0) = "00110"
CODEDATA(1) = "10001"
CODEDATA(2) = "01001"
CODEDATA(3) = "11000"
CODEDATA(4) = "00101"
CODEDATA(5) = "10100"
CODEDATA(6) = "01100"
CODEDATA(7) = "00011"
CODEDATA(8) = "10010"
CODEDATA(9) = "01010"


Message$ = "11110100"

CodedMessage$ = Leader1$

FOR Ptr = 1 TO LEN(Message$) STEP 2
  MarkValue = VAL(MID$(Message$, Ptr, 1))
  SpaceValue = VAL(MID$(Message$, Ptr + 1, 1))
  FOR Ptr2 = 1 TO 5
    SELECT CASE MID$(CODEDATA(MarkValue), Ptr2, 1)
    CASE "0"
      CodedMessage$ = CodedMessage$ + "1"
    CASE "1"
      CodedMessage$ = CodedMessage$ + "111"
    END SELECT

    SELECT CASE MID$(CODEDATA(SpaceValue), Ptr2, 1)
    CASE "0"
      CodedMessage$ = CodedMessage$ + "0"
    CASE "1"
      CodedMessage$ = CodedMessage$ + "000"
    END SELECT
  NEXT Ptr2
NEXT Ptr
CodedMessage$ = CodedMessage$ + Trailer$

CodedMessage$ = CodedMessage$ + STRING$((8 - LEN(CodedMessage$) MOD 8), "0")
FillerMessage$ = STRING$(LEN(CodedMessage$), "0")
FOR Ptr = 1 TO LEN(CodedMessage$)
  IF MID$(CodedMessage$, Ptr, 3) = "111" THEN
    MID$(FillerMessage$, Ptr, 2) = "11"
  END IF
NEXT Ptr

OPEN "LPT1" FOR OUTPUT AS #1
PRINT #1, CHR$(15); CHR$(27); "y"; CHR$(16); STRING$(19, " "); Message$
PRINT #1, CHR$(18); CHR$(27); "J"; CHR$(36);

FOR Ptr = 1 TO LEN(CodedMessage$) STEP 8
  Pattern = 0
  Filler = 0
  FOR Bit = 0 TO 7
    CMBitVal = VAL(MID$(CodedMessage$, 7 - Bit + Ptr, 1))
    FMBitVal = VAL(MID$(FillerMessage$, 7 - Bit + Ptr, 1))
    Pattern = Pattern + 2 ^ Bit * CMBitVal
    Filler = Filler + 2 ^ Bit * FMBitVal
  NEXT Bit
  PRINT #1, CHR$(27); "y"; CHR$(1);
  PRINT #1, CHR$(13);
  PRINT #1, STRING$(13, 32);
  PRINT #1, CHR$(27); "L"; CHR$(64); CHR$(0); STRING$(64, Pattern);
  PRINT #1, CHR$(27); "J"; CHR$(0);
  PRINT #1, STRING$(13, 32);
  PRINT #1, CHR$(27); "L"; CHR$(63); CHR$(0); CHR$(0); STRING$(62, Pattern)

  PRINT #1, CHR$(27); "y"; CHR$(15);
  IF Filler THEN
    PRINT #1, CHR$(13);
    PRINT #1, STRING$(13, 32);
    PRINT #1, CHR$(27); "L"; CHR$(64); CHR$(0); STRING$(64, Filler);
    PRINT #1, CHR$(27); "J"; CHR$(0);
    PRINT #1, STRING$(13, 32);
    PRINT #1, CHR$(27); "L"; CHR$(63); CHR$(0); CHR$(0); STRING$(62, Filler);
  END IF
  PRINT #1, ""

NEXT Ptr
PRINT #1, CHR$(27); "J"; CHR$(92 + 72);
PRINT #1, CHR$(27); "z1"; CHR$(27); "d0";
CLOSE #1