Referencia › Input and Output — 102 comandos


alert

input and output

Entrada: text (word or phrase) | buttonnames (list) | actions (list of lists)
Salida: 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

input and output

Entrada: none
Salida: list

Returns a list of all open files. See open

show allopen

announce

input and output

Entrada: text (word or phrase)
Salida: none

(Web only) Displays a message using a dialog box. See alert, dialog

announce |You won!|

answer

input and output

Entrada: none
Salida: 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

input and output

Entrada: none
Salida: 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

También: cat

input and output

Entrada: none
Salida: none

Opens the project catalog

cat

clearanswer

input and output

Entrada: none
Salida: none

Clears the 'answer' parameter, which contains the input value from the previous 'question'. See question, answer.

clearanswer

clearchar

input and output

Entrada: none
Salida: none

Clears any buffered keyboard presses and monitored keypresses (such as keypressedp). See readchar, peekchar, keypressedp.

clearchar

close

input and output

Entrada: filename (word)
Salida: none

Closes the specified file. See open

close "file

closeall

input and output

Entrada: none
Salida: none

Closes all files that are currently open. See open, close

closeall

copyfile

input and output

Entrada: source (word) | destination (word)
Salida: none

Copies the specified file to the specified destination.

copyfile "myfile "myfile2

createdir

input and output

Entrada: directory
Salida: none

Creates a new directory in the current path.

createdir "newdir

delete

input and output

Entrada: file (word)
Salida: 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

input and output

Entrada: name (word)
Salida: none

Deletes the named button. See newbutton

deletebutton "button

dialog

input and output

Entrada: text (word or phrase) | container (word) OR [container default]
Salida: 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

input and output

Entrada: file (word)
Salida: none

Sends a copy of the characters displayed on the screen to a file. nodribble stops it. See nodribble

dribble "mydribble.txt

erasefile

input and output

Entrada: filename (word)
Salida: none

Deletes the specified file from the current path. See createdir, renamefile, setprefix

erasefile "myfile

export

input and output

Entrada: name (word)
Salida: none

Saves an .lgo file with the provided name containing the current turtlespace code.

export "MyCode

filelen

input and output

Entrada: filename (word)
Salida: number

Returns the length of the specified file in bytes. See filep

show filelen "myfile

files

input and output

Entrada: none
Salida: [[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

input and output

Entrada: extension (word)
Salida: 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

input and output

Entrada: name (word)
Salida: 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

input and output

Entrada: axis
Salida: 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

input and output

Entrada: none
Salida: buttons

Returns a list of the buttons currently pressed on the gamepad. To read a second controller see selectgamepad, gamepad.

show gamebuttons

gamepad

input and output

Entrada: none
Salida: gamepad (number)

Returns the number of the gamepad currently addressed by gameaxis, gamebuttonp and gamebuttons. See selectgamepad

show gamepad

hidebutton

input and output

Entrada: name (word)
Salida: none

Hides the selected button. Use showbutton to show it.

hidebutton "button

import

input and output

Entrada: file (word)
Salida: none

Imports (copies) the specified file into the current turtleSpace. Root / is the current user folder.

import "/myfile

input

input and output

Entrada: word | number
Salida: 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

input and output

Entrada: none
Salida: 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

input and output

Entrada: word
Salida: none

Places the given list of characters into the keyboard buffer.

keys "abcde

listfiles

input and output

Entrada: none
Salida: none

Lists the files and folders in the current working directory

listfiles

load

input and output

Entrada: projectname (word)
Salida: 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

input and output

Entrada: filename (word)
Salida: none

Loads a database into memory. See savedatabase, newdatabase

loaddatabase "mydb

loaddictionary

input and output

Entrada: filename | dictionaryname
Salida: none

Loads the given dictionary from the filename into the dictionary with the given dictionaryname. See dictionary, newdictionary

loaddictionary "dictfile "mydict

loadimage

input and output

Entrada: imagename (word) | imagefile (word) OR imageurl (url)
Salida: 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

input and output

Entrada: modelname (word) | modelfile (word)
Salida: 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

input and output

Entrada: musicname (word) | musicfile (word)
Salida: none

Loads the specified music file into memory.

loadmusic "mymusic "music.sng

loadplot

input and output

Entrada: filename (word) | plotname (word)
Salida: 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

input and output

Entrada: sourcefile (word) | destinationfile (word)
Salida: none

Moves the specified file to the specified destination.

movefile "myfile "newfile

mousebutton

input and output

Entrada: none
Salida: 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

input and output

Entrada: none
Salida: 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

input and output

Entrada: screenposition (list) | clicktype (number)
Salida: 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

input and output

Entrada: none
Salida: 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

input and output

Entrada: none
Salida: 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

input and output

Entrada: name (word) | [x1 y1 x2 y2 (label…)] (list)
Salida: 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

input and output

Entrada: none
Salida: none

Ends a current dribble, if any. See dribble

nodribble

nostlbacking

input and output

Entrada: none
Salida: 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

input and output

Entrada: filename (word)
Salida: 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

input and output

Entrada: link (phrase)
Salida: none

opens the specified URL (weblogo only) Provided URL parameter must be a phrase (enclosed in pipes, see example).

openlink |https://turtlespaces.org|

paddle

input and output

Entrada: paddle (number)
Salida: 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

input and output

Entrada: none
Salida: word

Returns the current file path.

show path

peekchar

input and output

Entrada: none
Salida: 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

input and output

Entrada: filename (word)
Salida: none

Prints out the specified text file to the screen.

pofile "textfile

prefix

input and output

Entrada: none
Salida: path

Returns the 'prefix' or current file system path. / is the user's folder.

show prefix

question

input and output

Entrada: word or list
Salida: 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

También: rc

input and output

Entrada: none
Salida: 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

También: rcs

input and output

Entrada: number
Salida: 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

input and output

Entrada: none
Salida: 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

input and output

Entrada: filename
Salida: 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

También: rl

input and output

Entrada: none
Salida: list

Inputs a list from the keyboard OR currently open file. See question, readchar, setread

make "name readlist

readpos

input and output

Entrada: none
Salida: number

Returns the current read position in the read file in bytes.

show readpos

readword

También: rw

input and output

Entrada: none
Salida: 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

input and output

Entrada: none
Salida: 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

input and output

Entrada: source | destination
Salida: none

Renames a file.

renamefile "oldname "newname

revert

input and output

Entrada: none
Salida: 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

input and output

Entrada: none
Salida: none

Creates a save point in the current turtleSpace project.

save

savedatabase

input and output

Entrada: database (word) | file (word)
Salida: none

Saves the specified database under the specified filename. See newdatabase, loaddatabase

savedatabase "database "mydb

savedictionary

input and output

Entrada: dictionaryname | filename
Salida: none

Saves the given dictionary into a file with the given filename. See dictionary, newdictionary

savedictionary "mydict "dictfile

savegif

input and output

Entrada: seconds (number) OR [seconds frameskip]
Salida: 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

input and output

Entrada: seconds (number) OR [seconds frameskip]
Salida: 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

input and output

Entrada: filename (word)
Salida: none

Saves a screenshot of the current output window into the specified filename. For high-resolution captures, use savepng

savepict "mypic.png

saveproc

input and output

Entrada: procedure (word) | filename (word)
Salida: none

Saves the specified procedure into the specified file in the current working turtleSpace project.

saveproc "myproc "myproc.to

saveplot

input and output

Entrada: filename (name) | plotname (name)
Salida: none

Saves the specified plot to the specified file. See plot

saveplot "myplotfile "myplot

savepng

input and output

Entrada: [width height] (list) | name (string)
Salida: 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

input and output

Entrada: modelname (word)
Salida: 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

input and output

Entrada: modelname (word)
Salida: 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

input and output

Entrada: seconds OR [seconds frameskip]
Salida: none

Downloads a WEBM of the graphical screen of the specified duration after that duration has elapsed. Web only

savewebm 20

selectgamepad

input and output

Entrada: gamepad (number)
Salida: 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

input and output

Entrada: path (word)
Salida: none

Sets the current file path. Root / is the current user folder.

setpath "/

setprefix

input and output

Entrada: path
Salida: none

Sets the path for file operations. / is always the root of the user's folder

setprefix "/

setread

input and output

Entrada: filename (word)
Salida: 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

input and output

Entrada: bytes (number)
Salida: 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

input and output

Entrada: name (word)
Salida: 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

input and output

Entrada: filename (word)
Salida: 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

input and output

Entrada: byte (number)
Salida: none

Sets the write position in the currently opened file. See setwrite

setwritepos 60

sharevectors

input and output

Entrada: none
Salida: 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

input and output

Entrada: name (word)
Salida: none

Shows the selected button. Use hidebutton to hide it.

showbutton "button

stlbacking

input and output

Entrada: none
Salida: 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

input and output

Entrada: none
Salida: 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

input and output

Entrada: none
Salida: none

Takes a snapshot (PNG image), and places it in the snapshots folder in the current turtleSpace.

takesnapshot

title

input and output

Entrada: none
Salida: title (word)

Returns the title (filename) of the current turtleSpace.

show title

undo

input and output

Entrada: none
Salida: 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

input and output

Entrada: none
Salida: 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

input and output

Entrada: none
Salida: 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

input and output

Entrada: none
Salida: 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

input and output

Entrada: none
Salida: 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

input and output

Entrada: none
Salida: 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

input and output

Entrada: none
Salida: bytes (number)

Returns the current write position in bytes.

show writepos

writer

input and output

Entrada: none
Salida: filename (word)

Returns the name of the file currently open for writing.

show writer

rc

input and output

Entrada: none
Salida: character

Short form of readchar. Reads a single character from input without waiting for Enter.

make "key rc

rcs

input and output

Entrada: number
Salida: word

Short form of readchars. Reads the specified number of characters from input.

make "input rcs 5

rw

input and output

Entrada: none
Salida: word

Short form of readword. Reads a word from input.

make "name rw