How can I work with a user type array in Euphoria ???

new topic     » goto parent     » topic index » view thread      » older message » newer message

13/3/97, You wrote:

Poster:       Ricardo Niederberger Cabral <rnc at INFOLINK.COM.BR>
Subject:      How can I work with a user type array in Euphoria ???
---------------------------------------------------------------------------
----

        I'm new in Euphoria and I have a doubt:

        I did a game in Visual Basic 4.0 that has a global array defined at
this way:

Type MyType
       Cell as single
       Item as single
End Type

Global MapVar(1 to 100,1 to 100) as MyType

        Then, I use this variable to store the map data, for example, if I
want to say that in 2 (vertical cordinate) ,3 (horizontal cordinate) there
is a Cell number 3 and an item number 4, I write:
        MapVar(2,3).Cell=3
        MapVar(2,3).Item=4

        So this is my problem: How can I make the same thing in Euphoria
using that sequences method ?

        I would appreciate any help.

Thanks,
---
Ricardo Niederberger Cabral

Ciao Ricardo,

In Euphoria, what you ask is quite simple:

-- Mapvar.ex

-- First declare your sequence:
global sequence MapVar
-- Constants for your convenience (not really necessary, as you will
see)(-:
global constant Cell = 1, Item = 2

-- Now initialize the sequence with zeroes:
MapVar = repeat(repeat({0, 0}, 100), 100)               -- creates the map

-- And you are ready to fill your map:
MapVar[2][3][Cell] = 3
MapVar[2][3][Item] = 4

-- Even easier, without using the constants:
MapVar[2][3] = {3, 4}

-- To see the results, (the first 2 rows):
? MapVar[1..2]

I hope this answers your questions. Lots of success with translating your
game from VB.

Greetings,

Ad.

Regards

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu