To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.off-topic.geekOpen lugnet.off-topic.geek in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Off-Topic / Geek / 3226
3225  |  3227
Subject: 
Re: Previous and next links a la Brickshelf
Newsgroups: 
lugnet.off-topic.geek
Date: 
Wed, 25 Jul 2001 01:29:00 GMT
Viewed: 
130 times
  
On Wed, Jul 25, 2001 at 01:07:51AM +0000, Bram Lambrecht wrote:
Hi all,
If I have a comma separated text file of the form:
filename.ext,thumbnail width,thumbnail height,img width,img height
for example:

inside3.jpg,100,75,640,480
over.jpg,100,75,640,480
stairs.jpg,100,64,640,410
tower.jpg,78,100,320,410
trellis.jpg,78,100,320,410
waterfall.jpg,100,75,640,480

then what is the best way to grab the next and previous images if I am
displaying, for example, "tower.jpg".  (I'm using PHP, but I can work with perl
too.)  Thanks!

hmmm... dunno php, but try this in perl:

#!/usr/bin/perl -w

$current = shift;
$prev = '';
$next = '';
while (<>) {
  ($name) = split /,/;
  if ($name eq $current) {
    $next = <>;
    ($next) = split /,/, $next;
last;
  }
  $prev = $name;
}

this is untested, but if you put this in a file (say, call it match.pl),
and run it as "./match.pl stairs.jpg file.lst", it should end up with
$next = "tower.jpg" and $prev = "over.jpg".  This doesn't check for
special cases (like the name matches the first or last line), but should
give you an idea...

HTH,

:)

--
Dan Boger
dan@peeron.com



Message has 1 Reply:
  Re: Previous and next links a la Brickshelf
 
(...) I dunno PHP either, but it's very easy to learn as you go along. (...) Thanks once again, Dan. I should have thought of that myself. And it's easy to translate into just about any language. --Bram (23 years ago, 25-Jul-01, to lugnet.off-topic.geek)

Message is in Reply To:
  Previous and next links a la Brickshelf
 
Hi all, If I have a comma separated text file of the form: filename.ext,thumbnail width,thumbnail height,img width,img height for example: inside3.jpg,100,75,640,480 over.jpg,100,75,640,480 stairs.jpg,100,64,640,410 tower.jpg,78,100,320,410 (...) (23 years ago, 25-Jul-01, to lugnet.off-topic.geek)

4 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR