Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to concatenate a blob containing 00 (hexa) to a string?

148 views
Skip to first unread message

Szabó Márió

unread,
Jul 22, 2008, 3:48:19 AM7/22/08
to
Hi!


I would like to print to a Zebra TLP2844 barcode printer texts and images
too from PB.
Zebra has own language: EPL2. I have to create a special string, which is
OK,
I know the control codes and letters, so I can handle it.
But I have to concatenate/add an image as a string or something else at a
given position if i want to print a logo.
I have the image in blob, or in char array too, but I don't know how to add
an image or blob or characters to a string variable
The main problem is: image/blob contains 0 characters, and if I try to add
it to a string variable, then this will the end of the string.

A part of the string can be:

[...]
s_text += "R136,0"
s_text += "N"
s_text += "GW50,50,14,112, __raw data is needed here continuously___ "
s_text += "P1"


Image in hexa can be: 0A 10 01 01 00 00 FF FF 00 00 6C......... in
s_data[]


I can't do this:

s_text += Char( s_data[i] ) -- incompatible types in assignment:
character, string
or this:
s_text += String( s_data[i] ) -- because s_data[5] will terminate
the string.


Thanks in advance,
Mario


Bruce Armstrong [TeamSybase]

unread,
Jul 22, 2008, 8:50:25 AM7/22/08
to

Use a blob variable, and then concatenate to the blob or use BlobEdit
to build it up. The Blob method can be used to covert a string or
char array directly to a blob to be added to your variable.

On 22 Jul 2008 00:48:19 -0700, "Szabó Márió" <szabo...@hungexpo.hu>
wrote:

mason

unread,
Jul 22, 2008, 9:30:08 AM7/22/08
to
I used to convert static images to GRF files using a Zebra tool, and this
image name can be embedded in Zebra language(s). You dynamically create a
text file with EPL2 syntax, and copy it to PRN to print labels. If EPL
allows you to embed hex strings, you can convert a blob to a hex string and
put the string in the file. Here are two functions to do the conversion
(PB10/11 based).

//////////////////////////////////////////////////////////////
//
// Function string of_blob2hex(blob ablb)
//
// Description: convert a blob to a hex string
//
// Argument: ablb - blob to convert
//
// Return: a hex string
//
//////////////////////////////////////////////////////////////
string ls
long ll
byte lb

for ll=Len(ablb) to 1 step -1
GetByte(ablb,ll,lb)
ls=of_byte2hex(lb)+ls
next

RETURN ls


//////////////////////////////////////////////////////////////
//
// Function string of_byte2hex(byte ab)
//
// Description: convert a byte value to a hex string
//
// Argument: ab - byte value to convert
//
// Return: a hex string (1 byte)
//
//////////////////////////////////////////////////////////////
string ls[0 to
15]={"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"}

if IsNull(ab) then RETURN ""

if ab=0 then
RETURN "00"
elseif ab=255 then
RETURN "FF"
elseif ab<16 then
RETURN "0"+ls[ab]
else
RETURN ls[Int(ab/16)]+ls[Mod(ab,16)]
end if


"Szab¨® M¨¢ri¨®" <szabo...@hungexpo.hu> wrote in message
news:488590c3@forums-1-dub...

Bruce Armstrong [TeamSybase]

unread,
Jul 24, 2008, 11:00:38 AM7/24/08
to
A null is a terminating character for a string, there's no way to include it
in a string. You might want to use a char array instead, which can hold a
null character. How are you sending the data to the printer?

"Szabó Márió" <szabo...@hungexpo.hu> wrote in message
news:48889308$1@forums-1-dub...
> Hi!
>
>
> Unfortunatelly I have to build a string type variable not a blob, because
> the printer can receive only string type rows.
> So I have to convert the blob to string.
>
> I used the Blobmid to get an individual byte, but I can't convert a hexa
> 00
> to string.
>
> Any ideas?
>
> Thanks,
> Mario
>
>
> "Bruce Armstrong [TeamSybase]" <NOCANSPAM_br...@teamsybase.com>
> az alábbiakat írta a következo hírüzenetben:
> 5plb849qj9dao9f4h...@4ax.com...

Szabó Márió

unread,
Jul 24, 2008, 10:34:48 AM7/24/08
to
Hi!


Unfortunatelly I have to build a string type variable not a blob, because
the printer can receive only string type rows.
So I have to convert the blob to string.

I used the Blobmid to get an individual byte, but I can't convert a hexa 00
to string.

Any ideas?

Thanks,
Mario


"Bruce Armstrong [TeamSybase]" <NOCANSPAM_br...@teamsybase.com> az
alábbiakat írta a következo hírüzenetben:
5plb849qj9dao9f4h...@4ax.com...
>

Szabó Márió

unread,
Jul 24, 2008, 11:30:05 AM7/24/08
to
Hi!


I use these functions:

l_ret = PrintSetPrinter (p_printerv)
long Job
// Open a print job.
Job = PrintOpen()
PrintSend( Job, s_text )
PrintClose( Job )

where s_text can be the string which is needed for the printer (for example)


s_text += "R136,0"
s_text += "N"
s_text += "GW50,50,14,112, __raw data is needed here continuously___
"
s_text += "P1"

I tried to separate the core printer control rows and the data also
The control rows with the mentioned method: PrintSend( Job, s_text )
The data was sent in hexa also with PrintSend( Job, s_text ) in a separate
block.
It didn't work. :-(


Thanks,
Mario


"Bruce Armstrong [TeamSybase]" <NOCANSPAM_br...@teamsybase.com> az

alábbiakat írta a következő hírüzenetben: 48889916$1@forums-1-dub...

Bruce Armstrong [TeamSybase]

unread,
Jul 24, 2008, 12:21:34 PM7/24/08
to
Look at the help for the PrintSend function. It has an optional third
argument you use to indicate that you want to pass a null character. So you
send some other character instead, perhaps the pipeline character ( "|" )
instead of the null in the string, and then pass the pipeline character as
the third character so that PB replaces the pipeline character with a null.

It's actually explained fairly clearly in the Usage section of the help:

"As with any string, the number zero terminates the string argument. If the
printer code you want to send includes a zero, you can use another character
for zero in string and specify the character that represents zero in
zerochar. The character you select should be a character you do not usually
use. When PowerBuilder sends the string to the printer it converts the
substitute character to a zero."


"Szabó Márió" <szabo...@hungexpo.hu> wrote in message

news:48889ffd@forums-1-dub...

0 new messages