Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 8:16 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Yet another scripting question
PostPosted: September 10th, 2007, 11:51 pm 
Offline

Joined: February 26th, 2005, 2:44 pm
Posts: 58
Yes, I feel absolutely silly, but this keeps going bizarre on me.
(I am eventually going to go to use Flex, so I do know that this might not be possible in the published file, but I can't get past it not working now.)

I have an array of 40 elements, array name is beewords. Input text is stored in variable beein. I want to compare beein to see if it's in beewords. If so, I want to display it on the screen, and I've been doing it with the variable beelist. I played with the js functions grep and in, but I get unidentified functions using these, so I tried this:

for (x=0;x<beewords.length;x++){
if (beein=beewords[x])
{
beelist+= " " + beein;

}
}


And my return has either been beewords[0] or beewords[39], the first and last element of the array. It also changes beein to beewords[0] or beewords[39]. Not sure why that is happening????

Anyway, any help is appreciated.

_________________
http://www.akidsheart.com
http://www.storyit.com


For this message Roxie has been thanked by : mackavi


Last edited by Roxie on September 11th, 2007, 5:05 am, edited 1 time in total.

Top
 Profile Visit website  
 
 Post subject: Reply
PostPosted: September 11th, 2007, 2:34 am 
Offline

Joined: March 8th, 2005, 9:40 pm
Posts: 63
Hi Roxie,

I am not qualified to help you, :oops:
but maybe the answers, by Mackavi, to this post can help... :D

Code:
//Here's a solution for anybody else that needs to search an array for a specific term.

myWords = "SNAIL,BEE,CRICKET,ANT,FROG,JUNGLE".split(",")

myGuess = "SNAIL"



if (inArray(myGuess)) Debug.trace("Word found - increase score")




function inArray(str)
{
for (i=0;i<myWords.length;i++)
{
if (String.contains(myWords[i], str, true))
{
return true
} else
{
return false
}
}
}


Heres the link to the post.

viewtopic.php?t=2839

Regards

Neil

_________________
Opus Pro V6
Dell Inspiron 9400
Intel Centrino Duo 2GHz
2 Gig Ram
XP SP2


For this message Nitro has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: September 11th, 2007, 3:04 am 
Offline

Joined: November 11th, 2004, 4:05 am
Posts: 636
Location: Christchurch, NZ
if (beein=beewords[x])

should be

if (beein==beewords[x])

two equals signs are required to test if one value is the same as another value.
One equals sign will transfer the value of the second variable into the first one.

Paul


For this message Paul has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: September 11th, 2007, 4:15 am 
Offline

Joined: February 26th, 2005, 2:44 pm
Posts: 58
Thanks for the catch, Paul.

That explains this:
Quote:
It also changes beein to beewords[0] or beewords[39]. Not sure why that is happening????


Still haven't quite figured out why it's only returning beewords[0] or beewords[39]. Guess I'll fiddle a bit more.

_________________
http://www.akidsheart.com
http://www.storyit.com


For this message Roxie has been thanked by : mackavi


Last edited by Roxie on September 11th, 2007, 5:06 am, edited 1 time in total.

Top
 Profile Visit website  
 
 Post subject:
PostPosted: September 11th, 2007, 4:20 am 
Offline

Joined: February 26th, 2005, 2:44 pm
Posts: 58
Thanks, Neil.

It's coming back with an unidentified function if I use inArray.

_________________
http://www.akidsheart.com
http://www.storyit.com


For this message Roxie has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: September 11th, 2007, 1:40 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
To ask but a daft question,

Elements 0 & 39 aren't the only ones containing the beein value are they?

Juts thought i'd check.

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: September 11th, 2007, 5:43 pm 
Offline

Joined: February 26th, 2005, 2:44 pm
Posts: 58
Quote:
To ask but a daft question,

Elements 0 & 39 aren't the only ones containing the beein value are they?

Juts thought i'd check.

Mack


No, I tried all sorts of matches.
I got it working, but I still can't find where I squirreled it up. Basically, I started from scratch and just copied and pasted the code in a new pub of Opus Professional Type, verified that it woked, and then changed the type to Flex. Works fine in the compiled Flash file. Things beyond my understanding...

Now I want to set a timer, check for duplicates in beelist, and compare beewords to beelist for unmatched elements. Not quite sure how to do this, since beelist isn't an array. Think I need to go read and play with it some more.

And all this help is much appreciated.

_________________
http://www.akidsheart.com
http://www.storyit.com


For this message Roxie has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: September 11th, 2007, 10:05 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Hadn't caught the part about Flex - prehaps just one of those strange things :-)

As for the timer use the ticker action.

As for the list, use the split command to seperate demarkations into array elements.

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: September 11th, 2007, 11:12 pm 
Offline

Joined: February 26th, 2005, 2:44 pm
Posts: 58
Quote:
As for the timer use the ticker action.

As for the list, use the split command to seperate demarkations into array elements.

Mack


Thanks, Mack. Going to try to see what I can do, but have to wait until Thursday. Got grandkids now...

_________________
http://www.akidsheart.com
http://www.storyit.com


For this message Roxie has been thanked by : mackavi


Top
 Profile Visit website  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 42 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group