PDA

View Full Version : problem with EXECUTE_STRING


Harry
03-18-2004, 04:36 AM
I like to use a general macro to make a bitmap file. But I have a problem whith the bitmap_to_file command. its parameter RESOLUTION paper_to_pixels forces me to execute the variable.

Everything works fine exept that the background color isn't taken during generatnig the bitmap.

I am overlooking something...

Anyone a suggestion?




DEFINE make_bitmap
PARAMETER PAPER_SIZE
PARAMETER BITMAP_FILENAME
LOCAL BITMAP_RESOLUTION
LOCAL cmd_call

{Set resolution of bitmap}
LET BITMAP_RESOLUTION 100

{set background color}
CHANGE_VIEWPORT_COLOR white

{set all elements black on screen}
SCREEN_TRANSFORMATION ALL ALL ALL SAME BLACK

{make bitmap file}
LET cmd_call ('BITMAP_TO_FILE TIFF PORT CURRENT RESOLUTION Paper_to_pixels "' + PAPER_SIZE + '" ' + (STR BITMAP_RESOLUTION) + ' DEL_OLD "' + BITMAP_FILENAME + '"')

DISPLAY cmd_call

EXECUTE_STRING cmd_call

{reset screen settings}
SCREEN_TRANSFORMATION RESET

{reset background}
CHANGE_VIEWPORT_COLOR BLACK
END_DEFINE

make_bitmap 'A4' 'c:\temp\bitmap.tif'

H.annes
03-18-2004, 11:54 PM
good morning,

first of alll: why are you using EXECUTE_STRING? you can execute the command directly similar to this line:

BITMAP_TO_FILE TIFF PORT CURRENT RESOLUTION Paper_to_pixels Paper_size BITMAP_RESOLUTION DEL_OLD Bitmap_filename

If you want to use EXECUTE_STRING, try
EXECUTE_STRING IMMEDIATE Cmd_call

Hannes

Harry
03-21-2004, 11:32 PM
Originally posted by H.annes
...
you can execute the command directly similar to this line:

BITMAP_TO_FILE TIFF PORT CURRENT RESOLUTION Paper_to_pixels Paper_size BITMAP_RESOLUTION DEL_OLD Bitmap_filename
Hannes [/B]

Have you tried that line? It wil not work.
'paper_to_pixels' is a macro which has hard coded read command in it. :(

Have a look below


DEFINE Paper_to_pixels
LOCAL Width
LOCAL Height
LOCAL Paper_format
LOCAL Dpi
LOCAL Length
LOCAL Exit
INQ_ENV 6
LET Length (INQ 2)
LET Exit 0
LOOP
READ PNT STRING PROMPT (DGETTEXT 'me10mac'
"Enter paper format ('A0'-'A4', 'A'-'E') or paper size (width,height)")
Paper_format
IF (TYPE Paper_format=STRING)
LET Width (-1)
LET Height (-1)
IF (UPC Paper_format='A0')
LET Width 841
LET Height 1189
END_IF
IF (UPC Paper_format='A1')
LET Width 594
LET Height 841
END_IF
IF (UPC Paper_format='A2')
LET Width 420
LET Height 594
END_IF
IF (UPC Paper_format='A3')
LET Width 297
LET Height 420
END_IF
IF (UPC Paper_format='A4')
LET Width 210
LET Height 297
END_IF
IF (UPC Paper_format='A')
LET Width 216
LET Height 279
END_IF
IF (UPC Paper_format='B')
LET Width 279
LET Height 432
END_IF
IF (UPC Paper_format='C')
LET Width 432
LET Height 559
END_IF
IF (UPC Paper_format='D')
LET Width 559
LET Height 864
END_IF
IF (UPC Paper_format='E')
LET Width 864
LET Height 1118
END_IF
IF (Width=-1)
DISPLAY (DGETTEXT 'me10mac' '*** Unsupported paper format')
ELSE
LET Exit 1
END_IF
ELSE_IF (TYPE Paper_format=PNT)
LET Exit 2
END_IF
EXIT_IF (Exit)
END_LOOP
LOOP
READ NUMBER PROMPT (DGETTEXT 'me10mac' 'Enter dpi resolution') Dpi
EXIT_IF (Dpi>0)
DISPLAY (DGETTEXT 'me10mac' '*** Dpi resolution must be > 0')
END_LOOP
IF (Exit=1)
LET Width (ROUND ((Width/25.4)*Dpi))
LET Height (ROUND ((Height/25.4)*Dpi)) (PNT_XY Width Height)
ELSE_IF (Exit=2)
(ROUND ((Paper_format*Length/25.4)*Dpi))
END_IF
END_DEFINE

Thom Ivancso
03-22-2004, 10:04 AM
Hello Harry,

The reason that the background color is not taking when the image is created is because the following commands

{reset screen settings}
SCREEN_TRANSFORMATION RESET

{reset background}
CHANGE_VIEWPORT_COLOR BLACK

in your macro are being executed before the EXECUTE_STRING Cmd_call is being completed.

What you might want to do is use a menu to run this from. Giving the users the selections of paper size and output to use and then a button to reset the screen when it is completed (see image).

I created one and wrapped your code to it and it works. I will post this as well.

Cheers
Thom

Thom Ivancso
03-22-2004, 10:04 AM
Code as mentioned above.

Harry
03-22-2004, 11:27 PM
Thanks Thom,

This is just what I needed!

One question remains:

Is it possible to control the code flow?

I mean, can I ask for a return code to exam if execute_string is finished?

Best regards,

Harry