Silverfrost Forums

Welcome to our forums

%cc exit from main window

30 Dec 2008 10:17 #4147

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

30 Dec 2008 11:57 #4148

Maybe just knowing how to suppress the error message would do. This only occurs when I'm exitting the program, after all ! I tried compiling the main routine with /HARDFAIL and that didn't help.

Eddie

30 Dec 2008 7:41 #4149

If you were to provide a simple main program I may be able to help. As it is I have not managed to reproduce the problem.

My guess is that you are accessing memory that has been released. As a quick test, try using /SAVE on the compile command line. If this works you will need to find out which variable needs the SAVE attribute and remove /SAVE from the command line.

1 Jan 2009 7:50 #4153

Paul, Your suggestion worked, thanks. I thought I didn't need SAVE in a program unit, and I can't find any non-COMMON variables in it. I never rely on values persisting across subprogram invocations (not knowingly) so have always regarded SAVE as a bit unnecessary.

Day 1 of 2009 and this old dog has learnt a new trick!

Eddie

2 Jan 2009 9:31 #4154

ClearWin+ uses addresses (for example in window_update@). It also uses the Windows message queue which (being a queue) can have a delayed response. It is conceivable that ClearWin+ might try to update the contents of an address after the associated subprogram has exited.

If your problem is reproducible and you can illustrate it in a small but complete program then you can post it here and we will see if we can get ClearWin+ to avoid the crash.

2 Jan 2009 3:03 #4158

I'll see if I can get it to happen in a small program, but I suspect that it only happens in complicated situations. I can only find 3 local variables in the main program. If they are all explicitly put into a SAVE statement, that doesn't help. A global SAVE does.

Eddie

Please login to reply.