Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Eval? In Actionscript 3



k say i wanted to create a bunch of movieclips in a for loop but wanted to name them something different each time, how would i dynamically name them?example of basically what i want to know how to do
ActionScript Code:
for (var i:Number = 0; i  > 10; i++) {    var eval(myMovieClip+i):MovieClip = new MovieClip();}
but that code won't work as AS3 does not use eval any more so how would i go about doing this?



KirupaForum > Flash > ActionScript 3.0
Posted on: 05-02-2007, 06:36 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

?eval? In ActionScript 2.0
Hi!

I didn't find answer my question...

I would like use eval... but not with variables...

Story:
My Application get any strings from a server in xml...
In string: actionscript commands...
I would like tu execute there...

Example:
<cmd1>i=10;</cmd1>
<cmd2>trace(i)</cmd2>

but i don't know how to i do it... please help me...

Thanks ^_^

Alternate For Eval In ActionScript 3.0
Hi

Anybody knows the alternate for my following code, which was written in AS2..

sender = eval(vArgs[0]);
method = sender[vArgs[1]];
method.apply(sender, [someData]);

thx in advance..
Angel

Actionscript Eval And Array[] Enigma
i stumbled into a little puzzler......
i am using the following actionscript:

_root.num_04="violet"
colorName = eval("_root.num_" + _root.menusArray[4][1] ) ;
_root.array1 = colorName;
_root.array2 = _root.menusArray[4][1];
set("_root." + colorName, []);
set("_root." + colorName + "[1]", _root.menusArray[4][1]);
set("_root." + colorName + "[2]", _root.menusArray[4][2]);
_root.array3 = _root.violet[2];
_root.array4 = eval("_root." + _root.num_04 + "[2]");


menusArray[4][1] holds a text value like "04"
menusArray[4][2] holds a text value like "Company"
[array1....array4 are just dyn text boxes to display values for debugging]


results of dyn text boxes:

array1 ==> [violet ] ...correct
array2 ==> [04 ] ...correct
array3 ==> [ ] .......nothin!
array4 ==> [Company ] ...correct


the question is......why no value showing up for array3?
its got something to do with how the definition of the array is constructed.....using 'eval'

i then added this line of actionscript to further understand what was happening.....

_root.violet[2] = "New Value";
after this addition......
array3 ==> [New Value ]
but....
array4 ==> [Company ] ...not affected!?!

so......
either the definition using 'eval' make the difference
or
the difference lies in the 'eval' used to define the final value....
...as in the diff betw....
_root.array3 = _root.violet[2];
and....
_root.num_04="violet"
_root.array4 = eval("_root." + _root.num_04 + "[2]");


any thoughts would be appreciated.


[Edited by howardroarklives on 04-09-2002 at 03:01 AM]

Using Eval( )
I have a grid of objects all the same into which I'm creating a second object. This second object has an array which I want to access from somewhere else, and when I try to reach the array info using the below I get nothing.

blar = eval("_parent.TheGrid." + thecell + "." + source + ".lblarray[" + i + "]");

Anyone got any idea why, and what I can do about it?

Cheers
Mat

Help With Eval()
Can anyone help. I am trying to: text="new"
here is the code.


text="old";

t=eval("text");

trace("____________");
trace(text);
trace(t);

t="new";
trace(text)

Thanks!

~Sunny

If Else / Or... Eval?
Hi Gang,

I have a loadmovie command been loaded by the input of a textfield "text" like so;

on (release) {
loadMovieNum (text+".swf", 2);
}

How can I tell if a movie has been found, then if not print in another textfield "result" , "No Results found"?

It will kinda work like a search thing as long as you roughly know what the user is inputting its fine.
I suppose a database of the filepaths would be the best with PHP or something but I am new to that stuff, though I am trying to learn.

Thanks in advance

Planethouse

Eval / This ?
Hi every one I am really frustrated two days I have been trying to figure out why this has not worked:

count = 5
for (i=0;i<count;i++){
eval("name"+count)= "bob";
}

kept getting this error:

Left side of assignment operator must be variable or property.

so finally I read up and they switched from "eval" to "this"
http://www.macromedia.com/support/fl...nment_area.htm

well when I did there sample it got rid of the errors, but it will not trace out

this["TextField" + "One"] = "string1"
trace("TextFieldOne")
which should trace out to string1, but I get undefined

the for loop and eval stament above I have used a thousand times before can any one tell me how to make this worl in flash MX

much thanx dave

Help Using The EVAL
i use to use this code on flash 5 and it works without any error but then when i tried using the same code on flash mx.. doesn't work... any idea on how to solve this? this is the code:

for(myCtr=0;myCtr=10;myCtr++){
eval("test"+myCtr)=myCtr;
}

the error on flash mx is:
Left side of assignment operator must be variable or property.


however, that code works on flash 5

Eval Help
can someone tell me why this doesnt work

a = "getURL('asdasdas')";
eval(a);

is there another way to do this?

im using flash mx btw

Help With Eval...
Hi... I need a little help with the eval function.

I want to do something like:
_root.zIMC.activateZone(0);

But I wanted to do it with:

eval("_root.z"+zoneChar+"MC.activateZone(0);");
// where zoneChar would have the "I" (or any other value I want)



I supose this should be easy..... but I'm not being able to do it.

Can anyone tell me where I'm doing the mistake?


Thanks for all the help!

Eval
i have:

var city = london;
var citytext = eval(city+"text");


that works well.

now i have

var city = londontext;
var city = eval(city-"text");

that doesnt give me the result i was looking for.

is there a way to do this?

Eval How Not To Use It?
This file i've got that's using eval wont work now that Flash MX is here! I remember one of the Flash God's taught me how to do it from Macromedia that time when they were in the flashkit.


I know eval is supposed to be depretiated. But cant think of how its supposed to be coded to make it up to date with the Flash MX code now.

All it simply is, is a button(s) numbered 0 to 10 when you press on the button(s) it puts the chr code or (number) in the input text field that has focus.

How do you convert this to Flash MX?

//one btn example for number '0'.
code:
on (release) {
eval(_root.control.select) += chr(48);


//code on a mc to detect it and put the number in whatever input text field is currently has focus!!
code:
onClipEvent (enterFrame) {
variablename = Selection.getFocus();
if (variablename != null) {
select = Selection.getFocus();
if (t=Selection.getFocus()) {
}
_root.qe.gotoAndStop("menu");
}
}


A small example fla of the one working in Flash 5 is there if you need it. Dont worry about the error you get when if you test it, it just because ive named the buttons in the instance panel to start changing it over the Flash MX. But it's working Ok in flash 5 i really need it to be over in Flash MX.

Eval() Help
I can't seem to get eval() to work

I need it to dynamically set a var to Zero ...

I have a 130 spaces ... and I don't want to set each one by hand

example

User clicks space10 -> set spaceName to space10 -> use eval() to combine spaceName and "_amount" -> set to Zero

or

User clicks space130 -> set spaceName to space130 -> use eval() to combine spaceName and "_amount" -> set to Zero

code:
on (release) {
spaceName = _name
eval(spaceName+"_amount") = 0
}

Note: this action is inside a movieclip

is this possible ...

Help With EVAL
I'm trying to do the following. I've got 8 movie clips called "pile1" thru "pile8".

I'm trying to reference them in a for loop, but can't get the right script down to do it. Here's an example:


Code:
for(i = 1; i <= 8; i++){
baseX = eval(pile+i)._x;
baseY = eval(pile+i)._y;
...
}


Anyone know how to work this?

Thanks,

Eval?
why cant you do this??

one = "nav";
two = "text";



eval(one).eval(two) = "him";


i wont to set the "text" in the MC "nav"
eventuall y this will do this

for(z=0; z< 5; z++)
{
eval(one).eval(two+z) = somevarible;
}

help, im really stuck on this one

Eval?
why cant you do this??

one = "nav";
two = "text";



eval(one).eval(two) = "him";


i want to set the "text" in the MC "nav"
eventuall y this will do this

for(z=0; z< 5; z++)
{
eval(one).eval(two+z) = somevarible;
}

help, im really stuck on this one

Using This Instead Of Eval
I am trying to set (in old school):

tellTarget (eval("_root.case_study_mc.mc"+dispMC+".cs_short_m c")) {
gotoAndPlay("open");
}

I am trying to use:

this["_root.case_study_mc.mc" +dispMC+ ".cs_short_mc"] = theTarget
trace("theTarget = "+theTarget)
eval(theTarget).gotoAndPlay("open")

its not working, anyone help me out?

Eval(), Anyone?
AS 2.0

hey, i wrote a function to that takes a value and searches an array to see if that value already exists in that array. for some reason, though, eval() doesn't appera to be evaluating correctly...

if i trace only ob, it finds ob as undefined...


PHP Code:




ob = eval("arr["+i+"]");
trace (ob);







anyone have a clue?

PHP Code:




ret = distinctArr(groupsArr, "gName", myOb.product[i].group);
        if (ret == 0) {
            groupsArr.push({gName:myOb.product[i].group});
        }
function distinctArr(arr, fieldName, val) {
    for (i=0; i<arr.length; i++) {
        ob = eval("arr["+i+"]."+fieldName);
        if (ob==val) return 1;
    }
    return 0;
}

What Exactly Does EVAL(); Do?
Hey guys, i've seen eval(); been used in movies that i've downloaded, but i never understood what it ment, can some one tell me and give me an example of how it would be used. thanks a lot

Something Better Than Eval(...) ?
say i have the following code:

finalX = eval(item)._width/2;

where item is a string, which equals "_root.myMC.myInnerMC"

i've heard that eval is unclassy and inefficient. what is the best way to do this? oh, and item is being passed to the function which contains the above line of code as an argument. is there a better way to pass a reference to a movieclip than by using its target name and path as a string?

thanks.

Eval In AS3
function stick(btnname) {
if (current_btn != btnname) {
eval(current_btn).gotoAndPlay("out");
}
current_btn = btnname;
eval(current_btn).gotoAndStop("down");
}

I belive this would have worked in AS2, but I want to use AS3 and just wonder if there is anything similar to eval?

Eval
I'm trying to update some old script that uses the eval function, but can't seem to convert it over successfully so it works in AS2 player 8+...
For instance I tried replacing eval("subContainer"+j)._alpha = 0 with this["subContainer"+j]._alpha = 0 ... but it didn't want to function.
Here's the old script:
code: function resetMenu() {
for(j=0;j<=(9);j++){
eval("subContainer"+j)._alpha = 0
eval("subContainer"+j)._x = -1000000
eval("subContainer"+j)._y = 0
eval("mainButton"+j).JumpTo(j*mainSpace)
}
}

Eval() Help
I have an array I created called platforms(), which contains a listing of objects.

I can reference the array by platforms[i].name and have a value return. But since I am trying track where they user is I am trying to set the value to a pointer/variable, so can drill down and know were I am at within the array and object structures.

nestLevel = "platforms{" + i + "]"
trace(eval(nestLevel).name)

This give me undefined. What do I need to do so when I trace(platforms[i}.name) and trace(eval(nestLevel).name) I get the same values.

I need to track this data so it is dynamic because as I drop down into the menu, in theory there is a infinite level of submenus.

Eval Help
Hey,

Im trying to create a login system using XML - i found a flash movie that explains it, however it was created in Flash 5. Could anyone help me out and possibly provide a soultion!

If needed I can send the file! Thank you to everyon that may be able to help!

Here is part of the code

PHP Code:



function load_usrXML(success) {    if (success) {        var staff = usrXML.firstChild.firstChild;        i=1;        while (staff != null) {            eval (staff.attributes.TITLE) = staff.attributes.NAME;            eval (staff.attributes.PASSTITLE) = staff.attributes.CODE;            if (staff.attributes.NUM eq "accountnum") {                eval(staff.attributes.NUM) = staff.attributes.VALUE;            }            staff = staff.nextSibling;        }    } else {        trace("error Loading XML File");    }    setObj();} 




Errors Im getting

PHP Code:



**Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 32: Left side of assignment operator must be variable or property.                 eval (staff:String.attributes.TITLE) = staff:String.attributes.NAME;**Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 33: Left side of assignment operator must be variable or property.                 eval (staff:String.attributes.PASSTITLE) = staff:String.attributes.CODE;**Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 35: Left side of assignment operator must be variable or property.                     eval(staff:String.attributes.NUM) = staff:String.attributes.VALUE;Total ActionScript Errors: 3      Reported Errors: 3 

Help With Eval
heya,

alright, so i have written this code. what i am trying to do is get the onRollOver to move several buttons at the same time as well as a movieclip named map_img. i evaluated the button names to work with the loop. buttons test_btn1, test_btn2, test_btn3 are all recognized as buttons; but only test_btn3 is moving.

when i trace btn_name i only get, 'test_btn3'; i need it to trace 'test_btn1, test_btn2, test_btn3'

any ideas to get flash to recognize all 3?

thanks,

kris




Code:
for (i=1; i<=3; i++) {
var btn_name = this["test_btn"+[i]];
//btn_name._alpha = 0;
btn_name.onRollOver = function() {
this._alpha = 100;
this.onEnterFrame = function() {
if (this._x>=600) {
btn_name.targetx += 20;
map_img.targetx +=20;
trace(btn_name);
}
if (this._x<=400) {
btn_name.targetx -= 20;
map_img.targetx -=20;
}
};
};
btn_name.onRollOut = function() {
//this._alpha = 0;
delete this.onEnterFrame;
};
}

Eval() Help
I was using eval to access the instance name of a dynamically created object from an array. But once I made them in another dynamic movieclip just that little code stopped working.

Here is the current unworking code:

ActionScript Code:
function exe() {
    len = roofing.length;
    this.createEmptyMovieClip("containerClip", 50);
    for(var i=0; i<len; i++){
        clip = this.containerClip.attachMovie("largeSwatch_mc", roofing[i][1], i);
        trace(clip);
        clip._x = 7;
        clip._y = 4 + 115*i;
        // assign additional properties here
        clip.name_txt.text = roofing[i][0];
        clip.imgSpace_mc.loadMovie("images/thumb/" + roofing[i][2]);
        clip.clipName = roofing[i][1];
        clip.imgFile = roofing[i][2];
        clip.onRelease = function() {
            _root.selectedBrand = this.clipName;
            this.selector_mc.slideTo(-6, undefined, 0.5, "easeOutCubic");
            for (n=0; n<len; n++) {
                if (roofing[n][1] != this.clipName) {
                    eval(roofing[n][1]).selector_mc.slideTo(74, undefined, 0.5, "easeOutCubic");
                    trace(this._parent.eval(roofing[n][1]));
                }
            }
        }
    }
}


Here is how it was, only slightly different (this one worked with the eval):

ActionScript Code:
function exe() {
    len = roofing.length;
    for(var i=0; i<len; i++){
        clip = this.attachMovie("largeSwatch_mc", roofing[i][1], i);
        trace(clip);
        clip._x = 7;
        clip._y = 4 + 115*i;
        // assign additional properties here
        clip.name_txt.text = roofing[i][0];
        clip.imgSpace_mc.loadMovie("images/thumb/" + roofing[i][2]);
        clip.clipName = roofing[i][1];
        clip.imgFile = roofing[i][2];
        clip.onRelease = function() {
            _root.selectedBrand = this.clipName;
            this.selector_mc.slideTo(-6, undefined, 0.5, "easeOutCubic");
            for (n=0; n<len; n++) {
                if (roofing[n][1] != this.clipName) {
                    eval(roofing[n][1]).selector_mc.slideTo(74, undefined, 0.5, "easeOutCubic");
                    trace(this._parent.eval(roofing[n][1]));
                }
            }
        }
    }
}

I need to make it in that other movie clip to do other things with it, can anyone help? Thank you!

Using Eval
how to make a method call....

eval("_level0.loader_mc" + methodName[0] + "()");

the method[0] will give me something as frame03.

This is not making a call to that particular method.

when I try to do
_level0.loader_mc.frame03(); this calls the method.

Can anybody help me in this forum to get out of this problem which is bugging me.

-- Madhava

Eval
I guess eval is gone is AS3, so what would the equivalent be to do this:


ActionScript Code:
dots.graphics.lineStyle(4,0x99000);
dots.graphics.moveTo(dots.d1.x+5,dots.d1.y+5);
for(var i = 1;i<24;i++){
    eval("dots.graphics.lineTo(dots.d"+i+".x+5,dots.d"+i+".y+5);");
}

Eval And []
What´s the diference between eval and []?
like this


Code:
myfunction = function(arg){
trace(arg);
}
mystring= "myfunction";
_root[mystring]("Am I crazy?");
why this works?
and this not?

Code:
x="trace"
[x]("ok")
and this works
[code
x="trace"
eval(x)("ok")
[/code]

can anyone tell me the diference?
THanks

Eval() And This[]
Hi,

Sounds that eval() or this[] fails to dynamically build an array of arrays. What's wrong here ? (replacing this[] by eval() doesn't work better.... )


PHP Code:



collection1=["A0","A1","A2"];
collection2=["B0","B1","B2"];
collection3=["C0","C1","C2"];

//building allMyColl[] array...
var i=0;
while (this["collection"+i][0]!=undefined){
    allMyColl.push(this["collection"+i]);
    i++;


What Does Eval() Do?
I've seen this used a lot but I have no clue what it does. What is the purpose of the eval() function?

Using Eval
Hello, can someone please tell me how to use eval to access the rotation property of this object:
_level0.matilda.turret.rotation .
I successfully attached it using eval as below.

eval("matilda"+i).attachMovie("turret", "turret"+i, getNextHighestDepth());

then I try to use eval unsuccessfully:
eval("matilda"+i).eval("turret"+i)._rotation = 45;

thanks kindly for any help.





























Edited: 02/08/2008 at 11:38:15 AM by phil1943

Using Eval?
Ok I need to do this

take pc:PendingCall = service.getItemsList(0);

to
var remoteInfo:Array = new Array('getItemsList(0)');

and somehow make

pc:PendingCall = service.getItemsList(0);

I tried using eval to no avail, is there any way to do this?

Thanks!

Eval()
what is the equivalent of eval("mov"+j).x in actionscript 3.0

Eval?
I use component with a string parameter "effecttext" and a boolean parameter dynamicinput. AS2 i used;

if (dynamicinput) {
fxtext = eval(effecttext);
}else{
fxtext = effecttext;
}

Then if a component user selected "dynamicinput" then he/she could type the name of some variable he/she somewhere defined and the script would eval() what was typed and used the value of whatever was defined in that variable.

Any suggestion on how to do that in AS3?
P

Eval() In AS3?
ActionScript Code:
xml_data = new XML(event.target.data);data_result = (xml_data.server.connection).toString();


This codesnippet returns data from an XML document but I need to make the part server.connection dynamic, as a variable string. Instead it could be xml_data.server.serverURL. I´ve looked at examples on net and here on Kirupa but still - Nope.

Almost Eval()
Been trying once again to achieve a AS2 eval() equivalent.

- I have a variable in main timeline var test:String = "Hello World";
- I have a MC with a user input text field for variable effecttext
- I put MC on main timeline and type in text input field test

Now if in the MC I do the action
trace( parent[effecttext] );
it nicely traces Hello World

But if it type in input field parent.test
and do the action
trace( this[effecttext] );
I get a undefined instead of Hello World.

If it would allow the path to be typed in the text field, one basically would have the old AS2 eval() back. Seems I'm so close... Anybody any thoughts?

How To Do W/out Eval?
I want to call different functions with any number of params.

in AS 2 I would probably do something like:

Code:
str = '';
for(var i in params) {
i != 0 : str += ',' : null;
str += params[i];
}
eval(func_name + "(" + str + ");");
Not sure if I could even do that in AS2, but how would something like that work in AS3?

Thanks-

Using Eval In AS 2.0
Here is what I have done and it works but I thought eval was done away with in AS 2.0, id is a number


Code:
path = "Screen" + id + ".dragger";
path = eval(path);
Is this the right way to do this?

AS Eval() Vs PHP Eval()
in PHP, eval works like this:
'Evaluate a string as PHP code'
http://uk2.php.net/manual/en/function.eval.php

however in pesky AS its like this:
'Function; accesses variables, properties, objects, or movie clips by name. If expression is a variable or a property, the value of the variable or property is returned. If expression is an object or movie clip, a reference to the object or movie clip is returned. If the element named in expression cannot be found, undefined is returned.'
http://livedocs.macromedia.com/flash...=00001346.html

Now my question is Is it possible to use eval like I can in php?

something like this:

myString = '_root.play; alert("monkeys!");'
eval(myString);

doesnt work... anyone know of any workarounds?

To Eval() Or Not To Eval()
Came across an interesting Flash oddity today...

I have a component that contains a text field, and am populating it with a large amount of text (>1MB), which causes memory usage on my PC to skyrocket. I am instantiating the component using the standard syntax:


ActionScript Code:
var myTextComponent = new TextComponent(args);


and then addressing the components methods like this:


ActionScript Code:
myTextComponent.setText(myText);


Pretty straightforward, right? Well, here's the odd thing... I have found that using the following syntax saves me 10 MB of RAM:


ActionScript Code:
eval(myTextComponent).setText(myText);


Can anyone explain why? My hunch is that by evaluating the variable, I am addressing the object in a more direct manner, whereas addressing the variable would somehow keep an extra instance of the object in memory... Thoughts?

(If I were not loading such a huge amount of text, I'm sure my RAM savings would be nowhere near 10 MB...)

Eval On MX
I have been doing flash actionscripting for a while now...but i have come across a little problem..


I have code in Flash 5, that works fine, but i am recreating a site in flash mx, but some of the functions do not seem to work, its either my bad coding, or some stuff that was allowed in Flash 5, does not seem to work in Flash MX..

i use to have a line in Flash 5

i have a series of buttons, named pcb1, pcb2 pcb3..... and so on....

i have a loop i go through, and do some checks.....

and this is the line that is giving me problems...


eval("pcb"+leftbtn).gotoAndStop(1)

in flash 5 this line works fine, but as soon as i put it in flash mx, it stops working..

I have read up on some stuff, that i need to use

this["pcb"+leftbtn].gotoAndStop(1)

but this does not seem to work neither..


can some one please help me with this dilemma..

what am i doing wrong!!!!

Eval Problem
I set "eval" in under script, but not work just jump to "setProperty"........

on (press)
starDrag (this, true)
// "drag" movie inside on layer 2 is "hit button"; layer 1 is a garbage. script is set into hit button.

on (release)
eval(_root.drag._droptarget)==_root.destination;
setProperty (this, _visible, false);

Above is i do action with movie name "drag" a garbage to trash "destination", but not work!!!

anybody can help??? ;-(

Eval Evils
eval("_root."+eyeName+".movedthing._x") = a;
eval("_root."+eyeName+".movedthing._y") = b;

trace("_root."+eyeName+".movedthing._x: "+ eval("_root."+eyeName+".movedthing._x"));

Ok. In this piece of code I set the ._x and ._y properties of a movie clip. I then read it with the trace, and the value I've set is there. However, the actual position of the object doesn't change.

If I change the position of the object without eval, referencing the object directly, all is well.

And if I try to send the data to a dynamically named textbox like in:

eval("_root."+eyeName+"Text") = a;

Eval - Is There A Better Way For Flash 5
This is probably a really stupid anally uptight question. Because what I am doing works.

Flash5 indicates "eval" as depreciated. I use it all the time to return the variable value of a string. What is the correct way. I saw an example 4 to 5 months ago that used [ ] (array access operator) to do the same thing. I cannot make it work and cannot find the post.

I mainly use "eval" when I am concatinating string expressions and need the result to be the variable value of the concat string rather than the literal string.

If that made any sense?

Is there a better approach to this:

currentitem = eval ("menu" + i + ":n")

giving the value of the variable:
menu5:n
as
currentitem = "about us"

my butt just can't take it any more Could someone equally uptight enlighten me with the answer so I can get over it. and hey, could you correct my spelling while your at it...

thanks, Rob

Eval Question.
It's something interesting, but I don't know why this kind of thing exists.
I have found codes like this.
------------------------
i=3;
a=eval(m add "i");
trace(a);
------------------------
Coz "m" is an undefined variable, we have "3" in the output window.

but when I have a movieclip which has "m" as it's name.
we got nothing in output window. And we have variable "a" as reference of "_level0.m3".
Why? Can someone explain this?

'eval' Problem, Please Help
hi,
i want to create new Objects dynamically, depending on an Array....

basically i wrote this function :

function theObject(name){
this._name=name;
}

Using Eval In Version 4
I'm trying to use eval for something going on a pocketPC so I need to save it out in version 4.

This statement works ok in 5...

text=eval("text"+c)

but not in 4

the help file mentions using "slash" notation.

could sure use a whack upside the noggin!

thanks

Eval And Arrays
I've created a series of variables as follows:

Code:
// DB info
fieldNum = 6;
field0 = "idArray";
field1 = "nameArray";
field2 = "firstnArray";
field3 = "lastnArray";
field4 = "passwordArray";
field5 = "answerArray";
field6 = "datecompArray";
//
I wanted to use a for..next to cycle through each of these variables and use their value to create a new array for each as follows. Then retrieve a value from the allUsers array and pass it to a position in the newly created array.


Code:
// Initialize the Arrays
for (i = 0; i <= fieldNum; i++) {
thisName = eval("field" add i);
eval(thisName) = new Array();
trace ("***This array : " add eval(thisName) add " is this long " add eval(thisName).length);
}
// Fill the Arrays with info
for (i = 0; i <= allUser.length; i=i+(fieldNum + 1)) {
for (J = 0; J <= fieldNum; J++) {
thisName = eval("field" add J);
set (eval(thisName)[userNum], allUser[i+J]);
trace ("This array : " add eval(thisName) add " is this long " add eval(thisName).length);
}
userNum = userNum+1;
}
I've managed to get myself thoroughly lost in the eval() function. The idea is to use the following to evaluate the variable thisName to value, then use that value to create an array :

Code:
for (i = 0; i <= fieldNum; i++) {
thisName = eval("field" add i);
eval(thisName) = new Array();
trace ("***This array : " add eval(thisName) add " is this long " add eval(thisName).length);
}
I will say that the trace statment with the stars after it does produce a value of 0 when I run it so it appears that it might be creating the arrays, but the seond half of the code doesn't seem to be able to get the values into the array. I also tried using .toString and String(). Any help concerning th use of eval in this way to create and reference an array name via a variables value would be amazing.. thanks.
[Edited by Ogsite on 12-20-2001 at 06:06 PM]

Copyright © 2005-08 www.BigResource.com, All rights reserved