[GiDlist] .central.s info gendata

Moderator: GiD Team

Post Reply
Christophe Louis

[GiDlist] .central.s info gendata

Post by Christophe Louis »

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/baf7fe79/attachment.htm
Ramon Ribó

[GiDlist] .central.s info gendata

Post by Ramon Ribó »

Hello,

This kind of functionality is much better added directly in TCL, instead
of
having more TCL-GiD functions to remember.

In this case, it is really simple to use one of the two functions below:


proc GiveGendata { name } {
foreach "n val" [lrange [.central.s info gendata] 1 end] {
if { $n == $name } { return $val }
}
error "error '$name' is not in gendata"
}

proc GiveGendata2 { name } {
foreach "n val" [lrange [.central.s info gendata] 1 end] {
if { [string math $name* $n] } { return $val }
}
error "error '$name' is not in gendata"
}

This is the advantage of using a powerful scripting language as an
extension
for GiD.

Best regards,
--
Compass Ing. y Sistemas Dr. Ramon Ribó
http://www.compassis.com ramsan at compassis.com
c/ Manuel Girona, 61 bajos tel. +34 93 204 10 82
08034 Barcelona, Spain fax. +34 93 204 19 09

-----Mensaje original-----
De: gidlist-admin at gatxan.cimne.upc.es
[mailto:gidlist-admin at gatxan.cimne.upc.es]En nombre de Christophe Louis
Enviado el: lunes, 04 de noviembre de 2002 16:20
Para: Gid
Asunto: [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/1977ad76/attachment.htm
Enrique Escolano

[GiDlist] .central.s info gendata

Post by Enrique Escolano »

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 $i*2+1]] == $fieldname } {
set value [lindex $aa [ expr $i*2+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
Jorge Suit Perez Ronda

[GiDlist] .central.s info gendata

Post by Jorge Suit Perez Ronda »

You can do this, without error checking


proc GetGenDataValue { field } {
array set gendata [lrange [.central.s info gendata] 1 end]
return $gendata($field)
}

Christophe Louis wrote:

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/df43b84a/attachment.htm
Post Reply