Evaluate a string to run a function?

Discuss problems and solutions.
Post Reply
RufusWhite
Newbie
Posts: 2
Joined: 17 Sep 2012 19:08

Evaluate a string to run a function?

Post by RufusWhite »

Hi,

is there a way of running a script from a string - so for example at right now, I'm just using if():

Code: Select all

if (x) { pgm1(); }
else if (y) { pgm2(); }
else if (z) { pgm3(); }
whereas I'd prefer to do:

Code: Select all

evaluate('pgm' + currentPgm + '();');
is there a way of doing this?

Many thanks!
Rufus
Post Reply