Edit This Page
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

  1. function dependsMany()
  2. NumberItems=get_select_items()
  3. MaxNumber=table.maxn(NumberItems)
  4. if MaxNumber <= 1 then
  5. msgbox("Need more than one itme selected","Error 001")
  6. else
  7. for inc1 = 1,MaxNumber-1 do
  8. add_depend_item(NumberItems[MaxNumber],NumberItems[inc1])
  9. end
  10. end
  11. end


Code Explanation

  1. Function name
  2. the item ids for all the selected items are collected in a table "NumbrItems"
  3. the length of the table "id" is determined and saved as "MaxNumber"
  4. If statement to verify that more than one item is selected
  5. error message if imroper selction
  6. else statement for if
  7. loop from 1 through one less than the maxim number of selected items
  8. add the dependancies to the last selected item
  9. end of for loop
  10. end of if statement
  11. end of function