It is good idea to work with field names instead of indices.
You can define your own tcl procedures, for example, in this case:
proc GetProblemDataValue { fieldname } {
set value “”
set aa [.central.s info gendata]
for { set i 0 } { $i [lindex $aa 0] } { incr i } {
if { [lindex $aa [ expr $i2+1]] == $fieldname } {
set value [lindex $aa [ expr $i2+2]]
break
}
}
return $value
}
Note, To avoid name conflicts with the “GiD standard procedures”, it is recommended to use some prefix for your own procedures
For example, this procedure can be included in the scripts of the next GiD Version to simplify this request to another problemtype developer.
Rename your procedure for example to proc Chris_GetProblemDataValue { fieldname }
Enrique Escolano
----- Original Message -----
From: Christophe Louis
To: Gid
Sent: Monday, November 04, 2002 4:19 PM
Subject: [GiDlist] .central.s info gendata
Hello,
Imagine I have put the following lines in my .prb file :
QUESTION: Number_of_steps
VALUE: 10.
I would like to know whether it is possible to get this data in a tcl file by a command like :
.central.s info gendata xxx
(xxx being a command like Number_of_steps)
instead of calling the command :
[lindex [.gid.central.s info gendata] nbr]
(nbr being the position of this data in the list)
because, if I do this, it will be very difficult to add other fields in the future without changing all the tcl files.
Thanks for answering my question,
Christophe Louis
-------------- next part --------------
An HTML attachment was scrubbed…
URL: http://listas.cimne.upc.edu/pipermail/gidlist/attachments/20021104/19bd946e/attachment.htm