question about how to update an item in a field in batch mode

Peter Alcibiades palcibiades-first at yahoo.co.uk
Mon Jan 21 12:46:27 EST 2008


There is a sales file with a varying number of lines, tab delimited.

Each line records one transaction, the sale of one product.  These lines 
accumulate throughout the day.

At the end of the day, I want to take (for instance) item 1 & tab & item 2 & 
tab, and use this to look up the line in the stock list that corresponds to 
that sale.  Then item 5 of that line in the stock list, which is the stock 
level, should be decremented by 1 to show one of these items has been sold.

And so on for each line item in the sales file.

Not sure if this is quite clear, so here it is a bit more specific.

The sales field might look like this:

1	XX	2.30		RRR	6/1/08
2	YY	4.20		RRR	7/1/08

where the items are number, description, price, department, datestamp

then the stock field might look like this

1	XX	2.30		RRR	100
2	YY	4.20		RRR	150

Where the items are:  number, description, price, department, no in inventory.

So what I am trying to do is go through the sales field using the number and 
description from each line, one after the other, and match each line against 
the record for that product in the stock field, then if there is a match, 
knock down the no in inventory in the stock field, which is item 5,  by 1.  

If I could make it work, the result of running it in the above instance would 
just be that the no in stock would fall to 99 and 149.

The sticking point is how to do this match and decrement using repeat.

I can do it easily when dealing with it one record at a time - when there is 
only one record in the field, so there is no repeat loop.  But I'm having 
great trouble figuring out how you do it when you have to run through a 
series of records from the first field one after the other against the second 
field  Part of the difficulty may be the thing that was referred to earlier 
on the list, that you cannot modify the repeat for variable.

Any thoughts or hints very gratefully received as always.

Peter



More information about the use-livecode mailing list