Re: RE: Handling Structured Memory

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

Hi Don,
this is my very point. Many people have written their own structured data
routines. I've written at
least two! Its a pity that such a common need is mainly met by re-inventing the
wheel. If it was
implmented inside Euphoria then we could all share the same code, and learn the
same code, much more
easily.

14/11/2002 8:00:07 AM, Don Phillips <EuNexus at yahoo.com> wrote:

>
>> Yes Irv, I was only addressing the structed RAM issue and not the other
>> issue of strucured data. I agree that Euphoria would be enhanced if it
>> supported both concepts at the syntax level. The current method of 
>> assigning
>> sequence element indexes to constants and then using these is a little
>> kludgy.
>
>
>> struct sequence CustRecord
>>   sequence Name
>>   sequence Address
>>   sequence Telephone
>> end struct
>> 
>> CustRecord TempCust
>> 
>> TempCust.Name = "Derek Parnell"
>> TempCust.Address = "123 Main St"
>> TempCust.Telephone = "555 5555"
>
>Thats funny =) almost very close to what mine looks like.  But you have 
>to declare the storage size...
>
>constant -- (integers)
>NAME      = struct_member(),
>ADDRESS   = struct_member(),
>TELEPHONE = struct_member()
>
>integer CUSTRECORD
>CUSTRECORD = define_struct({
>     { NAME, BYTE, 50 },
>     { ADDRESS, BYTE, 50 },
>     { TELEPHONE, BYTE, 50 }
>})
>
>atom TempCust
>TempCust = struct( CUSTRECORD )
>struct_set( TempCrust, NAME, "Derek Parnell" )
>struct_set( TempCrust, ADDRESS, "123 Main St" )
>struct_set( TempCrust, TELEPHONE, "555 5555" )
>
>...
>
>Oh well, maybe I can figure out a way to make it dynamic... hmmm

BTW, I left my "example" code to feel a bit more like Euphoria. That is,
non-fixed size fields. An
extention to be able to optionally create fixed-size fields would be another
good idea IMO.

Maybe along the lines of...

 struct sequence Address
     sequence Addr1(30)
     sequence Addr2(30)
     sequence Addr3(30)
     sequence City(20)
     sequence ZIP(15)
     sequence Country(2)
 end struct
 struct sequence CustRecord
   sequence Name(50)
   Address Mailing
   Address Business
   sequence Telephone(20)
 end struct

 TempCust.Mailing.Addr1 = "Level 1"
 TempCust.Mailing.Addr2 = "123 Main St"
 TempCust.Mailing.City = "Melbourne"
 TempCust.Mailing.ZIP = "3004"
 TempCust.Mailing.Country = "AU"
 TempCust.Business = TempCust.Mailing
 
---------
Cheers,
Derek Parnell 
ICQ# 7647806

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

Search



Quick Links

User menu

Not signed in.

Misc Menu