Automatically repeating menu choices

Tony Walduck
While writing a menu-based utility (the violin scales and arpeggios program also featured in this issue) I wished to make it possible to easily repeat a menu selection after it had been acted upon. These notes describe the solution I developed.
I decided to allow the automatic reselection of a previous menu choice by putting a repeat option as the first menu line.
All other menu lines write a number into a GVAR variable as well as actioning their intended response. The number written is the number of down-key presses needed to position the highlight on that menu line.
The repeat menu option reads the GVAR variable, flushes the keyboard input buffer (*FX15,1) and, if the variable is not zero (which would cause it to loop), inserts that number of down-key codes into the input buffer (*FX138), followed by a Return code to re-select the previous menu line.
The program U.VSA (Violin scales and arpeggios - accessible from this Utilities menu) contains a much-modified version of this technique. In this one program, nearly 80 music pieces can be chosen and easily repeated.
The reason the technique has been modified is that, as I rapidly came to the 125 user-word limit as well as space limitations, I had to employ whatever constructions would allow me to economise on both. Consequently the program structure is less clear than I would have liked it to be.

Related files on this disc:
U.Repeat1 - example repeat menu facility for a single-level menu
U.Repeat2 - as above for a two-level menu

Published in AMPLINEX 027, July 1992