At 5:46 PM +0000 1/21/2008, Peter Alcibiades wrote:
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.


Here's one way:

set the itemDelimiter to tab
put field "Sales" into mySales -- not strictly necessary but speeds things up
-- collect the info about how many of each thing were sold today:
repeat for each line thisSale in mySales
  add 1 to soldThings[item 2 of thisSale]
  -- this builds an array where the keys are the item descriptions
end repeat
-- now update the Stock list to account for all items sold:
put field "Stock" into myStock -- again, for speed
repeat for each key thisThing in soldThings
  -- figure out which line of the stock list is the record for this thing:
  put lineOffset(tab & thisThing & tab,myStock) into thisThingLineNumber
  -- and subtract the total sold today from the number of this thing in stock:
subtract soldThings[thisThing] from item 5 of line thisThingLineNumber of myStock
end repeat
put myStock into field "Stock"
--
Jeanne A. E. DeVoto, Transcript Language Curmudgeon
[EMAIL PROTECTED]
http://www.jaedworks.com
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to