|
Edit This Page |
Sample Program 4
Description
This piece of code extracts the item numbers from selected text then assigns depenancies. The last item selected will depend on all of the prior items selected.
Code
- function dependsMany()
- NumberItems=get_select_items()
- MaxNumber=table.maxn(NumberItems)
- if MaxNumber <= 1 then
- msgbox("Need more than one itme selected","Error 001")
- else
- for inc1 = 1,MaxNumber-1 do
- add_depend_item(NumberItems[MaxNumber],NumberItems[inc1])
- end
- end
- end
Code Explanation
- Function name
- the item ids for all the selected items are collected in a table "NumbrItems"
- the length of the table "id" is determined and saved as "MaxNumber"
- If statement to verify that more than one item is selected
- error message if imroper selction
- else statement for if
- loop from 1 through one less than the maxim number of selected items
- add the dependancies to the last selected item
- end of for loop
- end of if statement
- end of function