Mercurial > hg > egg-tcls
comparison tj.tcl @ 665:4156adacdc31
tj: Use utl_arg_rest instead of tj_arg_rest.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 20 Feb 2021 17:45:13 +0200 |
parents | 98e2254056b2 |
children | 7ff41e458ee0 |
comparison
equal
deleted
inserted
replaced
664:586caf75fccc | 665:4156adacdc31 |
---|---|
71 | 71 |
72 | 72 |
73 proc tj_cmd_match {uid ustr} { | 73 proc tj_cmd_match {uid ustr} { |
74 global tj_commands | 74 global tj_commands |
75 return [utl_cmd_match tj_commands $uid $ustr] | 75 return [utl_cmd_match tj_commands $uid $ustr] |
76 } | |
77 | |
78 | |
79 proc tj_arg_rest {rarglist rindex rstr} { | |
80 upvar $rstr dstr | |
81 | |
82 if {$rindex < [llength $rarglist]} { | |
83 set dstr [join [lrange $rarglist $rindex end] " "] | |
84 return 1 | |
85 } else { | |
86 return 0 | |
87 } | |
88 } | 76 } |
89 | 77 |
90 | 78 |
91 # ------------------------------------------------------------------------ | 79 # ------------------------------------------------------------------------ |
92 proc tj_get_id {rstr rindex rid} { | 80 proc tj_get_id {rstr rindex rid} { |
263 } else { | 251 } else { |
264 set rtime $tj_default_time | 252 set rtime $tj_default_time |
265 } | 253 } |
266 } | 254 } |
267 | 255 |
268 tj_arg_rest $rarglist $rindex rdesc | 256 utl_arg_rest $rarglist $rindex rdesc |
269 | 257 |
270 # Check the timestamp validity | 258 # Check the timestamp validity |
271 if {[catch {set rstamp [clock scan "${rdate} ${rtime}" -format "%d.%m.%Y %H:%M"]} uerrmsg]} { | 259 if {[catch {set rstamp [clock scan "${rdate} ${rtime}" -format "%d.%m.%Y %H:%M"]} uerrmsg]} { |
272 tj_msg $upublic $unick $uchan "err_timestamp" [list $uerrmsg $rdate $rtime] | 260 tj_msg $upublic $unick $uchan "err_timestamp" [list $uerrmsg $rdate $rtime] |
273 return 1 | 261 return 1 |
284 if {$hsign == "-"} { set rhours [expr -$rhours] } | 272 if {$hsign == "-"} { set rhours [expr -$rhours] } |
285 incr rindex | 273 incr rindex |
286 } | 274 } |
287 | 275 |
288 # Get description, if any | 276 # Get description, if any |
289 tj_arg_rest $rarglist $rindex rdesc | 277 utl_arg_rest $rarglist $rindex rdesc |
290 | 278 |
291 # Validate hours parameters a bit | 279 # Validate hours parameters a bit |
292 if {$rhours < -24 || $rhours > 24} { | 280 if {$rhours < -24 || $rhours > 24} { |
293 tj_msg $upublic $unick $uchan "err_invalid_hours" [list $rhours] | 281 tj_msg $upublic $unick $uchan "err_invalid_hours" [list $rhours] |
294 return 1 | 282 return 1 |
298 # Compute target timestamp | 286 # Compute target timestamp |
299 set rstamp [expr $uclock + ($rdays * 24 * 60 * 60) + ($rhours * 60 * 60)] | 287 set rstamp [expr $uclock + ($rdays * 24 * 60 * 60) + ($rhours * 60 * 60)] |
300 } else { | 288 } else { |
301 # Only description was specified | 289 # Only description was specified |
302 incr rindex -1 | 290 incr rindex -1 |
303 tj_arg_rest $rarglist $rindex rdesc | 291 utl_arg_rest $rarglist $rindex rdesc |
304 set rstamp "invalid" | 292 set rstamp "invalid" |
305 } | 293 } |
306 | 294 |
307 # Check if ID exists | 295 # Check if ID exists |
308 set umode 1 | 296 set umode 1 |