Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently November 6th, 2024, 6:34 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Looping through an array
PostPosted: August 1st, 2007, 10:03 pm 
Offline

Joined: March 8th, 2005, 9:40 pm
Posts: 63
I have a line in a text file that looks like this:
0,1,2,a,g,3 (This could be any length from 1 to 80.)

I use the following script to write this to an array.
get_loc = tloc;
var cloc = new Array
var cloc = get_loc.split(',');

Now I want to read each element in the array to perform an action depending on the value in the element.

I only want to loop to the next element after (another) variable has been changed.

Can anyone please help me to write a script that can do this?

Regards

Neil

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


Top
 Profile  
 
 Post subject:
PostPosted: August 2nd, 2007, 12:11 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Hi Nitro,

Not actually sure what it is you're trying to do. If this loop is supposed to proceed automatically once a variable somewhere else has changed then place a holding looping inside your existing loop.

for (i=0;i<myArray.length;i++)
{

//Your action on the array element goes here!

while (myHoldingVariable == true)
{
wait()
}

myHoldingVariable = true

}


Hope this helps,

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: Incremental counters
PostPosted: August 2nd, 2007, 1:42 am 
Offline

Joined: March 8th, 2005, 9:40 pm
Posts: 63
Hi Mack,
Thanks for your answer....
I have tried to implement your solution, and while I am sure it will work, I am still struggling.
"myHolding Variable" is an incremental counter based on keypresses/mouseclicks. ("var count" adds +1 to each keypress/click entry)

How do I implement this (counter) instead of a boolean value (true/false)?

I know my questions may sound really stupid, but I really am a novice in scripting, and all my websearches in javascript have not been able to resolve my problems. I even bought some books. Javascript topics seem to focus on HTML integration. I am trying really hard to become self sufficient, and actually intially managed to achieve, what I wanted to, with minimal scripting, but then there was a twist in the requirements, which messed everything up, and I had to go via the Opusscript route.
Without this forum, and specifically people like you, I would be completely lost.

Regards

Neil

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


Top
 Profile  
 
 Post subject:
PostPosted: August 2nd, 2007, 8:46 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Morning Nitro,

If this isn't automatic, then you could probably skip the whole holding looping process.

Add an action to your key press / mouse click that calls the function. Add the counter variable to the array

myArray[myCounter]

and then increment the counter at the end of the function ready for the next click or press. This way, the counter goes up one each time the function is run and the array reads the next element.

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: Problem Solved
PostPosted: August 2nd, 2007, 9:37 pm 
Offline

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

Thanks for your help, I eventually managed to solve this. :D

I really appreciate you spending time helping me.

One day, I might even be able to help novices.

Until then I have much to learn...

Regards

Neil

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


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 12 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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group