View previous topic :: View next topic |
Author |
Message |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Tue Dec 30, 2008 11:17 am Post subject: %cc exit from main window |
|
|
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:
Code: | 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
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 |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Tue Dec 30, 2008 12:57 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Tue Dec 30, 2008 8:41 pm Post subject: |
|
|
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. |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Thu Jan 01, 2009 8:50 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Fri Jan 02, 2009 10:31 am Post subject: |
|
|
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. |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Fri Jan 02, 2009 4:03 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
|