Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
Daross
- VIP Livecode Opensource Backer

- Posts: 23
- Joined: Thu Jun 04, 2009 8:15 pm
Post
by Daross » Fri May 25, 2012 2:44 pm
Hi all,
I have a stack with a table field "List" where I have a material list with quantities and a table field "Price List" where I have to add the amount in Item 6 from Item 2 of field "List"
I created this script but it does not work:
Code: Select all
on mouseUp
put field "List" into theList
put field "ListPrice" into theListPrice
set itemDel to tab
repeat for each line theLine in theList
repeat for each line theLine1 in field "ListPrice"
add 1 to tCounter
if item 1 of theLine = item 1 of field "ListPrice" then
add item 2 of theLine to item 6 of field "ListPrice"
next repeat
end if
end repeat
end repeat
end mouseUp
Thanks in advance
-
sturgis
- Livecode Opensource Backer

- Posts: 1685
- Joined: Sat Feb 28, 2009 11:49 pm
Post
by sturgis » Fri May 25, 2012 3:08 pm
I think I know what you're going for here, so try the following and see if its close enough.
Code: Select all
on mouseUp
put field "List" into theList
put field "ListPrice" into theListPrice
set itemDel to tab
repeat for each line theLine in theList
put 1 into tCounter -- init counter to be used in nested repeat
repeat for each line theLine1 in theListPrice --use the data in the var from above
if item 1 of theLine = item 1 of theline1 then --check for matching item. If true...
--adjust the field. The LINE number must be specified, and the current line is in tCounter
add item 2 of theLine to item 6 line tCounter of field "listPrice"
next repeat
end if
--if there was no match then increment tCounter for the next loop
add 1 to tCounter
end repeat
end repeat
end mouseUp
-
Daross
- VIP Livecode Opensource Backer

- Posts: 23
- Joined: Thu Jun 04, 2009 8:15 pm
Post
by Daross » Fri May 25, 2012 5:23 pm
Sturgis, your script work perfectly.
Many thanks.
Davide