CHR 0 in string

Remco Koot

New Member
Hello all,

I am having a problem sending a chr(0) to an external procedure.
We are using Progress 8.3x (win32).

DEFINE VARIABLE res AS CHAR NO-UNDO.

res = chr(1) + chr(0) + chr(1).
display LENGTH(res). (Length is 2, the chr 0 is gone....)

I also tried to put it in a raw. See kbase article ID: P22290
Title: "How to pass a CHR(0) value to an OCX component" at Progress. But is does not work under 8.3 .
Get an error incompatible data types...

DEFINE VARIABLE v-mem AS MEMPTR NO-UNDO.
DEFINE VARIABLE v-raw AS RAW NO-UNDO.

SET-SIZE(v-mem) = 8.
PUT-STRING(v-mem,1) = chr(5) + chr(0) + chr(27) + "&l3O".
v-raw = v-mem.

So... what next?

The main goal is to send an escape sequence to the external procedure ESCAPE from the GDI32 library.
This is the only way I can send an escape code since we are using VSVIEW/VSPRINTER to print forms....

I hope this all make a bit sence, and you guys can help me out!

Thanks in advance!

Remco Koot
 
Great!
It works! Thanks a lot Simon!

For people using VSView and want to print an overlay (watermark) under their print-job... you can use this method.

PROCEDURE Escape EXTERNAL "gdi32".

DEFINE INPUT PARAMETER hdc AS LONG.
DEFINE INPUT PARAMETER nEscape AS LONG.
DEFINE INPUT PARAMETER cbinput AS LONG.
DEFINE INPUT PARAMETER lpszIndata AS MEMPTR. (!)
DEFINE OUTPUT PARAMETER Returnvalue AS LONG.

DEFINE VARIABLE v-mem AS MEMPTR.

SET-SIZE(v-mem)=10.

PUT-STRING(v-mem,1) = chr(10). /*length of escape code string */
PUT-BYTE(v-mem,2) = 0. /*important! */
PUT-STRING(v-mem,3) = chr(27) + "&f1y" + chr(27) + "&f4X".

run Escape(vp:hdc,19,0,v-mem, OUTPUT i_result).

/* 19 = PASSTHROUGH */

Just run it somewhere before you call the VsPrinter to print the job.

In the escape code &f1y stands for macro id, and &f4X to enable overlay.


Hope to make a few people happy with this additional info!

-Remco
 
Back
Top