Référence › Input and Output — 102 commandes
alert
Entrée: text (word or phrase) | buttonnames (list) | actions (list of lists)
Sortie: none
(Web only) Displays a dialogue that prompts for button input, then executes the associated commands. See example
alert |Pick your animal| [cow pig] [[print "moo][print "oink]]
allopen
Entrée: none
Sortie: list
Returns a list of all open files. See open
show allopen
announce
Entrée: text (word or phrase)
Sortie: none
(Web only) Displays a message using a dialog box. See alert, dialog
announce |You won!|
answer
Entrée: none
Sortie: word, number or list
Returns the last answer typed by the user as a response to a question. Note that the data stored in answer belongs to the procedure and will be unavailable outside of it. See question.
question [What is your name?]
make "username answer
autosave
Entrée: none
Sortie: filepath (word)
Returns the path and filename of the most recent autosave such that 'load autosave' will load the current project's most recent autosave into the workspace.
load autosave
catalog
Aussi: cat
Entrée: none
Sortie: none
Opens the project catalog
cat
clearanswer
Entrée: none
Sortie: none
Clears the 'answer' parameter, which contains the input value from the previous 'question'. See question, answer.
clearanswer
clearchar
Entrée: none
Sortie: none
Clears any buffered keyboard presses and monitored keypresses (such as keypressedp). See readchar, peekchar, keypressedp.
clearchar
close
Entrée: filename (word)
Sortie: none
Closes the specified file. See open
close "file
closeall
Entrée: none
Sortie: none
Closes all files that are currently open. See open, close
closeall
copyfile
Entrée: source (word) | destination (word)
Sortie: none
Copies the specified file to the specified destination.
copyfile "myfile "myfile2
createdir
Entrée: directory
Sortie: none
Creates a new directory in the current path.
createdir "newdir
delete
Entrée: file (word)
Sortie: none
Deletes the specified file from the current turtleSpace. For safety, delete can only delete files from the root of the turtleSpace.
delete "myfile
deletebutton
Entrée: name (word)
Sortie: none
Deletes the named button. See newbutton
deletebutton "button
dialog
Entrée: text (word or phrase) | container (word) OR [container default]
Sortie: none
(Web only) Displays a dialogue that prompts for text input, then places that input into the supplied container name. If a default value is provided, this value is placed into the input area. See alert, announce
dialog |What is 3 + 7| "answer
dialog |What pencolor?| {"pencolor pencolor}
dribble
Entrée: file (word)
Sortie: none
Sends a copy of the characters displayed on the screen to a file. nodribble stops it. See nodribble
dribble "mydribble.txt
erasefile
Entrée: filename (word)
Sortie: none
Deletes the specified file from the current path. See createdir, renamefile, setprefix
erasefile "myfile
export
Entrée: name (word)
Sortie: none
Saves an .lgo file with the provided name containing the current turtlespace code.
export "MyCode
filelen
Entrée: filename (word)
Sortie: number
Returns the length of the specified file in bytes. See filep
show filelen "myfile
files
Entrée: none
Sortie: [[list] [list]]
Returns a list of entries in the current directory divided into two lists: the first contains folders, the second files.
show files
fileselect
Entrée: extension (word)
Sortie: path
Takes an extension mask as input (without the .) and prompts the user to select a file, returning the path and file selected.
show fileselect “lgo
fork
Entrée: name (word)
Sortie: none
Duplicates the current project and gives it the specified name, and switches to it as the currently active project. Note: If the project has a lot of files in it, this may take some time!
fork "forkedproject
gameaxis
Entrée: axis
Sortie: value
Returns a digital value (-1 0 1) of the specified gamepad axis. Note this only reads gamepads, not the mouse. For analog values use paddle. To read a second controller see selectgamepad, gamepad
show gameaxis 1
gamebuttons
Entrée: none
Sortie: buttons
Returns a list of the buttons currently pressed on the gamepad. To read a second controller see selectgamepad, gamepad.
show gamebuttons
gamepad
Entrée: none
Sortie: gamepad (number)
Returns the number of the gamepad currently addressed by gameaxis, gamebuttonp and gamebuttons. See selectgamepad
show gamepad
hidebutton
Entrée: name (word)
Sortie: none
Hides the selected button. Use showbutton to show it.
hidebutton "button
import
Entrée: file (word)
Sortie: none
Imports (copies) the specified file into the current turtleSpace. Root / is the current user folder.
import "/myfile
input
Entrée: word | number
Sortie: none
Allows the user to enter a word or number which is stored in a container with the name of the first parameter, and whose length is limited by the number provided in the second parameter. For example, 'input "name 10' will wait for the user to enter their name, but it can be at most ten characters in length.
input "name 10
melody
print :name
melody
keypress
Entrée: none
Sortie: word
Returns the next keypress from the keyboard buffer, if any keypresses exist inside it. If the buffer is empty, it returns an empty word. A variant of readchar that does not wait for a keypress before returning input. See readchar
forever [type keypress]
keys
Entrée: word
Sortie: none
Places the given list of characters into the keyboard buffer.
keys "abcde
listfiles
Entrée: none
Sortie: none
Lists the files and folders in the current working directory
listfiles
load
Entrée: projectname (word)
Sortie: none
Loads the specified project from disk. If that project has a procedure called .autostart defined in the Myrtle turtle, that procedure is executed upon load.
load "myproject
loaddatabase
Entrée: filename (word)
Sortie: none
Loads a database into memory. See savedatabase, newdatabase
loaddatabase "mydb
loaddictionary
Entrée: filename | dictionaryname
Sortie: none
Loads the given dictionary from the filename into the dictionary with the given dictionaryname. See dictionary, newdictionary
loaddictionary "dictfile "mydict
loadimage
Entrée: imagename (word) | imagefile (word) OR imageurl (url)
Sortie: none
Loads the specified image from disk or URL into memory. PNG is the only supported image type. A URL must have pipes around it (phrase).
loadimage "myimage "imagefile.png
loadmodel
Entrée: modelname (word) | modelfile (word)
Sortie: none
Loads the specified model file into the specified model name, replacing it if it already exists or creating it if necessary.
loadmodel "mymodel "modelfile.mdl
loadmusic
Entrée: musicname (word) | musicfile (word)
Sortie: none
Loads the specified music file into memory.
loadmusic "mymusic "music.sng
loadplot
Entrée: filename (word) | plotname (word)
Sortie: none
Loads the specified plot file into the specified plot name. The plot does not need to have been previously defined. See plot
loadplot "myplotfile "myplot
movefile
Entrée: sourcefile (word) | destinationfile (word)
Sortie: none
Moves the specified file to the specified destination.
movefile "myfile "newfile
mousebutton
Entrée: none
Sortie: number
Returns 0, 1 (left button), 2 (right button) or 3 (both buttons). Reading mousebutton disables camcontrol. See buttonp, mousex, mousey, mousebuttons (which returns all pressed buttons)
show mousebutton
mousebuttons
Entrée: none
Sortie: list
Returns a list of currently pressed mouse buttons where 0 = left, 1 = right, 2 = middle, 3 = scroll in, 4 = scroll out. See mousebutton, buttonp, mousex, mousey
show mousebuttons
mouseclick
Entrée: screenposition (list) | clicktype (number)
Sortie: none
Simulates a mouse click. The provided screen position should be in terms of percentages of the width and height of the screen, with 0 being the left and top respectively. The second parameter is one of the following: 1 - left click, 2 - right click, 3 - both / middle click. This is useful for tutorials or test workers
mouseclick [50 50] 1
mousex
Entrée: none
Sortie: percentage (number)
Returns the current horizontal mouse position in terms of the percentage of the screen width, with 0 being the left edge. Reading mouse disables camcontrol. See mousey
show mousex
mousey
Entrée: none
Sortie: percentage (number)
Returns the current vertical mouse position in terms of the percentage of the screen height, with 0 being the bottom edge. Reading mousey disables camcontrol. See mousex
show mousey
newbutton
Entrée: name (word) | [x1 y1 x2 y2 (label…)] (list)
Sortie: none
Creates a new on-screen button named name, spanning the rectangle [x1 y1 x2 y2] given as PERCENTAGES of the canvas (0 to 100, measured from the top-left corner). x1 must be less than x2 and y1 less than y2. Any words after the four numbers become the button's display label; if no label is given the button name is displayed. Button images are set separately with setbuttonimages. See setbuttonimages, buttonnamep, deletebutton, buttonclickedp, buttonclickp, showbutton, hidebutton
newbutton "go [40 80 60 90 Launch rocket]
nodribble
Entrée: none
Sortie: none
Ends a current dribble, if any. See dribble
nodribble
nostlbacking
Entrée: none
Sortie: none
Discards the backside triangles from 2D and 3D shapes when exporting an STL file. This is enabled by default to make STL file exports from turtleSpaces better compatible with 3D printer 'slicing' software. To export them with backside triangles for use in other 3D applications, call stlbacking before savestl. See stlbacking, which enables backside triangles from export.
stlbacking
open
Entrée: filename (word)
Sortie: none
Opens a file for reading or writing. You must also setread / setwrite the file in order to read from / write to it. See close, setread, setwrite
open "myfile
openlink
Entrée: link (phrase)
Sortie: none
opens the specified URL (weblogo only) Provided URL parameter must be a phrase (enclosed in pipes, see example).
openlink |https://turtlespaces.org|
paddle
Entrée: paddle (number)
Sortie: value (number)
Takes a value from 0 to 3 that indicates the 'paddle', which is the axis value of a controller and can be from 0 to 255. Paddles can be controlled either from a joypad (paddle 0 and 1 is usually the horizontal and vertical axes of the left thumbstick respectively, and 2 and 3 the right thumbstick) or using the mouse (paddle 0 and 1 return results based on the mouse's position on the window.) See buttonp, gameaxis, gamebuttons, selectgamepad
show paddle 0
path
Entrée: none
Sortie: word
Returns the current file path.
show path
peekchar
Entrée: none
Sortie: character
Returns the current next character in the keyboard buffer, if any. This character is left in the buffer. See readchar, clearchar
show peekchar
pofile
Entrée: filename (word)
Sortie: none
Prints out the specified text file to the screen.
pofile "textfile
prefix
Entrée: none
Sortie: path
Returns the 'prefix' or current file system path. / is the user's folder.
show prefix
question
Entrée: word or list
Sortie: none
Asks the user the 'question' posed in the provided word or list. The answer is retrieved through the answer primitive. See answer
question [What is your name?]
readchar
Aussi: rc
Entrée: none
Sortie: character
Reads a character from the keyboard buffer and returns it. If there is no key in the buffer, it will wait for the user to press a key. See keyp
show readchar
readchars
Aussi: rcs
Entrée: number
Sortie: word
Reads the specified number of characters from the keyboard buffer and returns them as a single word. If there are insufficient keys in the buffer, readchars will wait for the user to press a sufficient quantity of keys to meet the required amount.
show readchars 5
reader
Entrée: none
Sortie: filename
Outputs the name of the current file open for reading. You can change the current read file with the setread primitive. reader returns an empty list if the current reader is the keyboard.
print reader
/myfile.txt
readfile
Entrée: filename
Sortie: list
Returns a list of 'long words' (words with spaces), each long word in that list containing one line of the specified input file. You can use 'parse' to turn each long word into a list. See parse
show readfile "myfile.txt
readlist
Aussi: rl
Entrée: none
Sortie: list
Inputs a list from the keyboard OR currently open file. See question, readchar, setread
make "name readlist
readpos
Entrée: none
Sortie: number
Returns the current read position in the read file in bytes.
show readpos
readword
Aussi: rw
Entrée: none
Sortie: word
Reads a 'word' from the keyboard or open file. As opposed to readlist, this input is returned as a word, or a 'long word' if it includes spaces. See readlist, setread
make "input readword
redo
Entrée: none
Sortie: none
Redo reverts the library of procedures in the current turtleSpace to those contained in the next (forwardly) available autosave - it redoes those changes. Hence it is only available after using undo. See undo for a better explanation.
redo
renamefile
Entrée: source | destination
Sortie: none
Renames a file.
renamefile "oldname "newname
revert
Entrée: none
Sortie: none
Reverts to the last formal save, for example if you load a turtleSpace and muck about with it, but want to quickly return it to its original state.
revert
save
Entrée: none
Sortie: none
Creates a save point in the current turtleSpace project.
save
savedatabase
Entrée: database (word) | file (word)
Sortie: none
Saves the specified database under the specified filename. See newdatabase, loaddatabase
savedatabase "database "mydb
savedictionary
Entrée: dictionaryname | filename
Sortie: none
Saves the given dictionary into a file with the given filename. See dictionary, newdictionary
savedictionary "mydict "dictfile
savegif
Entrée: seconds (number) OR [seconds frameskip]
Sortie: none
Records and downloads an animated GIF of the given number of seconds. If this is given as a list, the second number is the frameskip value (the gif will only include every nth frame). Large windows are scaled down so the longest edge is at most 640 pixels. Called inside a procedure, the recording finishes and downloads when the procedure returns. See savemp4 and savewebm
savegif 5
savegif [5 2]
savemp4
Entrée: seconds (number) OR [seconds frameskip]
Sortie: none
Records and downloads an MP4 of the given number of seconds. If this is given as a list, the second number is the frameskip value (the mp4 will only include every nth frame).
savemp4 10
savemp4 [10 2]
savepict
Entrée: filename (word)
Sortie: none
Saves a screenshot of the current output window into the specified filename. For high-resolution captures, use savepng
savepict "mypic.png
saveproc
Entrée: procedure (word) | filename (word)
Sortie: none
Saves the specified procedure into the specified file in the current working turtleSpace project.
saveproc "myproc "myproc.to
saveplot
Entrée: filename (name) | plotname (name)
Sortie: none
Saves the specified plot to the specified file. See plot
saveplot "myplotfile "myplot
savepng
Entrée: [width height] (list) | name (string)
Sortie: none
Saves a PNG image rendered using FauxGL using the specified dimensions into the current turtleSpace project folder, as opposed to savepict or snapshot which captures the current rasterized window image. savepng allows you to save extremely high resolution renders, but be careful, since it uses a lot of memory! Also, if the camera turtle and the light turtle are different, savepng will use a cruder method of image generation.
savepng [1920 1080] "mypicture.png
savestl
Entrée: modelname (word)
Sortie: none
Creates a folder in the current project folder called modelname.mdl and exports a series of STL files inside it containing the current displayed vectors, one for each color displayed. These can be used with 3D printers, although they may need to be 'validated' by another application first (and the sides potentially extruded). Lines are converted to cylinders. See also savestlmono, which saves a single amalgamated STL file
savestl "mymodel
savestlmono
Entrée: modelname (word)
Sortie: none
Creates a folder in the current project folder called modelname.mdl and exports a single STL files inside it containing the current displayed vectors as a single color. This can be used with 3D printers, although it may need to be 'validated' by another application first (and the sides potentially extruded). See savestl, which separates the vectors by color
savestlmono "mymodel
savewebm
Entrée: seconds OR [seconds frameskip]
Sortie: none
Downloads a WEBM of the graphical screen of the specified duration after that duration has elapsed. Web only
savewebm 20
selectgamepad
Entrée: gamepad (number)
Sortie: none
Selects which attached gamepad is read by gameaxis, gamebuttonp and gamebuttons. Pads are numbered from 0 in the order they were attached, and pad 0 is selected by default. See gamepad, gameaxis
selectgamepad 1
setpath
Entrée: path (word)
Sortie: none
Sets the current file path. Root / is the current user folder.
setpath "/
setprefix
Entrée: path
Sortie: none
Sets the path for file operations. / is always the root of the user's folder
setprefix "/
setread
Entrée: filename (word)
Sortie: none
Sets a file previously opened with 'open' to be read from using readchar, readchars, readword or readlist. setread "printer causes input to come from the printer. setread " returns input to the keyboard. See open, close, setreadpos, setwrite
setread "inputfile
setread "
setreadpos
Entrée: bytes (number)
Sortie: none
Sets the read position of the current 'reader' (the input file set using setread). The provided number must be between 0 and the length of the file.
setreadpos 100
settitle
Entrée: name (word)
Sortie: none
Sets the title of the current turtlespace. Renames the current untitled turtlespace folder or changes the title of the currently open workspace folder. To create a new turtlespace, see initialize
settitle "MyGame
setwrite
Entrée: filename (word)
Sortie: none
Sets the previously 'open'ed file or output device for writing. setwrite " returns output to the interactive text area. If you setwrite "printer text will output to the printer area in the web IDE. See open, close, setread
setwrite "file
setwrite "api
setwrite "printer
setwritepos
Entrée: byte (number)
Sortie: none
Sets the write position in the currently opened file. See setwrite
setwritepos 60
sharevectors
Entrée: none
Sortie: URL
Returns a shareable URL that contains a web view version of the currently displayed vector information. It also displays the sharing user and project description (about). The viewer has a simple camera mechanism, and so models are best oriented to the camera's typical starting position. It also contains a link allowing for the opening of the current workspace in webLogo. See setabout
sharevectors
showbutton
Entrée: name (word)
Sortie: none
Shows the selected button. Use hidebutton to hide it.
showbutton "button
stlbacking
Entrée: none
Sortie: none
Includes the backside triangles from 2D and 3D shapes when exporting an STL file. This is turned off by default (nostlbacking) to make STL file exports from turtleSpaces better compatible with 3D printer 'slicing' software. To export them with backside triangles for use in other 3D applications, call stlbacking before savestl. See nostlbacking, which disables backside triangles from export.
stlbacking
takecover
Entrée: none
Sortie: none
Takes a cover photo, which is displayed in the file catalog when a turtleSpace is selected. If no cover photo exists, the file catalog displays the most recent auto-created snapshot (created when save is called). See save
takecover
takesnapshot
Entrée: none
Sortie: none
Takes a snapshot (PNG image), and places it in the snapshots folder in the current turtleSpace.
takesnapshot
title
Entrée: none
Sortie: title (word)
Returns the title (filename) of the current turtleSpace.
show title
undo
Entrée: none
Sortie: none
turtleSpaces autosaves any additions or changes to its current library of procedures. To revert to the previous autosave, use undo. To then revert to the next autosave (the one you were previously at) use redo. Note: if you add or change any procedures while in the autosave 'chain', the new autosave will be at the end of the chain, and you will need to undo back from the end to return to the state you were at prior to making the change. See redo
undo
uparrow
Entrée: none
Sortie: number
Returns the ASCII value for the up arrow key. Useful in combination with keypressedp, keydownp. See downarrow, leftarrow, rightarrow
if keypressedp uparrow [forward 20]
downarrow
Entrée: none
Sortie: number
Returns the ASCII value for the down arrow key. Useful in combination with keypressedp, keydownp. See uparrow, leftarrow, rightarrow
if keypressedp downarrow [back 20]
leftarrow
Entrée: none
Sortie: number
Returns the ASCII value for the left arrow key. Useful in combination with keypressedp, keydownp. See uparrow, downarrow, rightarrow
if keypressedp leftarrow [left 90]
rightarrow
Entrée: none
Sortie: number
Returns the ASCII value for the right arrow key. Useful in combination with keypressedp, keydownp. See uparrow, downarrow, leftarrow
if keypressedp rightarrow [right 90]
upchars
Entrée: none
Sortie: list
Returns a list of keys in ASCII format that have been released since upchars was last read. See keyupp, keydownp, keypressedp, keypress
show upchars
writepos
Entrée: none
Sortie: bytes (number)
Returns the current write position in bytes.
show writepos
writer
Entrée: none
Sortie: filename (word)
Returns the name of the file currently open for writing.
show writer
rc
Entrée: none
Sortie: character
Short form of readchar. Reads a single character from input without waiting for Enter.
make "key rc
rcs
Entrée: number
Sortie: word
Short form of readchars. Reads the specified number of characters from input.
make "input rcs 5
rw
Entrée: none
Sortie: word
Short form of readword. Reads a word from input.
make "name rw