473,396 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

question about cycling through a series of functions

How would I create another function that would cycle sequentially
through each of these? like 1..,2..,3,..4,..1,..etc..

function1() { something }
function2() { something }
function3() { something }
function4() { something }

Jul 23 '05 #1
4 939

"Julia Briggs" <ju*******@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
How would I create another function that would cycle sequentially
through each of these? like 1..,2..,3,..4,..1,..etc..

function1() { something }
function2() { something }
function3() { something }
function4() { something }

function5()
{
loop
call the other functions
end loop
}
MK

Jul 23 '05 #2
Ivo
"The Mighty Krell" wrote
"Julia Briggs" wrote
How would I create another function that would cycle sequentially
through each of these? like 1..,2..,3,..4,..1,..etc..

<snip>
Using eval():

function fun1() { alert( 'Greetings from function ' + 1); }
function fun2() { alert( 'Hello from function ' + 2); }
function fun3() { alert( 'Hi from function ' + 3); }

function go() {
for( var i=1; i<4; i++ ) {
eval( 'fun' + i + '()' );
}
}
go();

Loop through function go() as often as you like.
hth
--
Ivo
Jul 23 '05 #3

"Ivo" <no@thank.you> wrote in message
news:42***********************@news.wanadoo.nl...
"The Mighty Krell" wrote
"Julia Briggs" wrote
How would I create another function that would cycle sequentially
through each of these? like 1..,2..,3,..4,..1,..etc..

<snip>
Using eval():

function fun1() { alert( 'Greetings from function ' + 1); }
function fun2() { alert( 'Hello from function ' + 2); }
function fun3() { alert( 'Hi from function ' + 3); }

function go() {
for( var i=1; i<4; i++ ) {
eval( 'fun' + i + '()' );
}
}
go();

Loop through function go() as often as you like.
hth
--
Ivo

Why in the world would you use eval for something this trivial?

Jul 23 '05 #4
The Mighty Krell wrote:
"Ivo" <no@thank.you> wrote in message
news:42***********************@news.wanadoo.nl...
"The Mighty Krell" wrote
"Julia Briggs" wrote

How would I create another function that would cycle sequentially
through each of these? like 1..,2..,3,..4,..1,..etc..


<snip>
Using eval():

function fun1() { alert( 'Greetings from function ' + 1); }
function fun2() { alert( 'Hello from function ' + 2); }
function fun3() { alert( 'Hi from function ' + 3); }

function go() {
for( var i=1; i<4; i++ ) {
eval( 'fun' + i + '()' );
}
}
go();

Loop through function go() as often as you like.
hth
--
Ivo


Why in the world would you use eval for something this trivial?


Not that its "trivial". But why use it when its not needed?
function go(){
for (var i=1; i<4; i++){
window['fun'+i]()
}
}

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

51
by: Casper Bang | last post by:
My question is fundamental I beleive but it has been teasing me for a while: I have two classes in my app. The first class is instantiated as a member of my second class. Within this first class,...
2
by: solartimba | last post by:
Hi, I am in another country, and I need to finish a program. But I do not have any reference books. Can you tell me how to print this to a file without ending the stream with an endl. Stated...
2
by: farrell77 | last post by:
I have a pivot chart that displays 3 data series. Series 1 values range from 17 to 106. Series 2 values range from 1 to 18. Series 3 values range from 0 to 1. When I display all three series...
2
by: Sha Crawford | last post by:
I have a series of images called shacam1, shacam2..... shacam(n) I want these to appear on my blog as if they were a feed from a webcam. I need a little piece of code to select a random image to...
15
by: Quackker12 | last post by:
is there a function in ansi c that does this? sigma(2^n/n!,0,infinity,n); syntax sigma(expression, start, end, variable); may be expression could be a function.... I know you can do this...
3
by: jason | last post by:
is there a way to set up an array of bits of generic size, cycle through all the possible bit patterns, and detect a sub-pattern within the bit pattern? for cycling through possible patterns: i...
14
by: Rob Meade | last post by:
Hi all, I'm working on a project where there are just under 1300 course files, these are HTML files - my problem is that I need to do more with the content of these pages - and the thought of...
7
by: Ryan | last post by:
I'm in the process of learning more about building my ASP.NET website to use my SQL datastore and am a bit confused about how ADO.NET works with ASP.NET. This Microsoft article implies that using...
5
by: Ray Tomes | last post by:
Hi Folks I am an old codger who has much experience with computers in the distant past before all this object oriented stuff. Also I have loads of software in such languages as FORTRAN and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.