1. Re: Variable naming in Euphoria

> From: futures8

> Some languages have the capability to programatically create variable
> names; the following example from Foxpro demonstrates what I'm hoping
> can somehow be done in Euphoria. I have checked the Euphoria docs and
> various other Euphoria programs submitted to the archives by
> others, but
> haven't found and examples of what I'm looking for;

Eu doesn't have this ability, but there are some work arounds you can use.
(You might ask Kat--she seems to do this in mIrc.)

<snip>

>       store val(CLOSE) to Price&j
>       skip
> next i
> --------------------------------------------------------------
> -------------------
>
> the loop iteratively creates variables  Price1, Price2 ...Price10 and
> assigns them a value.
> The concatenation operator in Euphoria will catenate the contents of
> sequences, but not variable names.
>
> Is there a way to similarly create (declare) and assign variable names
> on the fly in Euphoria?

What I would do in this case, is use a sequence:

-- Begin Pseudocode
sequence Price = {}
for i = 1 to 10 do
        Price &= val(CLOSE) -- or however you'd get the value in Eu
end for
-- End Pseudocode

Then, you could access it like:
for i= 1 to 10 do
        ? Price[i]
end for

It seems (from your example), that this would accomplish everything you'd
need for it to do, and might even make life simpler down the road (you don't
have to rebuild the var name when you want to use it).  Sequences seem to be
one of Eu's greatest assets IMHO, but it takes a bit of practice to figure
how to use them effectively, especially when you've come from another
language.

Matt

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu