The default action taken by GiD when validating a problem type password is verifying that it is not empty. When a password is considered as valid, this information is written in the file 'password.txt' which is located in the problem type directory. In order to override this behaviour, two nodes are provided in the .xml file

  • PasswordPath: The value of this node specifies a relative or absolute path describing where to locate/create the file password.txt. If the value is a relative path it is taken with respect to the problem type path.



  • ValidatePassword: The value of this node is a Tcl script which will be executed when a password for this problem type needs to be validated. The script receives the parameters for validation in the following variables:

key with the contents of the password typed,

dir with the path of the problem type, and

computer_name with the name of host machine.

Note: It's like this Tcl procedure prototype: proc PasswordPath { key dir computer_name } { ... body... }

The script should return one of three possible codes:

0 in case of failure.

1 in case of success.

2 in case of success; the difference here is that the problem type has just saved the password information so GiD should not do it.

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.


#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"]