Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
20 June, 2013, 08:36:18 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1]   Go Down
  Print  
Author Topic: Exiting For-loop in a search-subroutine -  (Read 404 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
MGOS
LV5 Advanced (Next: 300)
*****
Offline Offline

Gender: Male
Last Login: Yesterday at 20:43:31
Date Registered: 29 July, 2011, 16:54:53
Location: Germany
Posts: 297


Topic starter
Total Post Ratings: +74

View Profile
« on: 09 December, 2011, 15:51:55 »
0

Not only. I want to stop the for loop if the condition is true. But the function should return the value the index variable of the loop had when it was stopped.
So lets say the Array has the dimension of 5 and is {1,2,0,9,7} and r1 is 9. Then my function goes through the loop, stops at I = 4 and returns 4.
If I looked for let's say 5, the function would return 0, becouse none of the elements in the array had the value 5.

Both of the functions I posted SHOULD do this, but I don't know which one is better / legal axe code.

I know that array indizes usally start with 0, but starting with 1 has some advantages in my case, so I use that.
« Last Edit: 04 September, 2012, 20:50:18 by MGOS » Logged

Click those to see more information Smiley
Current   
Projects: 
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.322 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.