String to Code

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
MagicianFB
Posts: 11
Joined: Mon Oct 10, 2005 8:45 am

String to Code

Post by MagicianFB »

Is there any way to convert a string to normal code?

for example

Code: Select all

print(tocode("3+3"))
would print 6
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

<Deleted>
Geo Massar
Retired Engineer
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

save to file and dofile() ?
any better ideas?
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
MikeHaggar
Posts: 116
Joined: Mon Jul 18, 2005 2:20 am

Post by MikeHaggar »

Why would one need that?
Bob535
Posts: 56
Joined: Fri Nov 04, 2005 6:52 am

Post by Bob535 »

You could use it to return code from a function, although there are ways around this of course. One use may be for if you are inputing code via a text editor to be run by the program.
MikeHaggar
Posts: 116
Joined: Mon Jul 18, 2005 2:20 am

Post by MikeHaggar »

heh... ok
MagicianFB
Posts: 11
Joined: Mon Oct 10, 2005 8:45 am

Ok.. got it

Post by MagicianFB »

print(assert(loadstring("3+3"))) -> 6
Post Reply