Sample Program 5
Description
This piece of code extracts the item dependents and displays same.
Code
- x=get_select_items()
- maxx=table.maxn(x)
- msgbox("Items Selected"..maxx,"X")
- for inc1=1,maxx do
- y=get_depend_items(x[inc1])
- maxy=table.maxn(y)
- msgbox(maxy,"Y")
- if maxy>0 then
- message="Item "..get_folder_value("ItemID",x[inc1]).." Depends "
- for inc2=1,maxy do
- message=message .. get_folder_value("Depends",x[inc1])
- if inc2<maxy then
- message=message..", "
- end
- end
- msgbox(message,"Depends Item")
- for inc3=1,maxx do
- if has_depend_item(x[inc1], x[inc3])==1 then
- msgbox("Item "..get_folder_value("ItemID",x[inc1]).." Depends "..get_folder_value("ItemID",x[inc3]),"Confirm depends reference")
- end
- end
- end
- end
Code Explanation
- get the id numbers for the selected items
- determine the maximum number of items selected
- message box to display the number of items selected
- do loop to cycle through each item selected
- get the id for all dependent items for the selected items
- determine the maximum number of dependent items
- message box to display the number of dependent items for each of the selected items
- if there are more than one dependents then create a message
- set up the start of the message getting the ItemID folder value
- For loop to cycle through each of the dependent items
- concatenate the ItemID folder value to the start of the message
- if there are more depends then
- concatenate a comma to the end of the message prior to looping back
- end of if statement
- end of for loop
- message box to display the built up message
- for loop to increment through the selected items to determine if the selected items are dependant on any of the other selected items
- if conditional to verify that the specific item has depends items
- message box to display the item dependencies based on the ItemID folder
- end of if statement
- end of for loop
- end of if statement
- 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.