Re: string_exec()

new topic     » goto parent     » topic index » view thread      » older message » newer message
ryanj said...

I still do not understand why string_exec() would be useful. Would someone please show a code example that demonstrates what string_exec() can do that can't currently be done in Euphoria, or that would make something easier to do?

I cannot show you that using a sandboxed string_exec().

However, using a eval() with access to the program environment,

Tiggr, what is 5 + 4? 
-- Tiggr munges to the question to discover the unknown you ask about 
-- Tiggr builds a variable sentence in various ways,  
-- including your nick (or a variation), 
-- various pleasantries (or not), various text colors, etcs,  
-- and appends the unknown, in this case : $calc(4+5) 
-- and then simply putting the variable name on a line in the code will execute it 
You may think that's trivial to do, all you need do it write a case stack (or maybe a map) using all the numbers that will ever be asked, and all the variables that will ever be asked, and all the math/boolean operations on those numbers and vars that will ever be asked. And make sure those vars exist before you see if they have a value, or your app will crash.

You'd use this in your forthcoming spreadsheet, where a user entered a previously unknown formula into a cell, using the results of other formulas entered into other cells. Hopefully, you will lack the constraints of a sandbox on the eval(), in which case you'll filter the formulas against a list of illegal commands. You could also place all your eval calls in one include file, so the eval could be restricted to the scope of that include.

There's various procedures using string eval that are useful in some forms of Ai.

Kat

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu