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.

Moving back one line

Old posts that have not been replied to for several years.
Locked
S
SomeGuy
Voice
Posts: 13
Joined: Sat May 01, 2004 5:25 pm

Moving back one line

Post by SomeGuy »

I'm trying to parse a webpage, and basically the main name is on the second line, while the status is on the previous line.

Now my script parses the webpage, finds the main name, but now i need to move up one line to catch the status.

ie,

<img src=up.gif><br>
<font size=3>Main name</font>

Now, my script allows for adding and deleting of different names, so it needs to do this in the while loop, now, I'm pretty sure I can handle everything except this one part, never done anything like this before.

Thanks
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

read the webpage line by line in a list; then you can access any line by index
S
SomeGuy
Voice
Posts: 13
Joined: Sat May 01, 2004 5:25 pm

Post by SomeGuy »

Can you just post an example on how I would use index to dynamically choose lines?
User avatar
arcane
Master
Posts: 280
Joined: Thu Jan 30, 2003 9:18 am
Location: Germany
Contact:

Post by arcane »

Code: Select all

incr current_index -1

Code: Select all

[expr $current_index - 1]
or just use

Code: Select all

$lines($current_index - 1)
:?:
aVote page back online!
Check out the most popular voting script for eggdrop bots.

Join the metal tavern!
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

arcane wrote:

Code: Select all

$lines($current_index - 1)
that won't work

here's what I had in mind:

Code: Select all

set status [lindex $lines [expr [lsearch $lines "*Main name*"] - 1]]
User avatar
arcane
Master
Posts: 280
Joined: Thu Jan 30, 2003 9:18 am
Location: Germany
Contact:

Post by arcane »

ah yeah, you were talking about lists and not arrays...
my fault.
anyway, i gave him 1 not working solution and 2 working, that's 67% - not too bad :mrgreen:
aVote page back online!
Check out the most popular voting script for eggdrop bots.

Join the metal tavern!
S
SomeGuy
Voice
Posts: 13
Joined: Sat May 01, 2004 5:25 pm

Post by SomeGuy »

You guys rock, thanks for the help.
Locked