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.

problen with lreplace

Old posts that have not been replied to for several years.
Locked
C
Careto
Voice
Posts: 11
Joined: Tue Mar 02, 2004 1:33 pm

problen with lreplace

Post by Careto »

then not like thus causing that it says to me to that line belongs borra1 and being able to erase that line of the file.

Code: Select all

set borra1 "</table>"
set modfile [open index.php "r"]
set todo [read -nonewline $modfile]
close $modfile
set lee [split $todo "\n"]
set lee [lreplace $lee $borra1 $borra1]
set modfile [open $modfile "w"]
puts $modfile [join $lee "\n"]
close $modfile
but error: bad index "</table>": must be integer or end?-integer?

how I can know to that I number of line belongs?
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

i think its correct me if i am wrong eh
from what i remember

Code: Select all

lreplace $arg 1 2 $args
if u wana wana replace the the seconds argument of $arg with $args
XplaiN but think of me as stupid
C
Careto
Voice
Posts: 11
Joined: Tue Mar 02, 2004 1:33 pm

Post by Careto »

it does not work, gives the following error me:

Code: Select all

set borra1 "</table>"
set modfile [open index.php "r"]
set todo [read -nonewline $modfile]
close $modfile
set lee [split $todo "\n"]
set lee [lreplace $borra1 1 2 $borra1]
set modfile [open $modfile "w"]
puts $modfile [join $lee "\n"]
close $modfile
error: Tcl error [encuesta]: list doesn't contain element 1

what I want is that in the file, borra1 is eliminated, is to say </table > since she is one of the part of the end of the file. thanks of all way
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

maybe change it to 0 end if its only one element cause, from what i understand is that the list doesn't contain more then 1 element .. so what is it that u wana replace ??

from what i understand ur using it wrong ..
set lee [lreplace $lee $borra1 $borra1]

=> set lee [lrepace $lee 1 2 $borra1]
XplaiN but think of me as stupid
C
Careto
Voice
Posts: 11
Joined: Tue Mar 02, 2004 1:33 pm

Post by Careto »

not work, error
bad index "</table>": must be integer or end?-integer?
index it must of being numerical?
C
Careto
Voice
Posts: 11
Joined: Tue Mar 02, 2004 1:33 pm

Post by Careto »

corrected with:

Code: Select all

set modfile [open index.php "r"]
set todo [read -nonewline $modfile]
close $modfile
set lee [split $todo "\n"]
regsub -all "</table><p>" $lee "" lee
thanks Ofloo
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

np u can also use string map check out the manual for string map
XplaiN but think of me as stupid
Locked