All the applications we use require input from us as users from time to time. The input could be clicking the bold button in Microsoft Word or typing a value into an Excel workbook. The input data is then processed according to the instructions in the app you are using.
In this post:
Required knowledge:
Starting point
The final version of the code in the tutorial Variabilize a program in LOGO is as follows:
make "numberOfSides 4 make "lengthOfSides 100 repeat :numberOfSides [ fd :lengthOfSides rt 360/:numberOfSides ]
readword
is a great introduction to the JOption class in Java.
To change the variables, we must change the code each time. This is far from ideal and impossible for the user to do in compiled programs such as Java. I think we can also agree it is poor form to expect our users to modify our programs!
Runtime!
The next step involves refactoring the code so that the user is asked to input the parameters at run-time. For this, we use the readword
command. While the syntax for the command is super simple, it needs to be used in conjunction with the make
command to assign the input value to a variable so that it can be used later in your program:
make "numberOfSides (readword [ Enter number of sides: ] )
Visit our LOGO cheatsheet here!
Whatever is typed between the square brackets will appear as text to prompt the user. The user’s input is then assigned to the variable numberOfSides
.

readword
text input dialog in Turtle Academy.Put it all together
All together now:
make "numberOfSides (readword [ Enter number of sides: ] ) make "lengthOfSides (readword [ Enter length of sides: ] ) repeat :numberOfSides [ fd :lengthOfSides rt 360/:numberOfSides ]
References:
- Turtle Academy. (2023) Lessons. Available at: https://turtleacademy.com/lessons/23 (Accessed: 28 January 2023)
- Terrapin. (No date) Commands Overview. Available at: https://resources.terrapinlogo.com/weblogo/commands/ (Accessed: 22 April 2024).
This seems to be a very useful site for searching out more details on using Logo. However, I have not been able to get the variable input for ‘readword’ to work.
In my program I have written ‘make “xStreet ( readword [Enter X Position: ] )’
The result is an error message ‘unexpected object [Enter X Position: ]’
I need user input in my program – preferably without having to set up files containing my required inputs!
I am using ACSLogo on MacOS 15.2 Sequoia.
Hi Clive
Your code works:
make "xStreet ( readword [Enter X Position: ] )
Pay careful attention to the apostrophes and quotes you are using. My only guess is that the syntax for ACSLogo is a variant of the LOGO Basic used for Turtle Academy.