catch { glob -type f $::db(path)/$film/* } files
foreach bla $files {
set subtitle "No"
if {[string match "*.sub*" $bla]} { set subtitle "Yes" }
}
where the $bla variable looks like:
"/home/irc/raid/upload/movies/2 Fast 2 Furious/2 Fast 2 Furious.sub" sometimes is working, sometimes it dosen't.. When I do a manual test like .tcl set bla "/home/irc/raid/upload/movies/2 Fast 2 Furious/2 Fast 2 Furious.sub" ; if {[string match "*.sub*" $bla]} { putlog "yes" } it's working all the time but when I put it to do the test with if {[string match "*.sub*" $bla]} { set subtitle "Yes" } sometimes it fails.. Any sugestions how to *fix* this?
Once the game is over, the king and the pawn go back in the same box.
set in [open $file r]
while {![eof $in]} {
set line [gets $in]
set line [lindex $line 0 end] #this is cos every line starts with 2 space chars
.....
a line in the file started this way:
"Text": sometext
it worked with each line, but not with that one (error : list element in quotes followed by ":" instead of space)
i fixed it with a "string range" from 3 to end
proc loadall { string } {
set files [exec ls scripts/]
foreach z [split $files \n] {
if {[string match "$string" $z]} {
utimer 2 "source scripts/$z" # <- 1rst way, works
source scripts/$z # <- 2nd way, doesnt work
}
}
}
both return the "file.tcl been loaded" thats on the bottom of each file, but with the 2nd way the vars that have been set at the top of the files arent set, the 1rst way sets them....
GodOfSuicide wrote:also had some wired error the last days...
That's not weird at all... You use list commands on strings and get what you deserve
Use 'string trim' to get rid of the spaces.
Use 'glob' to list files (there's probably errors in the files sourced by the timers too, but they happen in separate calls, so it wont prevent the rest from loading)
If you don't get what I mean, I'll come back later and clean up my post..I'm in a bit of a hurry right now...bbl
GodOfSuicide wrote:the 2nd works fine with ls too and the sources with utimers work fine (everything gets loaded)
I still think using the built in command to list files would be better.
The reason the variables "disappear" is because you source the files from within the proc and because of that, their code is executed in the scope of the proc (so the variables are deleted when the proc returns)
Use 'uplevel #0 [list source $z]' to get it executed in the global namespace (like the timers do)
ppslim wrote:caesar, your code proably is working correctly, however, you are forgetting your code is in a loop.
For every loop of your code, you are setting a value to "No". Thus, once you set the value to "Yes" and there are more files, the it returns to "No"
Damn, you're right. I thought I saw a 'break' in there (would make sense ), but using -dir to specify the dir will prevent matching problems and -nocomplain is "cleaner" that catching the glob
Umm.. yes, that makes sence now. Forgot that I was in a loop thing and yes, in some cases there are more than 1 file so happens exactly like you've said. Thanks for pointing that out ppslim.
Once the game is over, the king and the pawn go back in the same box.
Well, I'm still "confused" how I should "skip" the other files and see if only a .sub file is there.. I've tryed different alternatives but with no notable success. Any sugestions?
Once the game is over, the king and the pawn go back in the same box.
caesar wrote:Well, I'm still "confused" how I should "skip" the other files and see if only a .sub file is there.. I've tryed different alternatives but with no notable success. Any sugestions?
You should 'break' out of the loop when a match is found, or set the negative value outside the loop and only change the value when/if a match is found.
What's wrong with the code I suggested? It won't even need a loop.