Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   makevar with array? (https://forums.graalonline.com/forums/showthread.php?t=74903)

JkWhoSaysNi 06-26-2007 06:03 PM

makevar with array?
 
This won't work:
PHP Code:

makevar("this.something[0]") = "just testing";
echo(
this.something[0]); 

I could do:
PHP Code:

makevar("this.something")[0

but what I really want to do is this:

PHP Code:

makevar("this.something[0].whatever") = "just testing"

Is there any way to get makevar to work with arrays like this?

Thanks.

Novo 06-26-2007 06:04 PM

Quote:

Originally Posted by JkWhoSaysNi (Post 1322704)
This won't work:
PHP Code:

makevar("this.something[0]") = "just testing";
echo(
this.something[0]); 

I could do:
PHP Code:

makevar("this.something")[0

but what I really want to do is this:

PHP Code:

makevar("this.something[0].whatever") = "just testing"

Is there any way to get makevar to work with arrays like this?

Thanks.

Why not use (@"this.something")[0].(@"whatever"); ?

JkWhoSaysNi 06-26-2007 06:15 PM

hmm actually that doesnt seem to work either

PHP Code:

temp.test "something";
this.(@temp.test)[0] = 5;
echo(
this.something[0]); 

echos null.

JkWhoSaysNi 06-26-2007 07:42 PM

Well I see the problem.

"something[0]" becomes a variable name listed in getVarNames() it doesn't treat it as an array at all :(

Novo 06-26-2007 08:11 PM

Quote:

Originally Posted by JkWhoSaysNi (Post 1322711)
hmm actually that doesnt seem to work either

PHP Code:

temp.test "something";
this.(@temp.test).add(5);
echo(
this.something[0]); 

echos null.


PHP Code:

temp.test "something";
this.(@temp.test) = new[1];
this.(@temp.test)[0] = 5;
echo(
this.something[0]); 


I'd try that. As a blank string, I don't think [0] is even created... The variable type isn't set yet. By doing the


All times are GMT +2. The time now is 08:48 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.