breaking / stopping Harbour application

Moderator: Rathinagiri

Post Reply
paweljabl
Posts: 4
Joined: Mon Oct 20, 2014 7:44 am

breaking / stopping Harbour application

Post by paweljabl » Mon Dec 15, 2014 11:20 am

Hello,

writing on behalf of my father, who has just migrated old Clipper applications to Harbour .
ALT+C doesn't work in Harbour like it used to do in Clipper. ALT+C was a very useful function in Clipper allowing breaking nested programs and at the same time closing any open data sets. Now, when when breaking application with Task Manager , data files don't close and database is corrupted.
Could you please give my father any suggestions how to deal with this problem ?

thanks a lot,
Pawel J

User avatar
Pablo César
Posts: 4058
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 177 times

Post by Pablo César » Mon Dec 15, 2014 11:37 am

Hi Pawel, welcome to our community !

ALT-C even in Clipper will abort app. That's no the right way to close/stop app.

You do not tell us if you are compiling in GUI or in console mode.

If is in console mode, I believe you can SET KEY to a procedure closing databases and app.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

paweljabl
Posts: 4
Joined: Mon Oct 20, 2014 7:44 am

Post by paweljabl » Mon Dec 15, 2014 11:49 am

Hi Pablo,

thanks a lot for the very quick reply.
Correction to my initial post after contacting my father. He compiled in Console mode and also made it more clear when it works and when not.
Actually ALT+C works when programs is in Menu / edit mode awaiting for user input, however when programs starts some procedure / calculation and is not in user's control (runs for too long) then ALT+C doesn't work, the only way to interrupt is to kill it from Task Manager...

Could you please direct me to some example of using SET KEY ? Or other way to sort out my father's problem ?

thanks a lot,
Pawel

User avatar
Pablo César
Posts: 4058
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 177 times

Post by Pablo César » Mon Dec 15, 2014 12:15 pm

paweljabl wrote:Actually ALT+C works when programs is in Menu / edit mode awaiting for user input
So, if you already use ALT-C for hotkey menu access, then you can not use SET KEY for ALT-C to procedure.

I have make tests and I see Harbour works perfectly with ALT-C like in Clipper, i.e. its abort app.
But in Harbour for default, ALT-C is not able to do it.
To turn able, you need to put SetCancel(.t.), then it will abort as in Clipper.

I made this test:

Code: Select all

Function Main()
SetCancel(.t.)
INKEY(0) // waiting for user ALT-C
? "HELLOW"
INKEY(0)
Return Nil
Try it and tell us if is ok for you father.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

paweljabl
Posts: 4
Joined: Mon Oct 20, 2014 7:44 am

Post by paweljabl » Mon Dec 15, 2014 12:27 pm

Pablo , many, many thanks!
I'll will pass the solution to my father and as soon as possible we will let y know if this works,
he cannot test it at the moment, but today he should be able to verify
thanks a lot,
Pawel

User avatar
Pablo César
Posts: 4058
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 177 times

Post by Pablo César » Mon Dec 15, 2014 12:31 pm

paweljabl wrote:Could you please direct me to some example of using SET KEY ?
See also this:

Code: Select all

#define K_ALTC   302

SETCANCEL(.F.)              // Disable termination keys
SET KEY K_ALTC TO AltC      // Redefine Alt-C

FUNCTION AltC
LOCAL cScreen, nChoice, cLastColor := SETCOLOR("W/B, N/G")

SAVE SCREEN TO cScreen
@ 6, 20 CLEAR TO 9, 58
@ 6, 20 TO 9, 58 DOUBLE
@ 7, 26 SAY "Alt-C: Do you want to quit?"
@ 8, 35 PROMPT " Yes "
@ 8, 41 PROMPT " No "
MENU TO nChoice
SETCOLOR(cLastColor)
RESTORE SCREEN FROM cScreen
IF nChoice = 1
   CLOSE ALL  // should it closes all open databases files
   QUIT
ENDIF
RETURN NIL
I've not tested but see if is it better or not.

Your father can not communicate because is far or for language questions ?
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

paweljabl
Posts: 4
Joined: Mon Oct 20, 2014 7:44 am

Post by paweljabl » Mon Dec 15, 2014 12:45 pm

Hi Pablo,

thanks again for quick reply, answering your last question, both :) my father is away but also his English is very, very basic, almost none.
I'm now commenting to your code snippet that goes like that:
Function Main()
SetCancel(.t.)
INKEY(0) // waiting for user ALT-C
? "HELLOW"
INKEY(0)
Return Nil

I've just confirmed with my father via phone that he uses SetCancel and sets to true, and uses INKEY and it works, I mean ALT+C. He doesn't use ALT+C as hotkey in his menus neither. And when program has contact with a user then ALT+C works and aborts app. However when program collects data for too long, or there's a bug in a program and it runs in endless loop for example, then ALT+C doesn't work, however in Clipper it does.
Do you think there's a solution for that ? I mean your last code example with SET KEY could be the solution or in this case not ?

Pawel

User avatar
Pablo César
Posts: 4058
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 177 times

Post by Pablo César » Mon Dec 15, 2014 1:05 pm

paweljabl wrote:my father is away but also his English is very, very basic
Are you from Poland ? No problem, let's try in English :)
paweljabl wrote:However when program collects data for too long, or there's a bug in a program and it runs in endless loop for example, then ALT+C doesn't work, however in Clipper it does.
Do you think there's a solution for that ?
I never passed thru this. But others points must be analyse, for example:

- This app is working in network ? In your code, do you use network treatment (RLOCK, UNLOCK, etc) in case ?
- What SO is used with your app ?
paweljabl wrote:I mean your last code example with SET KEY could be the solution or in this case not ?
I do not know, try it.

Another idea: If you can reproduce same crash at your pc (with your source codes), you can try to apply debug calling (ALTD()) in that function. Just to see where is the breaking down. But remember, you will need to compile with debug option.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

Post Reply