Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if statement- please help

Status
Not open for further replies.

paulw1982

MIS
Joined
Aug 6, 2003
Messages
41
Location
AU
This is the script i have added to a button:

on(release){
for(j=0;j<50;j++){
for(i=0;i<15;i++){
if(_root.boxno.text==box+j){
trace(&quot;FOUND&quot;)
}
}
}
}

i have loads of arrays set up named box1, box2, box3 etc etc

please can somebody tell me the correct syntax for this if statement. I know its something to do with the 'j' but i cant work out how to fix it.

thanks in advance
 
Wasn't the actual line you wanted to post, more like...
Code:
if(_root.boxno.text==box+j[i]){...

And what is _root.boxno.text ?
 
Yep, Sorry!!

Here it is again.

boxno is an input box.

this loop is supposed to search all the arrays for a match.

on(release){
for(j=0;j<50;j++){
for(i=0;i<15;i++){
trace(&quot;box&quot;+j+&quot;[&quot;+i+&quot;]&quot;)
if(_root.boxno.text==box+j){
trace(&quot;FOUND&quot;)
}
}
}
}

 
sorry, ignore that one too.

you are right, it should have the 'i' in there too.

i dont know why it keeps being removed when i post the message.
 
Because the
Code:
[i]
tag is used to print italic text here on this board. Either uncheck the Process TGML box, at the bottom of the reply window or surround your code with code tags... (code) code here... (/code), replacing the parentheses around code with square brackets.
 
on(release){
for(j=0;j<50;j++){
for(i=0;i<15;i++){
if(_root.boxno.text==box+j){
trace(&quot;FOUND&quot;)
}
}
}
}
 
Ok! Now that we've got that straightened out, I must say that I'm not too familiar with &quot;array&quot; stuff, and would like you to provide a little more info...
What is your arrays setup like? Are these multidimensional arrays? 2 seperate arrays?
 
_root.onLoad=function(){
box1=new Array(&quot;1/H/20&quot;,&quot;1/H/21&quot;,&quot;1/H/22&quot;);
box2=new Array(&quot;1/H/17&quot;,&quot;1/H/18&quot;,&quot;1/H/19&quot;);
box3=new Array(&quot;1/E/34&quot;,&quot;1/E/35&quot;);
box4=new Array(&quot;1/E/36&quot;,&quot;1/E/37&quot;,&quot;1/E/38&quot;);
box6=new Array(&quot;1/E/39&quot;,&quot;1/E/40&quot;,&quot;1/E/41&quot;);
box7=new Array(&quot;1/E/19&quot;,&quot;1/E/20&quot;,&quot;1/E/21&quot;);
box9=new Array(&quot;1/E/10&quot;,&quot;1/E/13&quot;,&quot;1/E/14&quot;,&quot;1/E/15&quot;);
box10=new Array(&quot;1/E/11&quot;,&quot;1/E/12&quot;);
}
 
on(release){
for(j=1;j<11;j++){
for(i=0;i<this[&quot;box&quot;+j].length;i++){
trace(this[&quot;box&quot;+j]);
//if(this[&quot;box&quot;+j] == &quot;1/E/14&quot;){
// trace(&quot;FOUND&quot;)
//}
}
}
}

This will trace everything in your arrays. I can't replicate your input box thingy, and have simulated it (with the commented out lines)...
Can you pick it up from here?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top