Mel: Variable Conversion

From wikinotes
Revision as of 16:08, 6 October 2014 by Will (talk | contribs) (Created page with "= String to int = <pre> string $stringVar = "100"; int $i = $string; </pre> <br> <br> = String to Evaluation = <pre> string $statement = "(99+1) / 2"; eval("float $dummy =" +...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

String to int

string $stringVar = "100";
int $i = $string;



String to Evaluation

string $statement = "(99+1) / 2";
eval("float $dummy =" + $statement);

	//Eval Needs two values to evaluate
	//
	//so you need a second dummy variable to be 0. This
	//only works because it is a local variable, and is
	//re-initialized every time it is run.
	//
	//Unforunately, you cannot simply evaluate "eval(0 + $statement);"