how to set a vector of array

For developers writing C++, Fortran, Java, code who have questions or comments to make.

Moderators: silvia, selimgunay, Moderators

Post Reply
J.Zhang
Posts: 11
Joined: Mon Feb 02, 2009 3:27 am
Location: Edinburgh

how to set a vector of array

Post by J.Zhang »

Hi Frank,

How are you? I have a problem in the design of input of data from the interpreter.

I am planning to input a set of data from the OpenSees interpreter, but the number of these "double values" could vary from a few to hundreds. If I use only "double" in the constructor, I must creat hundreds of constructors. So I am thinking using a vector of array in the constructor. But I can not find vector in the Tcl and even array is very different with in the C++. For example

set a {...} # {...} means a set of double type.
pattern Plain 1 Linear {
eleLoad -ele 1 -type -beamUniform $a 0. 0.;
}

What is you advice? thanks a lot

Jian
fmk
Site Admin
Posts: 5884
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Re: how to set a vector of array

Post by fmk »

there is no vector in tcl .. the closest thing is the list.
linguan118
Posts: 140
Joined: Sun Oct 03, 2010 11:36 pm
Location: Hong Kong

Re: how to set a vector of array

Post by linguan118 »

You mean TCL script?
Try
set A ""
lappend A 4
lappend A 5
...
Then A is similar to a Vector.
When you use A, you should need foreach.
foreach b $A {
...$b..
}
Research Assistant Professor, The Hong Kong Polytechnic University
guanlin@polyu.edu.hk
pengr357
Posts: 1
Joined: Fri Aug 26, 2011 5:58 pm
Contact:

2

Post by pengr357 »

Thanks! There are lot of other tips in this forum.
Davistrash
Posts: 2
Joined: Fri Sep 23, 2011 2:55 pm

Re: how to set a vector of array

Post by Davistrash »

It's work for me. I am facing this problem in C++ from several day but After implementing this method. linguan118, I think you have a good knowledge of this kind of language fundamental.
Post Reply