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!
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:
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
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