I've looked everywhere for this, and can't find a solid way to do it... I am making a simple number-guessing game, and want to display the number attempt the player is on, and a colon. For example, if it was the user's 5th attempt the screen would look like:
Attempt 5:
...and the user would be able to guess the number again. This is the code for the loop:
For(X, 1, 10
INPUT whatever X is, G
IF G>N
DISP "TOO HIGH!"
...and so on. How would I make the INPUT command display the value of X? Would I have to convert is to a string, or is there a better way?
Input
is defined as taking either a variable or text and a variable. This gives you two options: Write your own input code (which I highly caution against as it will be slow and error-prone) with getKey or convert X to a string.
To convert a number to a string, use the following code: (You will want to change what variables it uses, currently turns N into the string.) Note that it does put a ? before your string, so you may want to remove that.
:"?
:For(X,1+int(log(N)),1,-1
:Ans+sub("0123456789",1+int(10fpart(N/10^X)),1
:End
:Ans→Str1