Re: field size

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

On Friday 27 July 2001 08:28, gwalters at sc.rr.com wrote:

> So far I like EU, but it has some limitations that I would like to see
> improved. My (and Lucy's) programming style heavily uses 
> select/case/cend...and EU being so structured i'm supprised that it
> doesen't have it.
>
>     select some.var
>         case 'a"
>             do something
>         case 'b'
>             do something
>         case 'c'
>             do something
>         otherwise
>             catch all here
>     cend .....or ala EU end select

That's a minor problem, just causes a bit more typing, since you can 
replace the above with 

if some_var = 'a' then 
    do something
elsif some_var = 'b' then
    do something
elsif some_var = 'c' then
   do something....
else
   catchall
end if

Of course, it helps if some_var has a short name:)
As an alternative, since my variables never have short names, I sometimes use:

object case -- declare this once at top of your progm.

case = customer[PREFS][DISCOUNT_LEVEL]

if case = 'a' then
   do ...
elsif case = 'b' then
   do ....
else
   err("Customer has not been assigned a valid discount level!)
end if

> I would also like to see variable names use periods...like 'customer.name',
> 'customer.address' instead of customer_address. Not a big issue with this
> one just personal preference. 

Rob has hinted that he is reserving the dot notation for something in the 
future.  
Putting that aside for the moment, I strongly urge you to not use 
individual variables (such as customer_address seems to be)
but instead use Euphoria's nested sequences to store these things:
example:

customer -- a sequence which contains 0 or more  records
  each record consists of:
        name  -- a sequence of characters
        addr    -- a sequence which might contain street, city, state, zip
        balances -- a sequence which contains current, pd30, pd60, pd90 values

You can then select customer #2's name:
  customer[2][NAME] -- "Joe Smith"

or customer #88's whole address:
  customer[88][ADDR] -- {"1234 Fifth St","Bourbon","KY","54321"}

or customer #88's state:
  customer[88][ADDR][STATE] -- "KY" 

or customer #129's past-due 90 balance:
  customer[129][BALANCE][PD90] -- 199.95

or customer #129's balances:
  customer[129][BALANCE] -- {12.99, 23.55, 66.98, 199.95}
 
Because things are neatly packaged, it's easy to add or delete or sort 
customers, and to extract groups of customers for reports, etc.

length(customer) returns the number of customers on your list. 
Extracting pieces of this data, such a a list of names or zip codes, or a 
total past-due, is very simple, just a loop from 1 to length(customer)

There's one hassle, however: the current implementation of Euphoria 
makes you declare the meaning of NAME, ADDR, CITY, BALANCE, PD90, etc,
for yourself. These need to be constants declared at the 
beginning of your program.  Some other programming languages do this 
automatically, but for us it requires extra work:

constant -- customer record layout: 
    NAME = 1, 
    ADDR = 2,
                   STREET = 1,
                   CITY = 2,
                   STATE = 3,
                   ZIP = 4,
    BALANCE = 3,
                    CURR = 1,
                    PD30 = 2,
                    PD60 = 3,
                    PD90 = 4
       
> And the 'goto label' issue... I'll have to
> sit this one out. It's the biggest road block in porting to EU to get
> something as a starting point to continue with and make complete redo's a
> piece at a time. And lastly as Irv points out a multiuser capability with a
> data base with record and file locking. I'm hoping that some of the
> contributions of others will solve this. I see that a 2.3 is on the way. I
> wonder what new things it will contain.

No comment on goto's ;)
File locking is no problem - a very simple thing for a programmer to 
implement him or herself. Record locking is a bit more difficult, but 
Jonas Temple has a library to do that on the RDS contributions page.
http://www.RapidEuphoria.com/edsnet.zip

Regards,
Irv

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

Search



Quick Links

User menu

Not signed in.

Misc Menu