Hello,
I'm writing a function and I am allowing the user to input a number/character (anything on the keyboard really). However, I only want them to be able to enter a single element. For example, if the user enters the letter m or the letter 5 it's fine, but I don't want the user to be able to enter the word moose, or the number 500.
Is there any (I've not been able to find one on the HyperSepc, but I could not be looking clearly enough) read function that stops taking input when the very first element is entered or only returns the first element that was entered? I'm using ACL Express Edition.
Thanks for any and all help!
Read only a single element
-
- Posts: 59
- Joined: Sun May 29, 2011 8:52 pm
- Location: NY
- Contact:
-
- Posts: 59
- Joined: Sun May 29, 2011 8:52 pm
- Location: NY
- Contact:
Re: Read only a single element
Okay, I have not the slightest clue how I missed this. Maybe because it's late
(read-char) does what I am looking for.
Might not want it to be a char, but I can always turn it into something once I have it as a char.

(read-char) does what I am looking for.
Code: Select all
CG-USER(35): (read-char)
a
#\a
CG-USER(36): (read-char)
ajaj
#\a
CG-USER(37): (read-char)
1334
#\1
CG-USER(38): (read-char)
%%100
#\%
Re: Read only a single element
Usually, a console always reads in a complete line. It's good practice to read the input and if it isn't of the required type then issue an error message and read the input again.I X Code X 1 wrote:Is there any read function that stops taking input when the very first element is entered