On Tue, 12 Jun 2012, artur tarassow wrote:
I am struggling with the following problem:
[Wide comments stripped out of script: it's helpful if you don't
assume that people are reading mail in a window that's hundreds of
columns wide.]
<hansl>
set echo off
set messages off
open denmark
list ttt = LRM LRY
scalar vars = nelem(ttt)
varnames = varname(ttt)
loop i=1..vars
print "$i"
sprintf astr$i "%s", varnames($i)
printf "%s", @astr$i
endloop
<\hansl>
Corrected loop:
loop i=1..vars
print "$i"
sprintf astr$i "%s", varname(i)
printf "%s\n", astr$i
endloop
There's no function "varnames()" but there is a "varname()".
Using "i" rather than "$i" as an argument to varname is not really a
correction, or only a stylistic one: no need to use string
substitution when it's a numerical value you want. And using
@astr$i instead of astr$i as an argument to printf is not
currently an error but arguably it should be one. In that position
you really want a string literal (in double quotes) or the name of a
string variable, and @astr$i is neither.
Off-topic, but "<\hansl>" would be an error if you were writing XML
rather than just pseudo-XML ;-)
Allin Cottrell