Chuck Miller:

> The only problem is creation of of bar code. I think hmbar code does all 
> types (128 etc) which are harder to do programmatically.  When I tried, I was 
> able to get 128 working on a Mac or a PC but not both. The coding seems to 
> have been slightly different

If you need a "Code 39" barcode then you can use the following method.
I adapted it out of a component by Thomas Maul and made it standalone.
It returns a picure that you can place on a form to print.

C_TEXT($1;$tCode)
C_LONGINT($2;$lScale)
C_PICTURE($0)
C_TEXT($tPattern;$t;$tSVG;$tLine;$tPoints;$tRef)
C_LONGINT($i;$x;$x2;$y;$y2;$lCount;$lHeight;$lWidth;$lBarwidth;$lScale)

$tCode:=$1
If (Count parameters>1)
        $lScale:=$2
Else 
        $lScale:=1
End if 

If ($Tcode#"*@")
        $tcode:="*"+$tcode
End if 
If ($tcode#"@*")
        $tcode:=$tcode+"*"
End if 
If (Length($tcode)>32)
        g4D_AlertErr ("Code zu lang!")
End if 

$tPattern:=""
For ($i;1;Length($tCode))
        $t:=$tCode[[$i]]
        Case of 
                : ($t="*")
                        $tPattern:=$tPattern+"1001011011010"
                : ($t="0")
                        $tPattern:=$tPattern+"1010011011010"
                : ($t="1")
                        $tPattern:=$tPattern+"1101001010110"
                : ($t="2")
                        $tPattern:=$tPattern+"1011001010110"
                : ($t="3")
                        $tPattern:=$tPattern+"1101100101010"
                : ($t="4")
                        $tPattern:=$tPattern+"1010011010110"
                : ($t="5")
                        $tPattern:=$tPattern+"1101001101010"
                : ($t="6")
                        $tPattern:=$tPattern+"1011001101010"
                : ($t="7")
                        $tPattern:=$tPattern+"1010010110110"
                : ($t="8")
                        $tPattern:=$tPattern+"1101001011010"
                : ($t="9")
                        $tPattern:=$tPattern+"1011001011010"
                : ($t="A")
                        $tPattern:=$tPattern+"1101010010110"
                : ($t="B")
                        $tPattern:=$tPattern+"1011010010110"
                : ($t="C")
                        $tPattern:=$tPattern+"1101101001010"
                : ($t="D")
                        $tPattern:=$tPattern+"1010110010110"
                : ($t="E")
                        $tPattern:=$tPattern+"1101011001010"
                : ($t="F")
                        $tPattern:=$tPattern+"1011011001010"
                : ($t="G")
                        $tPattern:=$tPattern+"1010100110110"
                : ($t="H")
                        $tPattern:=$tPattern+"1101010011010"
                : ($t="I")
                        $tPattern:=$tPattern+"1011010011010"
                : ($t="J")
                        $tPattern:=$tPattern+"1010110011010"
                : ($t="K")
                        $tPattern:=$tPattern+"1101010100110"
                : ($t="L")
                        $tPattern:=$tPattern+"1011010100110"
                : ($t="M")
                        $tPattern:=$tPattern+"1101101010010"
                : ($t="N")
                        $tPattern:=$tPattern+"1010110100110"
                : ($t="O")
                        $tPattern:=$tPattern+"1101011010010"
                : ($t="P")
                        $tPattern:=$tPattern+"1011011010010"
                : ($t="Q")
                        $tPattern:=$tPattern+"1010101100110"
                : ($t="R")
                        $tPattern:=$tPattern+"1101010110010"
                : ($t="S")
                        $tPattern:=$tPattern+"1011010110010"
                : ($t="T")
                        $tPattern:=$tPattern+"1010110110010"
                : ($t="U")
                        $tPattern:=$tPattern+"1100101010110"
                : ($t="V")
                        $tPattern:=$tPattern+"1001101010110"
                : ($t="W")
                        $tPattern:=$tPattern+"1100110101010"
                : ($t="X")
                        $tPattern:=$tPattern+"1001011010110"
                : ($t="Y")
                        $tPattern:=$tPattern+"1100101101010"
                : ($t="Z")
                        $tPattern:=$tPattern+"1001101101010"
                : ($t="-")
                        $tPattern:=$tPattern+"1001010110110"
                : ($t=".")
                        $tPattern:=$tPattern+"1100101011010"
                : ($t=" ")
                        $tPattern:=$tPattern+"1001101011010"
                : ($t="$")
                        $tPattern:=$tPattern+"1001001001010"
                : ($t="/")
                        $tPattern:=$tPattern+"1001001010010"
                : ($t="+")
                        $tPattern:=$tPattern+"1001010010010"
                : ($t="%")
                        $tPattern:=$tPattern+"1010010010010"
                Else 
                        g4D_AlertErrCaseOf (Current method name)
        End case 
End for 

$tSVG:=DOM Create XML Ref("svg";"http://www.w3.org/2000/svg";)
$lHeight:%
$lWidth:=1*$lScale
$x:=1
$y:=1
$i:=1
$tpattern:=$tpattern+"X"  // end of code, to make looping easier
While ($i<Length($tPattern))
        $lCount:=0
        $tLine:=$tPattern[[$i]]
          // check if similar are following
        While ($tline=$tpattern[[$i+1]])  // we cannot go longer than the 
string, thanks to "X"
                $lcount:=$lcount+1
                $i:=$i+1
        End while 
        If ($tLine="1")
                $y2:=$y+$lHeight
                $lBarwidth:=($lCount+1)*$lWidth
                $x2:=$x+$lBarwidth
                $tPoints:=String($x)+","+String($y)+" 
"+String($x)+","+String($y2)+" "+String($x2)+","+String($y2)+" 
"+String($x2)+","+String($y)
                $tRef:=DOM Create XML 
element($tsvg;"polygon";"style";"fill:black";"points";$tPoints)
        Else   //$tLine=0 // White, don't draw 
                $x2:=$x+($lcount*$lWidth)+$lWidth
        End if 
        $x:=$x2
        $i:=$i+1
End while 

SVG EXPORT TO PICTURE($tSVG;$0;Copy XML data source)
DOM CLOSE XML($tSVG)
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to