so far, in all my TCLs i use the 'foreach' function to read files n such, though ive come to scripting something that i believe that 'foreach' isnt doing the job properly. i tried to use the 'while' function to read files but i cant seem to get it to work how i want it to. how would i go about making it read a file, n how would i check each line? like in 'foreach' i would just call each line $line (foreach line $var {)
Yo momma's so fat she can be in the past, present, n future all at once
In most circumstances, foreach is the best way. Using a while loop is more cumbersome because you have to check for eof after you read, not before. The code User posted doesn't do this, so you will end up processing an extra blank line in each file. The correct while loop code is like this:
set file [open sheep/baa.txt r]
while {[gets $file line] != -1} {
# $line holds the line read
}
close $file
Because Tcl is rather inefficient, if you are reading many lines it's much better to use foreach line [split [read $file] \n] like that. That makes tcl read all the lines at once using C code. For long files, it is *much* faster.
its really hard to explain the real point of the tcl if u dont play a certain game, but ill give it a try.... somehow...
i just checked with some 'putlog' things to see if the bot gets stuck somewhere or something, n well, it reads a file it dls from a site, n with a command it searches the given parameters within the file. apparently, its not reading the first half of the file. i tried it with the 'while' function too, same result.
Yo momma's so fat she can be in the past, present, n future all at once
ofc, downloaded it quite a few times already, i open it with wordpad over n over again n i can see the entire file n its just fine, but the bot itself wont read the first half
Yo momma's so fat she can be in the past, present, n future all at once
ok, tried it with the fconfigure thing n without it, n kept the putlog thing. the result is that it seems it does read the entire file, but it only starts doing the putlog thing after half the file has been read.
i honestly dont know wats wrong, n ive changed the coding many many many times over the past 4 days.
Yo momma's so fat she can be in the past, present, n future all at once