This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

sugestion

Old posts that have not been replied to for several years.
Locked
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

sugestion

Post by caesar »

I have a list of movies with date of appearing and it's votes written in a variable or even in a file, dosen't matter. What I want to do is to split the list in some pages, to have 15 movies on a page, another 15 on th next page and so on till It's empty. I would like some sugestions on how should I complete this task. I have some ideeas of my own, but I want to see/compare mine with others.
Once the game is over, the king and the pawn go back in the same box.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Use a for loop?
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

a loop with a counter
then use the mathematic DIV cmd (if there is such a thing in TCL) to check if the counter is able to be divided trought 15 (alà if {[expr $ctr div 15] = 0})
if yes -> increase the page-jump-counter by one
G
GeoMan59
Voice
Posts: 10
Joined: Wed Jul 24, 2002 11:57 am

Post by GeoMan59 »

Don't need a div command i would think. You could do two things, you could store it in a temp var and take away 15 every time until you either go negative/zero or detect that the number is below 15, depending on where u check. Or you could do normal division and check to see if the number was below or equal to 15...

Tell me if that makes sense :)
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Give me an example of how should I mess around inside the for loop. I've played with it and screwd it all the time. The thing is that inside this loop I got to store in a html file only 15 movies with ther coments, date and etc. then move to the next page and continue with other 15 and so on..
Once the game is over, the king and the pawn go back in the same box.
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

Code: Select all

set movies(count) 0
set in [open mymovies.txt r]
while {![eof $in]} { 
	incr movies(count)
	set movies($movies(count)) [gets $in]
}
this should read all lines from the file into the array

Code: Select all

set ctr 1
set ctr2 0
set ctr3 0
while {$finished == 0} {
	incr ctr
	incr ctr3
	if {$ctr == 15} {
		set ctr 1 
		incr ctr2
	}
	set page($ctr2,$ctr) $movie($ctr3)
	if {$ctr3 == $movies(count)} {set finished 1}
}
i'm sorry i cant test it right now, but i think it should work
the output will be an array (page) with page(1,3) == "Desperados" for example

the output into the html template shouldnt be a problem afterwards
Locked