Focal Point
How to change image dimensions dynamically on each page

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/4861076661

May 05, 2006, 01:53 PM
jodye
How to change image dimensions dynamically on each page
Hi Guys

We are trying to do something strange. Basically we want to draw boxes around certain parts of data.

Please consider the following code... divider2.gif is a simple grey box that is 8x6 pixels.

TABLE FILE CAR
SUM
CNT.SALES
BY COUNTRY
SUM SALES
BY COUNTRY PAGE-BREAK
BY MODEL
ON TABLE PCHOLD FORMAT PDF
ON TABLE SET STYLE *
-*VERTICAL LINES
TYPE=REPORT, IMAGE=/mypath/to/divider2.gif, POSITION=(2.0 0.8), SIZE=(0.04 1.24), $
TYPE=REPORT, IMAGE=/mypath/to/divider2.gif, POSITION=(4.5 0.8), SIZE=(0.04 1.24), $
-*HORIZONTAL LINES
TYPE=REPORT, IMAGE=/mypath/to/divider2.gif, POSITION=(2.0 0.8), SIZE=(2.5 0.04), $
TYPE=REPORT, IMAGE=/mypath/to/divider2.gif, POSITION=(2.0 2.0), SIZE=(2.5 0.04), $
ENDSTYLE
END

I wish I could upload the resulting pdf. Anyway, there is a box being drawn around the models.

The problem is that we need to change the size of the box on each page. If you could scroll through the 5 pages of the generated pdf you would see that the box is too big on pages 2 and 4, and the box is too small on page 5.

So we need to dynamically change the SIZE of the image on each page based on the value of CNT.SALES.

I have been messing around with this for awhile and I can't figure a way to make it work.

The resulting code would look something like...

-SET &YVAL=(a variable representing the value of CNT.SALES)/SOMEVALUE;

TYPE=REPORT, IMAGE=/mypath/to/divider2.gif, POSITION=(2.0 0.8), SIZE=(0.04 &YVAL), $

With &YVAL dynamically changing on each page of the pdf.

So I guess the bottom line of this question is how can we get the value of CNT.SALES into an amper variable that changes on each page? I am thinking that we might need to loop through

Any ideas would be most welcome.

Thanks

Jodye


WF 8.0.0.5M
May 05, 2006, 01:57 PM
jodye
I have been thinking about this... and I came up with the following ... which does work. However I discovered something unbelievable, DM variables must be alpha or int but cannot be decimals. So this won't really work, since I need the size to be specified with 2 decimals.

Anyway this code does work and produces an image that has a varying length on each page. But without decimals its a no go.

Jodye

SET ASNAMES=ON
SET HOLDLIST=PRINTONLY
TABLE FILE CAR
SUM
COMPUTE MYCOUNT/D6=CNT.SALES; NOPRINT
COMPUTE MYCOUNTA/A8=FTOA(MYCOUNT, '(D6)', 'A8');
BY COUNTRY
ON TABLE HOLD AS MYHOLD FORMAT ALPHA
END
-SET &MYRECS=&LINES;

-*READ THE DATA INTO A LOOP
-RUN
-SET &I=0;
-STRT_READ
-SET &I=&I+1;
-READ MYHOLD &MYCOUNTRY.&I.A10. &MYCOUNT.&I.A8.

-TYPE PAGE &I WILL HAVE &MYCOUNT.&I RECORDS
-SET &OPENCLOSE=IF &I EQ &MYRECS THEN 'CLOSE' ELSE 'OPEN';

-SET &CUR=&MYCOUNT.&I;
-SET &LENGTH= &MYCOUNT.&I * 1;

-SET &YPOS=1.8;

TABLE FILE CAR
SUM SALES
BY COUNTRY
BY MODEL
HEADING
"THERE WILL BE &MYCOUNT.&I RECORDS"
WHERE COUNTRY EQ '&MYCOUNTRY.&I';
ON TABLE PCHOLD FORMAT PDF &OPENCLOSE
ON TABLE SET STYLE *
-*VERTICAL LINES
TYPE=REPORT, IMAGE=/mypath/divider2.gif, POSITION=(1.4 0.8), SIZE=(0.04 &LENGTH), $
TYPE=REPORT, IMAGE=/mypath/divider2.gif, POSITION=(3.9 0.8), SIZE=(0.04 &LENGTH), $
-*HORIZONTAL LINES
TYPE=REPORT, IMAGE=/home/IBI/ibi/apps/divider2.gif, POSITION=(1.4 0.8), SIZE=(2.5 0.04), $
TYPE=REPORT, IMAGE=/home/IBI/ibi/apps/divider2.gif, POSITION=(1.4 &YPOS), SIZE=(2.5 0.04), $
ENDSTYLE
END


-IF &I LT &MYRECS THEN GOTO STRT_READ;


WF 8.0.0.5M
May 08, 2006, 12:42 AM
susannah
jodye
i like your idea
how about this: do no math in DM, do it all in your preparation fex;
Calculate the complete final value you'll need as a D6.2
the hold the temp file FORMAT ALPHA like you did
but without the FTOA
then -READ it as .A6 or however long it has to be (better test)
and the value for &LENGTH or for &POS , if it were, for example, 0.04 ,
will be handled as an alpha field by dm
Then when you plop it into your fex, the fex will interpret it as a number.

i don't even think you'll need a .EVAL. I always follow my &VARS by a blank space , tho
&LENGTH) i would write as &LENGTH )

This message has been edited. Last edited by: susannah,




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
May 08, 2006, 12:02 PM
jodye
Hi Susannah

That is a great idea... maybe I would have thought of it eventually ;-)

Thanks I will let you know how it turns out.


WF 8.0.0.5M