Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Dynamics (https://forums.graalonline.com/forums/showthread.php?t=70516)

fowlplay4 12-01-2006 12:59 AM

Dynamics
 
A small concern..
PHP Code:

function onCreated() {
 
temp.func "onTest";
 
temp.paramz = {1,2,3};
 (@
temp.func)(@temp.paramz);
}
function 
onTest(j,e,r) {
 echo(
"Test:" SPC j SPC e SPC r);
}
/*
RC Output:
Test: 1,2,3 0 0
 
Result:
j=1,2,3
e=0
r=0

Desired Result:
j=1
e=2
r=3
*/ 

Is there another way I can workaround this without using else if statements, like in my below example?

PHP Code:

function onCreated() {
 
temp.func "onTest";
 
temp.paramz = {1,2,3};
 if (
temp.paramz.size() == 3) (@temp.func)(temp.paramz[0],temp.paramz[1],temp.paramz[2]);
 else if (
temp.paramz.size() == 2) (@temp.func)(temp.paramz[0],temp.paramz[1]);
 else if (
temp.paramz.size() == 1) (@temp.func)(temp.paramz[0]);
}
function 
onTest(j,e,r) {
 echo(
"Test:" SPC j SPC e SPC r);



Skyld 12-01-2006 01:18 AM

Um, foo({1, 2, 3}); is not the same as foo(1, 2, 3);.

You're giving it an array as the only parameter, therefore you will only get an array.

Chompy 12-01-2006 01:30 AM

PHP Code:

function onCreated() {
 
temp.func "onTest";
 
temp.paramz = {123};
 (@
temp.func)(@temp.paramz);

function 
onTest(p) {
 
temp.letters = {NULL"j""e""r"};
 
this.count 0;
 for(
temp.paramtemp.p)
 {
  
this.count++;
  (@ 
temp.letters[this.count]) = temp.param;
 }
 echo(
"Test:" SPC j SPC e SPC r);


Made this fast, dunno if it was something like this

fowlplay4 12-01-2006 02:49 AM

Hmm..
PHP Code:

function onCreated() {
 
temp.func "onTest";
 
temp.paramz = {1,2,3};
 (@
temp.func)(@temp.paramz);
 
/*
 (@temp.paramz) - returns  "1,2,3"   not {1,2,3}
 I see that "1,2,3" would be a string right?
 Would there be a way I could get it recognized as, without using that method Im currently using?
 onText(1,2,3); Is what I would like to acheive.
 If no one gets what Im saying, thanks anyway.
 */



Tolnaftate2004 12-01-2006 03:25 AM

Quote:

Originally Posted by fowlplay4 (Post 1248974)
Hmm..
PHP Code:

function onCreated() {
 
temp.func "onTest";
 
temp.paramz = {1,2,3};
 (@
temp.func)(@temp.paramz);
 
/*
 (@temp.paramz) - returns  "1,2,3"   not {1,2,3}
 I see that "1,2,3" would be a string right?
 Would there be a way I could get it recognized as, without using that method Im currently using?
 onText(1,2,3); Is what I would like to acheive.
 If no one gets what Im saying, thanks anyway.
 */



You're only passing one argument...
(@temp.func)(1,2,3);
It's a variable function name, and as such the parameters are sent just like they would in any other function.


All times are GMT +2. The time now is 01:16 AM.

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