• Welcome to Valhalla Legends Archive.
 

Treat a String as Code

Started by Soul Taker, November 24, 2004, 04:07 AM

Previous topic - Next topic

Soul Taker

I may be overthinking this and missing an obvious way, but how do I treat a string as code to be executed?
For instance, say I have a string containing "Call SomeFunction(Param, Param2)";  how do I then actually execute the code contained in the string?

MyndFyre

You would need to implement scripting.  I do not believe that this is otherwise inherently supported in Visual Basic; in JavaScript or PHP, you can use the eval() function to treat a string as code.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.


UserLoser.

You might be able to use CallByName

Soul Taker

 >:(
Doesn't look like CallByName would work for what I want.
Guess I'm going to have to skip this and find some complicated way to do it, thanks.

dxoigmn

Quote from: Soul Taker on November 25, 2004, 06:49 AM
>:(
Doesn't look like CallByName would work for what I want.
Guess I'm going to have to skip this and find some complicated way to do it, thanks.

Well what is it you're really trying to accomplish?  Perhaps it can be done in way to use CallByName?

Soul Taker

Quote from: dxoigmn on November 25, 2004, 08:07 AM
Quote from: Soul Taker on November 25, 2004, 06:49 AM
>:(
Doesn't look like CallByName would work for what I want.
Guess I'm going to have to skip this and find some complicated way to do it, thanks.

Well what is it you're really trying to accomplish?  Perhaps it can be done in way to use CallByName?
The only time I've used CallByName was to call control properties.  Unless it can be used for user-defined functions, it won't be useful to me.
I'm working on a workaround now anyway.  Sadly, it won't be as effective as just buffering a bunch of function calls into a string array and then quickly calling them like I wanted to, but it should do pretty much what I intended.