Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
13 years ago

Modelsim: alias to loop a command

I'm trying to create a modelsim alias command which loops another command a specific number of times.

From the command line I can use a Tcl for loop such as this to execute the command A (yet another alias) five times:

for {set x 0} {$x < 5} {incr x} A

If I create an alias called ten defined to the above command such as this:

alias ten "for {set x 0} {$x < 5} {incr x} A"

it appears that the variable x is being evaluated rather than used as a variable. So if I issue the command "alias ten" from the command line, what is echoed is:

ten=for {set x 0} {0 < 5} {incr x} A

Is there some trick to maintain variables in an alias? Or, is there a better way to loop a command via alias?

Thanks,

-phil

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Can't you define a procedure instead of an alias? It could take the command name as a parameter and evaluate it. I haven't tested it, but I'm thinking about something like that:

    proc ten { A } { for {set x 0} {$x < 5 } { incr x} {eval $A} }