• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need help with another loop

 
nicky sajdok
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again
The code below prints out this
[7,4,2,1,0]
addr1, id, phone, lastname, firstname
[9,8,6,5,3]
town, addr2, postcode, county, country

my problem now is that i want to put another loop inside of it so that my code will print this
ben
[7,4,2,1,0]
addr1, id, phone, lastname, firstname
alex
[9,8,6,5,3]
town, addr2, postcode, county, country
this is my loop.

thanks
nicky
 
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may have to do a triple loop, with {Ben, alex} at the outest, and manage to print the name just once.
 
nicky sajdok
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and how would i do this?
thanks
nicky
 
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i=0; i<2; i++
{
if (j + k) == 0
{
print( array[i] )
}
j=0; j<4; j++
{
k=0; k<4; k++
{
}
}
}
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I think Don was saying.
 
nicky sajdok
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried your idea but i just cant seem to get it to work
any other ideas please
thanks
nicky
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you need to understand how loops work I would suggest you start with a simpler demo example.

Start with these. Change the values, change what is printed, add code and see what happens...
 
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the bugs. I was in a hurry this morning.
To get this:
ben
[7,4,2,1,0]
addr1, id, phone, lastname, firstname
alex
[9,8,6,5,3]
town, addr2, postcode, county, country

 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure exactly what you are trying to show here, but the line

inside of this 'for'

doesn't make much sense to me.
 
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here j==0 is extra. It looks like I can just print out the two statements.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic