Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

What is the keyword 'execute' used for?

Asked by 9 years ago

I got a bit curious, and wondered if there was a keyword by the name of execute, to my surprise, it is a keyword, but when I use the code print(type(execute)) or print(execute), the Output says nil, also, the ROBLOX Wiki does not have any information on this keyword other than How to Execute a code, you can also change it as an identifier, here's an explanation of what I mean;

local execute = print --The keyword 'execute' is now an identifier for 'print'
local print = "Hello World!" --'print' is now an identifier for the string 'Hello World!'
execute(print) --Output: Hello World!

I am curious on what this type of keyword is used for, or, what it was used for, also, I am not too if the keyword execute has anything to do with String Manipulation.

1 answer

Log in to vote
5
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

The ROBLOX IDE doesn't highlight keywords in the smartest way.

Consider

print(random)

It will highlight random. This is because math.random is a built in function.

There is no significance to the name random on its own (or even much significance to the name math.random since math is just a table and "random" a key in it).


execute is similar. It comes from os.execute, which runs shell commands, e.g.,

os.execute("gcc source.c -o program.exe")

You can't use os.execute in ROBLOX, so it's sort of silly to bold execute anyway.


From Lua Users Wiki

os.execute([command])

Execute an operating system shell command. This is like the C system() function. The system dependent status code is returned.

With no argument, this command returns a non-zero value if an OS shell is presents or a zero value if one is not present.

2
Wow, that explains it all. :o Thanks man! :D Also, I have a question if I may; What is a 'shell command'? This is the first I've heard of it. TheeDeathCaster 2368 — 9y
2
It's stuff that you would type into Command Prompt (on Windows) or Shell / Terminal (on Mac / Linux). Shell / Batch are two very similar languages that it's written in. Usually, at some level the computer is running things in a text-only interface like that, so almost all programming languages give a way to use it. BlueTaslem 18071 — 9y
1
Kind of like the 'loadstring', or command bar in the Studio? TheeDeathCaster 2368 — 9y
2
In a sense, at the level of your operating system. BlueTaslem 18071 — 9y
Ad

Answer this question