Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.
29306 Discussions

setwindowconfig leads to divide by zero error; multiple tries don't fix.

john_levi_lmartin
811 Views
Hi, so I've been struggling with what seems to be a general documented bug in SETWINDOWCONFIG, but I've never seen this particular version. It began with getting a "integer divide by zero" deep in a subroutine called by SETWINDOWCONFIG. This alerted me to the fact that, despite the documentation, doing a SECOND or THIRD call to SETWINDOWCONFIG after a first failure didn't fix things. In fact, I found that it can be called 100 times without anything changing.

Now the biggest puzzle is that when I am debugging this under Microsoft Visual Studio, I still get the FALSE reply for the call, but if I bravely go on, nothing terrible happens. But when the program is run by itself, this leads to the screen disappearing (the window is infinitely small)--for some reason, I no longer get the 'divide by zero' problem, though this also only happened out of the debugger.

Does this make any sense to anyone?

Thanks!
-john

the basic code in this subroutine is...
USE IFQWIN

Real*8 version
INTEGER*2 dummy, fails
LOGICAL STATUS, WAITFOR, ERROR
CHARACTER*9 namever
CHARACTER*4 Name
TYPE (windowconfig) wc

IF(WAITFOR) THEN
READ (*,'(A)') namever
ENDIF
fails = 0
wc%numtextrows=-1
wc%numtextcols=-1
wc%mode = QWIN$SCROLLDOWN
namever(1:4)=Name
Namever(5:5)=' '
Write(namever(6:9),'(F4.2)') version
wc%title=namever

STATUS=SETWINDOWCONFIG(wc)
DO WHILE (.NOT. STATUS)
Write(1,*)'At least one setwindowconfig failure....'
fails = fails + 1
IF (fails.GT.99) THEN
CALL ERRMESS(249, ERROR)
EXIT
END IF
STATUS=Setwindowconfig(wc)
END DO
IF (.NOT. ERROR) dummy=DISPLAYCURSOR($gcursoron)
RETURN
END
0 Kudos
1 Reply
Lorri_M_Intel
Employee
811 Views
The one thing that I noticed is that the title needs to be a C string.

That is, it must be null terminated, and yours is not.

Try making namever 10 characters long, and setting the final character as a zero.
You can do this with
namever(10:10) = char(0)


-- Lorri
0 Kudos
Reply