This should be the easiest thing to do but I cannot find it in the documentation. What command(s) are needed to prompt and receive user keyboard input from the CIW from a SKILL routine? I am not looking for a custom user form - more on the order of one line of code or two at the most. I don't want to get the input from a file - I want to enter it with the keyboard.
You could try enterString() - the documentation says that the string / entry is terminated when [Enter] is pressed. I have not played with this for a very long time, but I think it should fit your requirements.
In reply to skillUser:
Thanks but I created a procedure to do this and it didn't seem to work. My procedure was
procedure(test() a = enterString())
When I run it, it immediately returns and there is no opportunity to enter the string. If I try to enter the string I get an error saying that the string is undefined.
In reply to thomas1000:
If you do:
procedure(test() a = enterString(?prompts list("do this")) printf("The value of a was %L\n" a))
And then call test() - you need to type the string you want in quotation marks, otherwise it won't read it.
I doubt this is really what you want. The CIW is not really intended for you to read responses from the user. Why not create a form?
Sorry to hear that it doesn't work - what are you trying to achieve? Perhaps the string could be an argument for a procedure, i.e. gather the input before running? Why not a small form to interact with the user to gather feedback? Is the information being obtained a general-purpose text string, or is it a more specific purpose (e.g. a point list)? Helping us to understand the problem better will elicit better responses.
I don't want to be critical of SKILL but I have evidently been spoiled by other languages. In VB you have an input statement and it creates a small form that you can use to enter values. Everytime I look at the amount of code required for a form it is about 4 or 5 times as much code as my original application, which is very short.
What I want to do is prompt for a number and have the user type the number (without quotes) and then use that number in a calculation. A form would be nice but I thought I had remembered from class about 10 years back that there was something about 1 line long - maybe that memory was imagined.
Have you tried enterNumber()?
Taking a cue from Andrew's post, I tried the following:
procedure(test() a = enterNumber(?prompts list("Enter a number")) printf("That number squared is %f\n" a**2))
However, when I type test in the CIW, the routine proceeds without stopping for user input (this is not the final application). If you try to enter a number it does not compute its squared value. It simply blows right past all of that. if you type, a, in the CIW, it is undefined but since my procedure made it global, it is evident that a was never assigned.
Here's a quick and dirty example of creating a simple form to get the user input:
;; this is an example of using the input value
procedure(CCFuseNum(form) printf("You entered: %L\n" form->CCFGetNumFloatField->value))
;; this is the simple form to get the number
?fields list( list(
hiCreateFloatField(?name 'CCFGetNumFloatField ?prompt "Enter number:")
0:0 130:30 80
?formTitle "Get Num"
There are more arguments to the hiCreateAppForm() function to control the appearance of the form etc.I've made the form "modal" so that the user has to interact with the form (OK/Cancel) before moving onto the next task. The form structure is global, so you can access it any time after it was called, e.g. CCFGetNum->CCFGetNumFloatField->value so you do not have to use the form callback if you do not want to.
I hope this helps you.
Thanks - that looks a lot better than the other form code I have seen. I will try it.