ON *BUTTON?

May 20, 2008
11,400
99
Syracuse, NY, USA
ON *BUTTON doesn't have anything to do with QuickEdit.

It seems to be working fine here -- how are you trying to trigger it? (You do know that it's not an asynchronous trigger? TCC has to be waiting for keyboard input.)
I see ... like this
Code:
on lbutton beep
inkey %%foo
I noticed that it satisfies the INKEY but doesn't set the variable ... WAD?
 
May 20, 2008
11,400
99
Syracuse, NY, USA
WAD. If you want to set the variable, use INKEY /M and don't use ON LBUTTON.
I was thinking it shouldn't satisfy the INKEY if INKEY isn't accepting mouse clicks. In what other circumstances would ON *BUTTON work?
 

rconn

Administrator
Staff member
May 14, 2008
12,344
149
I was thinking it shouldn't satisfy the INKEY if INKEY isn't accepting mouse clicks. In what other circumstances would ON *BUTTON work?

It's not "satisfying the INKEY"; it's interrupting INKEY and executing something else instead.

The other circumstances where ON *BUTTON would work would be any other time when TCC is expecting keyboard input. INPUT, PAUSE, LIST, SELECT, any internal command that takes interactive input (i.e., Y/N prompts), etc.
 
May 20, 2008
3,515
4
Elkridge, MD, USA
Rex:
This thread seems appropriate to ask:

1/ are ALL "ON" handlers of a batch file restored when a CALL'd batch file returns, or only - as documented in the paragrpah titled "Scope" of the "ON" command help topic - only the BREAK and ERROR handlers?

2/ How is ON scope affected by "calling a label", i.e., a part of the same batch file?
 
May 20, 2008
3,515
4
Elkridge, MD, USA
One additional question:
3/ How is ON scope affected when doing a GOSUB with an explicit filename? This has two subquestions - when the explicit file is actually the same as the one which executes the GOSUB, and the more common case of it being a different file...
 

rconn

Administrator
Staff member
May 14, 2008
12,344
149
Rex:
This thread seems appropriate to ask:

1/ are ALL "ON" handlers of a batch file restored when a CALL'd batch file returns, or only - as documented in the paragrpah titled "Scope" of the "ON" command help topic - only the BREAK and ERROR handlers?

2/ How is ON scope affected by "calling a label", i.e., a part of the same batch file?

1) The ON handlers only affect the current batch file level -- a CALL'd batch file is a nested file, so the ON handlers aren't referenced, and there's nothing to restore.

2) It's not affected at all; calling a label is done within the same batch file. But the question is probably moot, since that syntax is for batch files written for CMD.EXE, which doesn't support ON handlers anyway.
 

rconn

Administrator
Staff member
May 14, 2008
12,344
149
One additional question:
3/ How is ON scope affected when doing a GOSUB with an explicit filename? This has two subquestions - when the explicit file is actually the same as the one which executes the GOSUB, and the more common case of it being a different file...

"GOSUB filename" runs a nested batch file, so the ON handlers don't exist.
 
May 20, 2008
3,515
4
Elkridge, MD, USA
1) The ON handlers only affect the current batch file level -- a CALL'd batch file is a nested file, so the ON handlers aren't referenced, and there's nothing to restore.
The last sentence of HELP -> ON, subsection Scope:

"When control returns to the calling batch file, its break and error handlers that had been in effect at the CALL are reactivated."

I think this statement in the documentation is a leftover from the days when ON BREAK and ON ERROR were the only forms of ON, and should be amended to:

"When control returns to the calling batch file, all of its ONhandlers that had been in effect at the CALL are reactivated."

where underscore indicates modified text. This would be consonant with interpreting your above quoted statement to mean that the CALL'd batch file does not affect the caller's ON handlers.



2) It's not affected at all; calling a label is done within the same batch file. But the question is probably moot, since that syntax is for batch files written for CMD.EXE, which doesn't support ON handlers anyway.

While I agree with the original purpose of in-file CALL, CALL offers more flexibility than GOSUB for passing parameters, and for modifying passed parameters, so I would not be surprised if TCC-only users would take advantage of this feature. Regardless, your answer to my question was as expected - if control moves out of the file, ON does not propagate, but inside it does.
 
Similar threads
Thread starter Title Forum Replies Date
D Double Quote in TC Tool Bar Button Command line Support 3
Alpengreis Fixed 0xc0000005 while try to create a button (Schaltfläche) Support 4
Glenn Bowes WAD TOOLBAR Button Definations are different v19 to v20 Support 8
Alpengreis [v19.0.32 (x64)] Problem with [Options, Tabbed Toolbar, Add Button] in german language Support 1
T Fixed V18 debugger crashed on save button Support 1
T Fixed V18 debugger crashed on stop button Support 2
vefatica How do I get rid of this button? Support 1
cgunhouse Button Cause TCMD V17 to Crash Support 3
D TCMD16 Delete Toolbar Button bug Support 7
E Command History not showing on up arrow button Support 8
W Button command issue Support 5
S How to? Use Forum "feedback" button to open in a new tab Support 3
cgunhouse ToolBar Button Problem Support 11
D "Learn More" button on home page not working Support 3
Stefano Piccardi forum: what's new button Support 7
Y Close button on tabs Support 7
Stefano Piccardi IDE.exe start toobar button fails when % in script path Support 0
Joe Caverly No dash in Command Tool Bar Button Support 1
krischik Button changes not saved Support 5
krischik Tab and Button Icons in Window 64 Support 2
R Button label is blank - 11.00.48 Support 0
p.f.moore TC 11 - can the tabs on the button bar be switched off? Support 6
Y V11 Button Tab Support 7
M Tab button to launch as different user Support 1

Similar threads