Error processing request

Parameters

CONTENT_LENGTH0
REQUEST_METHODGET
REQUEST_URI/revision/inserting+lines+in+between+a+file+and+not+end+of+line?V=3
QUERY_STRINGV=3
CONTENT_TYPE
DOCUMENT_URI/revision/inserting+lines+in+between+a+file+and+not+end+of+line
DOCUMENT_ROOT/var/www/nikit/nikit/nginx/../docroot
SCGI1
SERVER_PROTOCOLHTTP/1.1
HTTPSon
REMOTE_ADDR172.71.254.203
REMOTE_PORT52228
SERVER_PORT4443
SERVER_NAMEwiki.tcl-lang.org
HTTP_HOSTwiki.tcl-lang.org
HTTP_CONNECTIONKeep-Alive
HTTP_ACCEPT_ENCODINGgzip, br
HTTP_X_FORWARDED_FOR13.58.197.26
HTTP_CF_RAY876e21d42ff72191-ORD
HTTP_X_FORWARDED_PROTOhttps
HTTP_CF_VISITOR{"scheme":"https"}
HTTP_ACCEPT*/*
HTTP_USER_AGENTMozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; [email protected])
HTTP_CF_CONNECTING_IP13.58.197.26
HTTP_CDN_LOOPcloudflare
HTTP_CF_IPCOUNTRYUS

Body


Error

Unknow state transition: LINE -> END

-code

1

-level

0

-errorstack

INNER {returnImm {Unknow state transition: LINE -> END} {}} CALL {my render_wikit {inserting lines in between a file and not end of line} {Hi,

I am looking to insert a couple of lines in the output. The problem is that when I try "puts $fh..." the lines are inserted only at the end of the output file and not immediately, where the last line was read...

I've attached a sample script to make more sense of my problem..... The output file which needs modification is attched after the script...

======
#------------
Sample script
#------------

set fh [open "...123.txt" r+]
while {[gets $fh line] > 0} {
        set temp $line
        if {[string eq [lindex $temp 0] "12345"]==1} {
                puts $fh "one two three four five"
                } elseif {[string eq [lindex $temp 0] "67890"]==1} {
                        puts $fh "six seven eight nine zero"
                } else { 
                }        
        }

#--#--#--#--#--
======
Existing output file

======
12345

45678

Insert the names of the above digits...

...immediately after the number

67890

90123

...& not at the end

This is the End of line. Do not print below this!!
=======

[AM] (25 september 2011) This is only possible by making a copy of the file and renaming it:

======
set fh [open "...123.txt" r]
set fhout [open "...123.txt-new" w]
while {[gets $fh line] > 0} {
        puts $fhout $line
        set temp $line
        if {[string eq [lindex $temp 0] "12345"]==1} {
                puts $fhout "one two three four five"
                } elseif {[string eq [lindex $temp 0] "67890"]==1} {
                        puts $fhout "six seven eight nine zero"
                } else { 
                }        
        }
close $fh
close $fhout
file rename "...123.txt-new" "...123.txt"
======

This is not a limitation of Tcl - this is an operation that the operating system does not support
directly. It simply cannot shift the data "downwards" - just think of a file of several millions
of lines and you want to insert a new line after each original line ...} regexp2} CALL {my render {inserting lines in between a file and not end of line} {Hi,

I am looking to insert a couple of lines in the output. The problem is that when I try "puts $fh..." the lines are inserted only at the end of the output file and not immediately, where the last line was read...

I've attached a sample script to make more sense of my problem..... The output file which needs modification is attched after the script...

======
#------------
Sample script
#------------

set fh [open "...123.txt" r+]
while {[gets $fh line] > 0} {
        set temp $line
        if {[string eq [lindex $temp 0] "12345"]==1} {
                puts $fh "one two three four five"
                } elseif {[string eq [lindex $temp 0] "67890"]==1} {
                        puts $fh "six seven eight nine zero"
                } else { 
                }        
        }

#--#--#--#--#--
======
Existing output file

======
12345

45678

Insert the names of the above digits...

...immediately after the number

67890

90123

...& not at the end

This is the End of line. Do not print below this!!
=======

[AM] (25 september 2011) This is only possible by making a copy of the file and renaming it:

======
set fh [open "...123.txt" r]
set fhout [open "...123.txt-new" w]
while {[gets $fh line] > 0} {
        puts $fhout $line
        set temp $line
        if {[string eq [lindex $temp 0] "12345"]==1} {
                puts $fhout "one two three four five"
                } elseif {[string eq [lindex $temp 0] "67890"]==1} {
                        puts $fhout "six seven eight nine zero"
                } else { 
                }        
        }
close $fh
close $fhout
file rename "...123.txt-new" "...123.txt"
======

This is not a limitation of Tcl - this is an operation that the operating system does not support
directly. It simply cannot shift the data "downwards" - just think of a file of several millions
of lines and you want to insert a new line after each original line ...}} CALL {my revision {inserting lines in between a file and not end of line}} CALL {::oo::Obj3923547 process revision/inserting+lines+in+between+a+file+and+not+end+of+line} CALL {::oo::Obj3923545 process}

-errorcode

NONE

-errorinfo

Unknow state transition: LINE -> END
    while executing
"error $msg"
    (class "::Wiki" method "render_wikit" line 6)
    invoked from within
"my render_$default_markup $N $C $mkup_rendering_engine"
    (class "::Wiki" method "render" line 8)
    invoked from within
"my render $name $C"
    (class "::Wiki" method "revision" line 31)
    invoked from within
"my revision $page"
    (class "::Wiki" method "process" line 56)
    invoked from within
"$server process [string trim $uri /]"

-errorline

4