Sample Program 5


Description

This piece of code extracts the item dependents and displays same.

Code

  1. x=get_select_items()
  2. maxx=table.maxn(x)
  3. msgbox("Items Selected"..maxx,"X")
  4. for inc1=1,maxx do
  5. y=get_depend_items(x[inc1])
  6. maxy=table.maxn(y)
  7. msgbox(maxy,"Y")
  8. if maxy>0 then
  9. message="Item "..get_folder_value("ItemID",x[inc1]).." Depends "
  10. for inc2=1,maxy do
  11. message=message .. get_folder_value("Depends",x[inc1])
  12. if inc2<maxy then
  13. message=message..", "
  14. end
  15. end
  16. msgbox(message,"Depends Item")
  17. for inc3=1,maxx do
  18. if has_depend_item(x[inc1], x[inc3])==1 then
  19. msgbox("Item "..get_folder_value("ItemID",x[inc1]).." Depends "..get_folder_value("ItemID",x[inc3]),"Confirm depends reference")
  20. end
  21. end
  22. end
  23. end

Code Explanation

  1. get the id numbers for the selected items
  2. determine the maximum number of items selected
  3. message box to display the number of items selected
  4. do loop to cycle through each item selected
  5. get the id for all dependent items for the selected items
  6. determine the maximum number of dependent items
  7. message box to display the number of dependent items for each of the selected items
  8. if there are more than one dependents then create a message
  9. set up the start of the message getting the ItemID folder value
  10. For loop to cycle through each of the dependent items
  11. concatenate the ItemID folder value to the start of the message
  12. if there are more depends then
  13. concatenate a comma to the end of the message prior to looping back
  14. end of if statement
  15. end of for loop
  16. message box to display the built up message
  17. for loop to increment through the selected items to determine if the selected items are dependant on any of the other selected items
  18. if conditional to verify that the specific item has depends items
  19. message box to display the item dependencies based on the ItemID folder
  20. end of if statement
  21. end of for loop
  22. end of if statement
  23. end of for loop

Notes

This bit of code displays the ItemID values that are created when the dependencies are set up (get_folder_value()). Item_id and ItemID are different and should not be confused when working with LUA scripts and eccoext dependents.