...
Furthermore, we can provide a description of the status returned for GiD to show to the user. If another status is returned, it is assumed to be 1 by default.
Below is an example of a <ValidatePassword> node.
Code Block | ||||
---|---|---|---|---|
| ||||
<ValidatePassword> #validation.exe simulates an external program to validade the key for this computername #instead an external program can be used a tcl procedure if { [catch {set res [exec [file join $dir validation.exe] $key $computername]} msgerr] } { return [list 0 "Error $msgerr"] } switch -regexp -- $res { failRB { return [list 0 "you ask me to fail!"] } okandsaveRB { proc save_pass {dir id pass} { set date [clock format [clock second] -format "%Y %m %d"] set fd [open [file join $dir .. "password.txt"] "a"] puts $fd "$id $pass # $date Password for Problem type '$dir'" close $fd } save_pass $dir $computername $key rename save_pass "" return [list 2 "password $key saved by me"] } okRB { return [list 1 "password $key will be saved by gid"] } default { return [list 0 "Error: unexpected return value $res"] } } </ValidatePassword> |
...