Silverfrost Forums

Welcome to our forums

DRAW_CHARACTERS@ in a block IF causing crash?

14 Dec 2006 12:00 #1442

I'm doing graphics to a graphics object on screen, and (sometimes) to a printer graphics object. The program baulks at something which is hard to describe. The graphics have 2 lines of text. The position on screen for this text is different for the hard copy than it is on the screen. If I write the two text lines with:

   IIY = 25
   IJY = 45
   CALL DRAW_CHARACTERS@(TITLE2,10,IIY,RGB@(0,0,0))
   CALL DRAW_CHARACTERS@(TITLE1,10,IJY,RGB@(0,0,0))

(TITLE1 and TITLE2 being 80-character strings)

then the text is drawn, although it isn't where I want it on the hard copy. So, I pass a variable to the subprogram (that draws the particular graphics) which is named NDEV that is 1 for hard copy, and 0 for screen graphics. At several points in the subprogram, I check on NDEV, and do such things as adjusting line thicknesses etc. I then try to use NDEV as follows:

   IF (NDEV .EQ. 0) THEN
   IIY = 25
   IJY = 45
   CALL DRAW_CHARACTERS@(TITLE2,10,IIY,RGB@(0,0,0))
   CALL DRAW_CHARACTERS@(TITLE1,10,IJY,RGB@(0,0,0))
   ELSE
   IIY = 25
   IJY = 45
   CALL DRAW_CHARACTERS@(TITLE2,10,IIY,RGB@(0,0,0))
   CALL DRAW_CHARACTERS@(TITLE1,10,IJY,RGB@(0,0,0))
   ENDIF

Notice that the coordinates are the same. Obviously, I want IIY and IJY to be different, but I have cut and pasted identical FORTRAN in here, so that whichever route is taken the same sequence occurs. This code causes the program to crash - in my standard WinXP I get the 'chord' sound and all the windows close instantly. But when I revert to no IF, it works - no crash. Bizarrely, when NDEV=0, the graphics come up on screen faultlessly.

Anyone know what I'm doing that causes this odd behaviour?

Eddie

14 Dec 2006 12:08 #1443

... and I forgot to say ...

If I do the DRAW_CHARACTERS@ OUTSIDE the block IF, it works, as in:

   IF (NDEV .EQ. 0) THEN
   CALL SCALE_FONT@(1.0D0)
   IIY = 25
   IJY = 45
   ELSE
   CALL SCALE_FONT@(8.0D0*HSCALE)
   IIY = 95*IYRES/100
   IJY = 90*IYRES/100
   ENDIF

   CALL DRAW_CHARACTERS@(TITLE2,10,IIY,RGB@(0,0,0))
   CALL DRAW_CHARACTERS@(TITLE1,10,IJY,RGB@(0,0,0))

(slightly more complex than my earlier (simplified) code).

It has taken me a lot of head-scratching to work out the problem, as it seemed to me that my FORTRAN was valid.

Eddie

14 Dec 2006 7:09 #1445

I cannot see anything wrong with this. If you can post a fully 'working' program then I will run some tests on it.

Please login to reply.