works as expected, but, how do i access the data stored in the var, since
if i use
[ctime ${datatype}_declared_at] it uses the name and not the data (and
that is pretty naturally), but i dont suppose that
${${datatype}_declared_at} works?
So, how do i read my dear old unixtime from such a variable?
Thanks.
/jan
> Try ${{datatype}_declared_at}
Eh? I get "can't read "{datatype": no such variable"
What about [set ${datatype}_declared_at]
--
Jonathan E. Guyer
An easier way to accomplish this is by using an array:
set declared_at($datatype) [unixtime]
To answer the specific question it's important to remember (or learn...)
that the set command has two forms -- one to set a value and one to retrieve
a value. So, the idiomatic way to do what you want is this:
set ${datatype}_declared_at
The ${datatype} will be evaluated and converted to "mythingie" before being
passed to the set command. The set command will thus see
"mythingie_declared_at", consider that the name of a variable, and fetch the
value of that variable.
I don't know it is a best way, but you can use:
[set ${datatype}_declared_at]
This should return value which you want get... (set without second argumet,
just returns value in variable)
Anyway, I think is better to use array for this kind of stuff.
Best regards,
TaKeDa
[ctime [set ${datatype}_declared_at[unixtime]]]
This provided there is a value within this var-within-var
Phil
"Jan Johansson" <j...@mupp.net> wrote in message
news:Pine.LNX.4.10.101071...@animal.mupp.net...
>
Thankyou, more people pointed out the array aproach, so i will use that..
Question do, is ther eanyway to do a test if a certain element in an array
exists? like an info exists but for elements in arraay?
Thankyou
Jan
Wroks, but someone else pointed out i should go with arrays, so ill do
that. But thankyou nonetheless, tyou did after all answer my question as i
had put it :)
A thankyou to yuo and all the others who helped me on thsi one :)
Ah. much easier :) But that gives a followup question. I cant seem to be
able to use "info exists" on an element in an array, how do i check if an
element exists within an array?
Thanks
Yes. 'info exists' works also for array entries.
% set foo(bar) baz
baz
% info exists foo(bar)
1
% info exists foo(boo)
0
rolf
info exists declared_at($datatype) ;# works
info exists $declared_at($datatype) ;# doesn't work
Yes, i understand now. Thanks!
Aaaaah, i see the light! Thankyou.