Can't get item error message

Hi,
I’m modifying a script that a coworker wrote before he moved away. It was designed to send jobs to certain printer presets while giving each document an alpha-numerical code. I’m trying to add a new printer preset and an appropriate radiobutton. I have typed it all in exactly like my coworker had. It should work. However, when I first ran the script everything printed although I had only chosen 2 pages. (The radiobuttons are there). I made no changes. Now whenever I run it, I get an error message that reads: “Can’t get item 2 of {Black White Ads}”. When I hit the Edit button, it takes me to an area of the script that I haven’t even touched. “item i” is highlighted. Any thoughts about what “item 2” is? Thanks.
JDG

Hi,

sometimes it’s difficult to find errors even having the code.
But it’s almost impossible without any code line. :wink:

The error occurs, because the specified list {Black White Ads} contains only one item

Thanks for your response. So why does “item i” think it should be 2 items? I’ve patterned the specified list after the other presets, and they are each 1 item. Is there a fix? Thanks again.
JDG

your index variable is higher than the number of items in the list.
Probably the problem could be solved in a minute, if you were sharing the code

Okay, it’s a huge script, so I’ll copy a small portion of the part I fixed. It basically repeats itself with different numbers. This is the beginning of the part I changed which isn’t working. What’s in quotes are printer presets. I added “Black White Ads” purposely before the defaulted Do Not Print radiobutton.
I’ve noticed that the more pages I choose to print the number in the message goes up. IE: If I pick one page, it’s “can’t get item 2”, if I pick 2 pages, “can’t get item 3” and so forth.
Also the script does work on an InDesign document that has no section designations. (I just discovered this today.) However we will have up to 4 sections (A-D) in one document, so I need this to work with sections. Hope I gave you enough to go on. Thank you so much.

if checked state of proof_doc_box is false then
set multi_preset_list to {}
set disclude_page_list to {}
if (count of page_names) < 6 then
repeat with i from 1 to (count of page_names)
if selected button of item i of print_button_group_1_list is 0 then
if selected index of proof_menu is 0 then
set selected_preset to “FBEx1_Merge”
else if selected index of proof_menu is 1 then
set selected_preset to “FBEx2_Merge”
end if
set multi_preset_list to multi_preset_list & selected_preset
else if selected button of item i of print_button_group_1_list is 1 then
if selected index of proof_menu is 0 then
set selected_preset to “Film_BMx1_EAE”
else if selected index of proof_menu is 1 then
set selected_preset to “Film_BMx2_EAE”
end if
set multi_preset_list to multi_preset_list & selected_preset
else if selected button of item i of print_button_group_1_list is 2 then
set selected_preset to “WideSingle B&W Composite”
set multi_preset_list to multi_preset_list & selected_preset
else if selected button of item i of print_button_group_1_list is 3 then
set selected_preset to “Black White Ads”
set multi_preset_list to multi_preset_list & selected_preset
else if selected button of item i of print_button_group_1_list is 4 then
set disclude_page_list to disclude_page_list & item i of page_names
end if
end repeat

And this is the area that I didn’t touch but gives me the error message (item i):

set print_page_loop to (count of page_range_list)
repeat with i from 1 to (count of page_range_list)
set final_preset_list to final_preset_list & item i of multi_preset_list
if InDesign_Letter is true then
set multi_letter to item i of page_range_list
set input_page_num_uc to sblib’s convert_to_uppercase(multi_letter)
try
set first_character to first character of input_page_num_uc
set section_letter_list to section_letter_list & first_character as string
on error
set first_character to “”
set section_letter_invalid to true
set get_an_eae to false
end try
repeat with i from 0 to 9
set i to i as string
if first_character is i then
set section_letter_invalid to true
set get_an_eae to false
end if
set i to i as integer
end repeat
end if
end repeat
else
set get_an_eae to false

							end if

There are two lists page_range_list and multi_preset_list.
The repeat loop uses the number of item in page_range_list as index variable
If page_range_list contains more elements than multi_preset_list you get the error message

Thanks for your help. I’m still stumped. This is what I find when I try to find out how many items are in the lists:

set multi_preset_list to {}
set page_range_list to {}

They appear to be the same to me. I know that the multi_preset_list has 5 presets in it. (Was 4, I added 1).
The other list is a mystery to me.

I suspect it has something to do with the lettering in InDesign. The script won’t recognize Sections Letters, whereas it did before I added the new preset. I’ve read and read can’t figure it out. Thanks again.
JDG

--Reconciles Page Information 
								set page_range_list to {}
								set final_preset_list to {}
								set section_letter_list to {}
								if (count of disclude_page_list) is less than (count of page_names) then
									repeat with i from 1 to (count of page_names)
										if disclude_page_list does not contain item i of page_names then
											set page_range_list to page_range_list & item i of page_names
										end if
									end repeat
									set print_page_loop to (count of page_range_list)
									repeat with i from 1 to (count of page_range_list)
										set final_preset_list to final_preset_list & item i of multi_preset_list
										if InDesign_Letter is true then
											set multi_letter to item i of page_range_list
											set input_page_num_uc to sblib's convert_to_uppercase(multi_letter)
											try
												set first_character to first character of input_page_num_uc
												set section_letter_list to section_letter_list & first_character as string
											on error
												set first_character to ""
												set section_letter_invalid to true
												set get_an_eae to false
											end try
											repeat with i from 0 to 9
												set i to i as string
												if first_character is i then
													set section_letter_invalid to true
													set get_an_eae to false
												end if
												set i to i as integer
											end repeat
										end if
									end repeat
								else
									set get_an_eae to false
									
								end if

Okay, I have tried everything I can think of to make this script work. I know it has something to do with the section letters in InDesign, b/c it won’t recognize them, even though it did before I added the new preset. It makes no sense to me. Please help. Hope I’ve given enough info. (the preset I added is “Black White Ads”) Thanks.
JDG

repeat with i from 1 to (8)
										set new_page_counter to i + 32
										if selected button of item i of print_button_group_5_list is 0 then
											if selected index of proof_menu is 0 then
												set selected_preset to "FBEx1_Merge"
											else if selected index of proof_menu is 1 then
												set selected_preset to "FBEx2_Merge"
											end if
											set multi_preset_list to multi_preset_list & selected_preset
										else if selected button of item i of print_button_group_5_list is 1 then
											if selected index of proof_menu is 0 then
												set selected_preset to "Film_BMx1_EAE"
											else if selected index of proof_menu is 1 then
												set selected_preset to "Film_BMx2_EAE"
											end if
											set multi_preset_list to multi_preset_list & selected_preset
										else if selected button of item i of print_button_group_5_list is 2 then
											set selected_preset to "WideSingle B&W Composite"
											set multi_preset_list to multi_preset_list & selected_preset
										else if selected button of item i of print_button_group_5_list is 3 then
											set selected_preset to "Black White Ads"
											set multi_preset_list to multi_preset_list & selected_preset
										else if selected button of item i of print_button_group_5_list is 4 then
											set disclude_page_list to disclude_page_list & item i of page_names
										end if
									end repeat
									repeat with i from 1 to (count of print_button_group_6_list)
										set new_page_counter to i + 40
										if selected button of item i of print_button_group_6_list is 0 then
											if selected index of proof_menu is 0 then
												set selected_preset to "FBEx1_Merge"
											else if selected index of proof_menu is 1 then
												set selected_preset to "FBEx2_Merge"
											end if
											set multi_preset_list to multi_preset_list & selected_preset
										else if selected button of item i of print_button_group_6_list is 1 then
											if selected index of proof_menu is 0 then
												set selected_preset to "Film_BMx1_EAE"
											else if selected index of proof_menu is 1 then
												set selected_preset to "Film_BMx2_EAE"
											end if
											set multi_preset_list to multi_preset_list & selected_preset
										else if selected button of item i of print_button_group_6_list is 2 then
											set selected_preset to "WideSingle B&W Composite"
											set multi_preset_list to multi_preset_list & selected_preset
										else if selected button of item i of print_button_group_6_list is 3 then
											set selected_preset to "Black White Ads"
											set multi_preset_list to multi_preset_list & selected_preset
										else if selected button of item i of print_button_group_6_list is 4 then
											set disclude_page_list to disclude_page_list & item i of page_names
										end if
									end repeat
									
								end if	
--retrieves selected section letter
								set InDesign_Letter to false
								if selected index of section_menu is (-1) then
									set section_letter_invalid to true
									set get_an_eae to false
								else if selected index of section_menu is less than ((count of letter_options) - 1) then
									repeat with section_index from 0 to 26
										if selected index of section_menu is section_index then
											set section_letter to item (section_index + 1) of letter_options
											if section_letter is "B" then
												set zone_page to true
											end if
										end if
									end repeat
								else if selected index of section_menu is 27 then
									set InDesign_Letter to true
								end if
								
								--Reconciles Page Information 
								set page_range_list to {}
								set final_preset_list to {}
								set section_letter_list to {}
								if (count of disclude_page_list) is less than (count of page_names) then
									repeat with i from 1 to (count of page_names)
										if disclude_page_list does not contain item i of page_names then
											set page_range_list to page_range_list & item i of page_names
										end if
									end repeat
									set print_page_loop to (count of page_range_list)
									repeat with i from 1 to (count of page_range_list)
										set final_preset_list to final_preset_list & item i of multi_preset_list
										if InDesign_Letter is true then
											set multi_letter to item i of page_range_list
											set input_page_num_uc to sblib's convert_to_uppercase(multi_letter)
											try
												set first_character to first character of input_page_num_uc
												set section_letter_list to section_letter_list & first_character as string
											on error
												set first_character to ""
												set section_letter_invalid to true
												set get_an_eae to false
											end try
											repeat with i from 0 to 9
												set i to i as string
												if first_character is i then
													set section_letter_invalid to true
													set get_an_eae to false
												end if
												set i to i as integer
											end repeat
										end if
									end repeat
								else
									set get_an_eae to false
									
								end if



Well, I fixed the error message and now the script goes all the way though all the dialog boxes, lets you choose what you need then when it’s time to name the doc and send to the printer, it stops. Don’t know why, since I never changed any of that part of the script. Here’s what I did change:

if (count of page_names) < 6 then
set column_1 to make dialog column
tell column_1
set print_button_group_1_list to {}
repeat with i from 1 to (count of page_names)
set the_page to (item i of page_names) as string
set the_panel to make border panel
tell the_panel
make static text with properties {static label:the_page}
set print_button_group_1 to make radiobutton group
tell print_button_group_1
make radiobutton control with properties {static label:“Color (Merge)”}
make radiobutton control with properties {static label:“Color (Direct)”}
make radiobutton control with properties {static label:“Black & White”}
make radiobutton control with properties {static label:“BW Ads (Merge)”}
make radiobutton control with properties {static label:“Do Not Print”, checked state:true}
end tell
set print_button_group_1_list to print_button_group_1_list & print_button_group_1 as list
end tell

								end repeat
							end tell

(I added the BW Ads (Merge) radiobutton, and all subsequent collumns that the script puts into the dialogn box.)
And I changed this:

---------------------------------------------------------------------------------------------------------------------------------
						--retrieves information from Multi Dialog Box
						---------------------------------------------------------------------------------------------------------------------------------
						if checked state of proof_doc_box is false then
							set multi_preset_list to {}
							set disclude_page_list to {}
							if (count of page_names) < 6 then
								repeat with i from 1 to (count of page_names)
									if selected button of item i of print_button_group_1_list is 0 then
										if selected index of proof_menu is 0 then
											set selected_preset to "FBEx1_Merge"
										else if selected index of proof_menu is 1 then
											set selected_preset to "FBEx2_Merge"
										end if
										set multi_preset_list to multi_preset_list & selected_preset
									else if selected button of item i of print_button_group_1_list is 1 then
										if selected index of proof_menu is 0 then
											set selected_preset to "Film_BMx1_EAE"
										else if selected index of proof_menu is 1 then
											set selected_preset to "Film_BMx2_EAE"
										end if
										set multi_preset_list to multi_preset_list & selected_preset
									else if selected button of item i of print_button_group_1_list is 2 then
										set selected_preset to "WideSingle B&W Composite"
										set multi_preset_list to multi_preset_list & selected_preset
									else if selected button of item i of print_button_group_1_list is 3 then
										set selected_preset to "Black White Ads"
										set multi_preset_list to multi_preset_list & selected_preset
									else if selected button of item i of print_button_group_1_list is 4 then
										set disclude_page_list to disclude_page_list & item i of page_names
									end if
								end repeat

(This is where the button is connected to the actual preset. It also goes through the possible number of collumns.
I’m almost certain this is where it hangs up:


	--Final Print Loop (Names File / Prints)
	-------------------------------------------------------------------------------------------------------------------------------------------------------------
	if (pub_valid is true) and (page_num_valid is true) and (section_letter_invalid is false) and (broken_link is false) then
		
		set failed_to_print_list to {}
		repeat with i from 1 to print_page_loop
			
			if publication is "Regional" then
				set reg_edition to true
			else
				set reg_edition to false
			end if
			
			--If printing multiple pages, defines page specific information
			if checked state of multi_box is true then
				
				if InDesign_Letter is true and proof_doc is false then
					set selected_preset to item i of final_preset_list
					set raw_page_name to item i of page_range_list as text
					set page_to_print to raw_page_name
					set section_letter to first character of item i of section_letter_list
					if section_letter is "B" then
						set zone_page to true
					else
						set zone_page to false
					end if
					set page_num_only to sblib's extract_num_from_string(raw_page_name)
					set two_digit_page_num to sblib's make_num_two_digits(page_num_only)
				else if InDesign_Letter is false and proof_doc is false then
					set selected_preset to item i of final_preset_list
					set raw_page_name to item i of page_range_list as text
					set page_to_print to raw_page_name
					if section_letter is "B" then
						set zone_page to true
					else
						set zone_page to false
					end if
					set page_num_only to sblib's extract_num_from_string(page_to_print)
					set two_digit_page_num to sblib's make_num_two_digits(page_num_only)
				else if proof_doc is true then
					set page_to_print to (item i of page_names) as string
					set page_num_only to sblib's make_num_two_digits(page_to_print)
				end if
				set input_page_num_uc to ""
				set broken_link to sblib's check_link_status(input_page_num_uc, page_num_only, page_to_print)
			end if
			
			
			tell application "Finder" to activate
			tell application "Finder" to delay 2
			tell application "Adobe InDesign CS2" to activate

Please help. I’m at my wits end! Thanks!
jdg