forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Confirm_exit

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
DanRRight



Joined: 10 Mar 2008
Posts: 2816
Location: South Pole, Antarctica

PostPosted: Sat Sep 18, 2010 5:53 am    Post subject: Confirm_exit Reply with quote

When i exit the code with Esc or Alt+x or other ways, to close all running processes, files and windows i do final closures which do a lot and lot of different things with the commands like this

Code:

       i = winio@('%ac[Alt+X]&',
     *  '+','SET', kFrwdial_SettingsRd_D01, 1,
     *  '+','SET', k_Brahms_GoPauseStop012, 2,
     *  '+', Save_Code_Settings,
     *  '+', Close_AllCode_Files,
     *  '+', BringInitialTextWindowToTheTop,
     *  'exit' )


But ideal would be to have the functionality of "confirm_exit" which asks you before if you really want to close window ( or do that by mistake ). So when you click Alt+X/Esc for example the window will ask you this question, and then if you say "YES" it will do all the final SETs before the exit above and do the exit itself. But if you say NO - no action will be performed.

Any ideas how to make that functionality?
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7924
Location: Salford, UK

PostPosted: Sat Sep 18, 2010 7:21 am    Post subject: Reply with quote

Does %cc do what you want?
Back to top
View user's profile Send private message AIM Address
DanRRight



Joined: 10 Mar 2008
Posts: 2816
Location: South Pole, Antarctica

PostPosted: Sat Sep 18, 2010 10:56 am    Post subject: Reply with quote

Thanks for one more (already uncountable) good suggestion, Paul. I suppose you mean %`cc? Most probably that's what does the trick, will doublecheck, because making search over my older codes i see that I've used %cc in numerous cases 10 years ago but by some reason stopped. Is %`cc a newer addition?
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Sat Sep 18, 2010 8:08 pm    Post subject: Reply with quote

Hi Dan,

I stumbled over this too. The answer is that 'Exit' is for a REALLY quick hack, and 'Confirm_Exit' is for a nearly as quick hack. For real work, you have to do it yourself.

The problem is that there are several ways to close a window, including the File / Exit route, the close box on the window, Exit Windows, Alt-F4 etc. They can't all be 'Exit'. If in addition you use %cc, you have to think carefully or you get asked twice, or not at all, whether you want to save the file befoe exitting.

I do this in the main window:

Code:
       IA = WINIO@('%cc&', EndExit_FUNCTION)
       IA = WINIO@('%ew&', EndExit_FUNCTION)
       IA = WINIO@('%mn[[|,E&xit]]&',                EndExit_FUNCTION)


The End_Exit function looks like this:

Code:
      INTEGER FUNCTION EndExit_FUNCTION()
C      -----------------------------------
C
C      call back function for CLOSE. Clears graphics area, and re-sets
C      permission to OPEN file or have NEW file
C
C      -----------------------------------------------------------------
       INCLUDE <WINDOWS.INS>
       EXTERNAL       File_FUNCTION

       COMMON/GREYS/  IGR(10),JGR(10),KGR(10),LGR(10),MGR(10),NGR(10)
C                                                                      .
       CHARACTER*(129)      FILENM
       COMMON  /FILES/      FILENM

       CHARACTER*(129)      PATH(4)
       COMMON/PATHS/        PATH

       CHARACTER*(20)       FLTN(2), FLTS(2), CAPT
       SAVE
       INTEGER File_FUNCTION
       COMMON/EXITCODE/     INHIBIT_EXIT
C      ... second pass through this function? Always quit.
       EndExit_FUNCTION = 1
       IF (INHIBIT_EXIT .EQ. 0) THEN
           EndExit_FUNCTION = 0
           RETURN
           ENDIF
C      ... anything worth saving? I this case give option to save.
       IF (MGR(3) .NE. 0 .OR. MGR(4) .NE. 0) THEN
       IA=WINIO@('%ca[Quit using Program]&')
       IA=WINIO@('%si?   Do you want to save your data first?   &')
       IA=WINIO@('%ff%nl%cn%6`bt[Yes]     %6bt[No]     %6bt[Cancel]')
C      ... Cancelled or Close box - return, keeping main window open
       IF (IA .EQ. 0  .OR.  IA .EQ. 3) RETURN
C      ... Don't save. In this case go on to exit. Be aware that this
C          could lead to a second pass through this callback function
       IF (IA. EQ. 2) THEN
           EndExit_FUNCTION = 0
           RETURN
           ENDIF
C      ... Save file - at least, give the option to save. User can still
C          decide not to save. This can't be done with callback on the
C          button.  Be aware that this
C          could lead to a second pass through this callback function
       IF (IA .EQ. 1) THEN
            CAPT = 'File to save to'
            FLTN(1) = 'WSX files'
            FLTN(1) = 'All files'
            FLTS(1) = '*.wsx'
            FLTS(2) = '*.*'
            CALL GET_FILTERED_FILE@ (CAPT,FILEnm,PATH(1),FLTN,FLTS,2,0)
            CALL CORRECT_NAME(FILEnm,'.wsx')
            IJ = File_FUNCTION()                ! This is in this file
            INHIBIT_EXIT = 0
            ENDIF
       EndExit_FUNCTION = 0

C      ... If the user closes a window without a current file, we need 
C          to close the main window. Just in case this leads to a second
C          pass, then set INHIBIT_EXIT to 0 (no), although it will be
C          caught here the second time round. INHIBIT_EXIT is cleaner.

       ELSE                  ! This is ELSE to the IF about MGR 3 and 4.
       INHIBIT_EXIT = 0
       EndExit_FUNCTION = 0
       ENDIF
       RETURN
       END


In the context of my program, you can only save if MGR(3) or (4
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2816
Location: South Pole, Antarctica

PostPosted: Mon Sep 20, 2010 6:30 am    Post subject: Reply with quote

You've done nice trick with that, Litus! Will add to my weaponry with reference on you. This is a must for all programs. And i also missed %ew format which you use, that's together with %`cc looks like a later years additions, i do not see them in Clearwin older then circa 2000-2004. Lots of good new stuff. Thanks Smile
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2816
Location: South Pole, Antarctica

PostPosted: Wed May 29, 2013 1:23 am    Post subject: Reply with quote

i think %cc does not work together with 'confirm_exit', works only with plain 'exit' ....
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group