Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"OUT OF STACK SPACE" when working with Function Keys (F1,F2...) 1

Status
Not open for further replies.

aliinal

Technical User
Jun 26, 2001
104
TR
I've written a program that uses function keys to get input from user. Ex F1 to go to add section F2 to delete etc.etc.
For this i used the commands below

Code:
KEY(X) ON 'Where x is the Function Key's keyboard scan code
ON KEY(X) GOSUB aaaaa

but in runtime if i hold that function key pressed or hit several times i get the error "OUT OF STACK SPACE"...
It's an interesting error for this program cus no recursive subs...
Thanks for your help
 
suggestion: in that "gosub aaaa" use the KEY OFF command so that if the KEY IS still pressed WHILE in that sub routine, it doesn't call itself again.

I'm pretty certain it's called a "recursive call", you may have heard of it.

THEN, just before the RETURN statement use the KEY ON command to reactivate the key's usability.

Good Luck.
--MiggyD "The world shrinks more and more with every new user online."
 
Glad to have helped.
--MiggyD "The world shrinks more and more with every new user online."
 
Actually, MiggyD, this is called a re-entrant call. The routine did not call itself, but it was called while it was still running. This is one possibility, especially if the routine inside the key handler takes a long time to execute.

The other possibility is that aliinal's program isn't '[tt]RETURN[/tt]'ing from the handler, but instead explicitly '[tt]GOTO[/tt]'ing the top of some loop. In this case, the stack would still have the return value from the keyboard handler '[tt]GOSUB[/tt]' call. Invoking the handler repeatedly would slowly consume all of the available stack space, eventually causing the program to crash.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top