Page 1 of 1
How add number to item of Field from another
Posted: Fri May 25, 2012 2:44 pm
by Daross
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
Re: How add number to item of Field from another
Posted: Fri May 25, 2012 3:08 pm
by sturgis
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
Re: How add number to item of Field from another
Posted: Fri May 25, 2012 5:23 pm
by Daross
Sturgis, your script work perfectly.
Many thanks.
Davide