Guidance
指路人
g.yi.org
software / rapidq / Examples / Graphics & Animation / barcode / barcode / I2of5 / I2OF5.INC

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
'--------------------------------------------------------------
'
' BARCODE CODE I 2 of 5
'
'--------------------------------------------------------------
     DECLARE FUNCTION I25 (TEKST AS STRING) AS STRING


     FUNCTION I25 (TEKST AS STRING) AS STRING
'--------------------------------------------------------------
' inizialize VAR`S

      DIM bcode(0 TO 9) AS STRING*5 ' ARRAY MET bitpatterns STRING`S
      DIM COMBI AS STRING
      DIM BITPAT AS STRING
      DIM BITPAT2 AS STRING
      DIM BARCODE AS STRING
      DIM ZWART AS STRING
      DIM WIT AS STRING
      DIM BAR AS STRING
      DIM CH1 AS STRING
      DIM CH2 AS STRING
      DIM BIT AS STRING
      DIM TMP AS STRING
'DIM I25 AS STRING

      DIM  LANG AS INTEGER
      DIM Q AS INTEGER
'--------------------------------------------------------------
'* PROGRAM CONSTANTS *

'
' TABEL KOMT VAN  http://www.barcodeisland.com

      BCode(0) = "NNWWN" '00
      BCode(1) = "WNNNW" '01
      BCode(2) = "NWNNW" '02
      BCode(3) = "WWNNN" '03
      BCode(4) = "NNWNW" '04
      BCode(5) = "WNWNN" '05
      BCode(6) = "NWWNN" '06
      BCode(7) = "NNNWW" '07
      BCode(8) = "WNNWN" '08
      BCode(9) = "NWNWN" '09


'--------------------------------------------------------------
'* MAIN PROGRAM CODE *
'
' barcode text, must be only numbers and have an even lenght

      LANG=LEN(TEKST)

      FOR Q=1 TO LANG STEP 2

       CH1=MID$(TEKST,Q,1)     ' odd number in a number pair
       CH2=MID$(TEKST,Q+1,1)   ' even number in a number pair

       ZWART=BCODE(ASC(CH1)-48)' odd numbers are encoded in the bars
       WIT=BCODE(ASC(CH2)-48)  ' even numbers are encoded in the spaces

'--------------------------------------------------------------
       COMBI=STRING$(10,32) ' combination string of width and narrow bars/spaces
       BITPAT=STRING$(20,32)' same as above but 2 as long and space between the W/N
       bar="1"  ' a black bar
       bitpat2="" ' the resulting 0/1 number pair string

        ' ON ODD POSTIONS THE BARS , odd numbers are encoded in the bars
       Y=1
       FOR X =1 TO 10 STEP 2
        BIT=MID$(ZWART,Y,1)
        COMBI= REPLACE$(COMBI,BIT, X)
        Y=Y+1
       NEXT X


        'ON EVEN POSITION THE SPACES, even numbers are encoded in the spaces
       Y=1
       FOR X =2 TO 10 STEP 2
        BIT=MID$(WIT,Y,1)
        COMBI= REPLACE$(COMBI,BIT, X)
        Y=Y+1
       NEXT X


        '  TRANSFORM W/N PATTERN IN A 0/1 BIT PATTERN
       Y=1
       FOR X =1 TO 10
        BIT=MID$(COMBI,X,1)
        BITPAT= REPLACE$(BITPAT,BIT,Y )
        Y=Y+2
       NEXT X

       FOR X =1 TO 20 STEP 2
        IF MID$(bitpat,X,1)="W" THEN BITPAT2=BITPAT2+BAR+BAR
        IF MID$(bitpat,X,1)="N" THEN BITPAT2=BITPAT2+bar

        SELECT CASE bar ' flips from bar`s to spaces like :bar-space-bar-space  ect.
        CASE "1"
         bar="0"
        CASE "0"
         bar="1"
        END SELECT

       NEXT X

       PAT=BITPAT2  ' resulting number pair in a 0/1 bar/space pattern
'--------------------------------------------------------------

       TMP=BITPAT2      ' temp string
       BARCODE=BARCODE+TMP     ' all the encoded 0/1 number pair`s

      NEXT q

      I25="1010"+BARCODE+"1101"   ' start+ all number pair`s + stop



     END FUNCTION

'--------------------------------------------------------------
'
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Tue 2024-7-23  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2001-06-13 19:43:42