Hi,
is there any more elegant way to acchieve the following:
One can use MVAR to get numerical user input. But the
only hint for the user to do is the name of the variable itsself,
which normally is very short to fit into a menu item.
The other way I can think of is to first put a string into the
alpha register as an "explanation" and then KEYG/KEYX to
execute a subroutine, which stores ths value of the X-register
into a variable of some kind.
But this is clunky and uses a lot of space and resources in form
of LABELs and lines of code just to store a value.
is there any other more elegant and condensed way to acchieve
this?
Cheers !
mcc
Getting User Input while using the alpha register
Getting User Input while using the alpha register
DM 42 - SN: 00373, Firmware release v.:3.22. / DMCP 3.24. as compiled by SwissMicros
-
- Posts: 19
- Joined: Sat Oct 17, 2020 2:32 am
- Location: Greater Montreal, Canada
Re: Getting User Input while using the alpha register
Taking it from the higher level, it is obvious that the caption you want displayed as a prompt has to be saved somewhere. Either it is present in the code or in variables that would be extracted (and therefore in need of storage prior to running) before being displayed.
You cannot save data, including a text string, in less space than it occupies, unless it can be condensed using data compression techniques (like 'zip'), but then the program would need the logic to decompress, and that also ought to take an awful lot of space.
If your program is really complex and feature rich, with many different prompts that might have a few repeating words and formulations, you could possibly envision storing the repeating common sub-elements once, and have a reference place holder in the captions featuring the unique wording. Then the program would parse the caption, notice the place holder and fetch the corresponding element to insert at the designated spot. But I have a hunch that the processing would be a lot more complicated than biting the bullet and storing the captions in full. And if there was a program that might benefit from such substitution techniques, it is likely to be more suited for something running on a computer, where memory is considered pretty abundant already.
You cannot save data, including a text string, in less space than it occupies, unless it can be condensed using data compression techniques (like 'zip'), but then the program would need the logic to decompress, and that also ought to take an awful lot of space.
If your program is really complex and feature rich, with many different prompts that might have a few repeating words and formulations, you could possibly envision storing the repeating common sub-elements once, and have a reference place holder in the captions featuring the unique wording. Then the program would parse the caption, notice the place holder and fetch the corresponding element to insert at the designated spot. But I have a hunch that the processing would be a lot more complicated than biting the bullet and storing the captions in full. And if there was a program that might benefit from such substitution techniques, it is likely to be more suited for something running on a computer, where memory is considered pretty abundant already.
Re: Getting User Input while using the alpha register
If you have meaningful variable names you can use the INPUT function:
will ask the user to enter the value for the "Speed" variable. But this is limited to 7 characters.
If you want to provide a longer text string to the user, you can use PROMPT to display a text string and then store the value entered by the user, for example:
You can also display the current value of the variable, so the user doesn't need to re-enter it if it has not changed :
Note: SF 25 is here in case the "ACCEL" variable doesn't yet exist when we RCL it. If in your program you know that the variable already exists at this step, you don't need the SF 25.
Code: Select all
INPUT "Speed"
If you want to provide a longer text string to the user, you can use PROMPT to display a text string and then store the value entered by the user, for example:
Code: Select all
"Acceleration ?"
PROMPT
STO "ACCEL"
Code: Select all
SF 25
RCL "ACCEL"
Acceleration ?"
PROMPT
STO "ACCEL"
DM42: 00425 - DM41X: β00066 - WP43: 00042