Re: structure

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

On Thursday 26 July 2001 09:35, gwalters at sc.rr.com wrote:

> irv, you've hit it. each one can have a different length...problem is fixed
> now..thanks all for your input..

That, of course, is one of Euphoria's advantages - you can pack 
pretty much anything you want into a sequence, without any arbitrary 
limits or having to pre-define the space.

As an example, the 'normal' way to implement an A/R system is with 
two files: a customer file containing name, addr, balances, etc.
and a transaction file, with current txns.

With Euphoria, I tend to use just one file, which contains:
(hope my indentation makes it thru EuForum intact)

customer key
  -- customer info 
       -- name
       -- addr
       -- balances
            -- current
            -- 30
            -- 60
            -- 90
  -- customer txns (zero or more)
        -- inv #
        -- date
        -- amt...

As customer makes purchases, the new purchase is just appended to
his/her txns sequence.

Number of transactions can be obtained by calling length(customer[txns])
Customer totals are computed by looping 1... length(txns), etc.

This eliminates a lot of lookups and searching, since everything related 
is located within the one file. It also simplifies things such as deleting 
a customer account:
if length(txns) > 0 
or balance != 0 then
  error("Can't delete active account!")

Backups are simple - one file to copy, as are statements.
Reviewing a customer's account is verrry quick, as well. 

EOM reports are less quick, because you have to loop thru all 
customers and consolidate the data. Usually you're printing these 
reports, so there's plenty of time for processing while the printer 
chugs along.  

Starting a new period is just a matter of adjusting the 30/60/90, 
and then setting customer[x][txns] = {} 

You could keep the entire sequence of customers 'in-memory',
but it's better to store these in a EDS database, since EDS will
handle the lookup logic for you and ensure the use of unique keys
automatically.

Regards,
Irv

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

Search



Quick Links

User menu

Not signed in.

Misc Menu