FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour force closure program execution
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
force closure program execution
Posted: Mon Nov 10, 2014 02:08 PM
Hi,
I have to be sure at 100% that every users every users are logged off.

In your opinion is it dangerous to modify this? :

Code (fw): Select all Collapse
METHOD ClockOn() CLASS TMsgBar

   local cTime := Time()

   if ::oClock == nil
      // keep the ':=' below for XBase++ compatibility
      ::oClock := TMsgItem():New( Self, cTime, ::GetWidth( cTime ) + 12,,,, .t.,;
                                 { || WinExec( "Control date/time" ) } )
      ::oClock:lTimer = .t.
      ::oClock:bMsg   = { || [b]myTime()[/b] }
   endif
   ::CheckTimer()

return nil

//---------------------------------------------------------------------------//


and then

//------------------------------------------------------------------------//
Code (fw): Select all Collapse
FUNCTION MYTIME()
LOCAL cTime := TIME()
IF cTime >= "20:00:00"
   logfile( "forced_exit.log" , { cTime , M->cUte_dos } ) // M->cUte_dos is the number of user 
   CLOSE DATABASE
   QUIT

ENDIF
RETURN cTime

This is only a test condition
IF cTime >= "20:00:00"

Many thanks
Marco
Marco Boschi
info@marcoboschi.it
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: force closure program execution
Posted: Mon Nov 10, 2014 02:35 PM

Marco,

I don't recommend to use QUIT. Instead of it, simply finish your app from the function Main():

function Main()

...

return nil // application should reach this point

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: force closure program execution
Posted: Mon Nov 10, 2014 03:22 PM
Antonio,
from the main function I define the window in this way.

Code (fw): Select all Collapse
DEFINE WINDOW oMain                  ;
       FROM nTw , nLw TO nBw , nRw   ;
       TITLE cTitle                  ;
       ICON oIcomain; //oIcoMain     ;
       MENU oMenu        ;
       COLOR RGB( 255 , 255 , 255 ) , RGB( 178 , 178 , 178 ) PIXEL

oMain:bMoved := {|| oMain:CoorsUpdate() }

    SET MESSAGE OF oMain TO "Winrap: "                           + ;
                            M->cUte_dos                          + ;
                            " (" + UPPER(M->StampaWin) +   ")"   + ;
                            " (" + M->dati_path + ")"                 ;   // era cCurFolder
                            CENTERED CLOCK KEYBOARD 2007

Im sorry but I do not understand...
Marco Boschi
info@marcoboschi.it
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: force closure program execution
Posted: Mon Nov 10, 2014 03:33 PM

Marco,

He is saying not to use QUIT but rather create a condition that closes the main window.

You can use the VALID clause to execute any codeblock. Remember that you have to return .t. for the window to close.

ACTIVATE WINDOW oWnd...VALID (doWhatever(), .t.)

QUITing in the middle of a program can leave stuff in memory and perhaps you need to other cleanup before exiting.

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion