I'm having a problem with exitting from a program. The main window has a %cc with a callback function EndExit_FUNCTION which gives an opportunity to cancel the exit or save data first. Here it is:
INTEGER FUNCTION EndExit_FUNCTION()
INCLUDE <WINDOWS.INS>
EXTERNAL File_FUNCTION
COMMON/GREYS/ MGR(10)
CHARACTER*(129) FILENM
COMMON /FILES/ FILENM
IF (MGR(3) .NE. 0 .OR. MGR(4) .NE. 0) THEN
EndExit_FUNCTION = 1
IA=WINIO@('%ca[Quit using Program XXX]&')
IA=WINIO@('%mi[ICON_2]&')
IA=WINIO@('%si? Do you want to save your data first? &')
IA=WINIO@('%ff%nl%cn%6^`bt[Yes] %6bt[No] %6bt[Cancel]',
& '+','FILE_OPENW',Filenm,FILE_FUNCTION,'EXIT')
IF (IA .EQ. 3) RETURN
ENDIF
EndExit_FUNCTION = 0
RETURN
END
Button 1 (Yes) launches the routine to save the current data (FILE_FUNCTION); Button 2 (No) sets the return code to 0, which closes the main window, whereas button 3 (Cancel) sets the return code to 1 so that the main window behaves as if nothing happened, and doesn't close.
Under certain circumstances in my rather large program, which are repeatable, exitting causes an error of the type: The instruction at 00401c01 attempted to write to location fffffedc in file ss.for at line 350, which is the last executable line in the main routine with
IA=WINIO@('%sf')
Most of the time, exit occurs as intended. The program has no other windows open.
The repeatable conditions occur when a particular toolbar button is selected (%tb) and the big graphics area in the main window accordingly displays a particular set of things. I've tried ending the main window WINIO@ sequence with different things, but to no avail. MGR(3) and (4) are both 1 when it works and when it doesn't - I've checked, even though the window in this routine wouldn't appear if neither was 1.
Am using FTN95 4.90
Has anyone any ideas?
Eddie