CFD Online URL
[Sponsors]
Home > Forums > CFX

One question about macro

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   January 24, 2003, 19:24
Default One question about macro
  #1
oldarmy
Guest
 
Posts: n/a
What's wrong in the following macro?

calc i = 1 while ( $i < 100 )

.

.

.

calc ms$i=masstotal

.

.

. echo $ms$i

If the value of "i" is 7, the result is "$ms7". What I want is to get an valute stored in variable "ms7". How can I fix this problem?
  Reply With Quote

Old   February 14, 2003, 09:36
Default Re: One question about macro
  #2
Jim
Guest
 
Posts: n/a
(I'm assuming your first line, "calc i=1 while ($i < 100)" is actually two lines. This message board did the same thing to me, sticking two lines together unless I left a blank line between them.)

You should be getting a value stored in parameter ms7 (and all of ms1 through ms99, presumably). The problem is in the "echo" command. You want TASCtool to substitute 7 for $i, then substitute the value of ms7 for $ms7. This requires sort of a nesting of dollar signs; it's got to substitute the $i and then use the first dollar sign after that's done. I haven't found any way to get TASCtool to do that either. Instead, it's just reading left to right, trying to evaluate $ms (which has no value set, so it just echoes "$ms"), then $i (which it correctly replaces with "7").

The workaround I use is to use "calc" to put the value into a simple parameter name just for output. After all, the correct value has been placed into ms7. Instead of "echo $ms$i", try:

calc ms_output=ms$i

echo $ms_output

This ought to work. Just let ms_output keep getting replaced by the current value of ms$i as the loop goes.

Jim
  Reply With Quote

Old   February 17, 2003, 21:21
Default Re: One question about macro
  #3
oldarmy
Guest
 
Posts: n/a
Thank you very very much, Jim!
  Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unanswered question niklas OpenFOAM 2 July 31, 2013 17:03
internal field question - PitzDaily Case atareen64 OpenFOAM Running, Solving & CFD 2 January 26, 2011 16:26
Question about Table applicaiton. universez OpenFOAM Running, Solving & CFD 0 January 12, 2010 21:31
question about uds tanven FLUENT 1 October 27, 2009 10:55
Poisson Solver question Suresh Main CFD Forum 3 August 12, 2005 05:37


All times are GMT -4. The time now is 12:21.