I am wondering if it is possible to simply this script using a repeat loop…
tell application "Adobe InDesign CC 2018"
activate
set amountTemperature to {"1", "2", "3", "4"}
set emissionList to {"75/65", "65/55", "55/45", "45/40", "45/38", "38/33", "35/30"}
set amountTemperatureNumber to choose from list amountTemperature with prompt "How many emissions do you want to calculate?" default items {"3"} OK button name "Update document"
if amountTemperatureNumber is false then return
-- selection: 1 emission
if item 1 of amountTemperatureNumber is equal to "1" then
set Emission1 to (choose from list emissionList with prompt "Select emission 1" default items {"75/65"} without multiple selections allowed) as string
set Flow1 to characters 1 thru 2 of Emission1 as string
set Return1 to characters 4 thru 5 of Emission1 as string
end if
-- selection: 2 emissions
if item 1 of amountTemperatureNumber is equal to "2" then
set Emission to (choose from list emissionList with prompt "Select emission 1" default items {"75/65"} without multiple selections allowed) as string
set Flow1 to characters 1 thru 2 of Emission as string
set Return1 to characters 4 thru 5 of Emission as string
set emissionList2 to {}
repeat with x from 1 to count of items of emissionList
set emissionItem to item x of emissionList
if emissionItem is not in Emission then set end of emissionList2 to emissionItem
end repeat
set Emission2 to (choose from list emissionList2 with prompt "Select emission 2" default items {"55/45"} without multiple selections allowed) as string
set Flow2 to characters 1 thru 2 of Emission2 as string
set Return2 to characters 4 thru 5 of Emission2 as string
end if
--selection: 3 emissions
if item 1 of amountTemperatureNumber is equal to "3" then
set Emission to (choose from list emissionList with prompt "Select emission 1" default items {"75/65"} without multiple selections allowed) as string
set Flow1 to characters 1 thru 2 of Emission as string
set Return1 to characters 4 thru 5 of Emission as string
set emissionList2 to {}
repeat with x from 1 to count of items of emissionList
set emissionItem to item x of emissionList
if emissionItem is not in Emission then set end of emissionList2 to emissionItem
end repeat
set Emission2 to (choose from list emissionList2 with prompt "Select emission 2" default items {"55/45"} without multiple selections allowed) as string
set Flow2 to characters 1 thru 2 of Emission2 as string
set Return2 to characters 4 thru 5 of Emission2 as string
set emissionList3 to {}
repeat with z from 1 to count of items of emissionList2
set emissionItem to item z of emissionList2
if emissionItem is not in Emission2 then set end of emissionList3 to emissionItem
end repeat
set Emission3 to (choose from list emissionList3 with prompt "Select emission 3" default items {"45/40"} without multiple selections allowed) as string
set Flow3 to characters 1 thru 2 of Emission3 as string
set Return3 to characters 4 thru 5 of Emission3 as string
end if
--selection: 4 emissions
if item 1 of amountTemperatureNumber is equal to "4" then
set Emission to (choose from list emissionList with prompt "Select emission 1" default items {"75/65"} without multiple selections allowed) as string
set Flow1 to characters 1 thru 2 of Emission as string
set Return1 to characters 4 thru 5 of Emission as string
set emissionList2 to {}
repeat with x from 1 to count of items of emissionList
set emissionItem to item x of emissionList
if emissionItem is not in Emission then set end of emissionList2 to emissionItem
end repeat
set Emission2 to (choose from list emissionList2 with prompt "Select emission 2" default items {"55/45"} without multiple selections allowed) as string
set Flow2 to characters 1 thru 2 of Emission2 as string
set Return2 to characters 4 thru 5 of Emission2 as string
set emissionList3 to {}
repeat with z from 1 to count of items of emissionList2
set emissionItem to item z of emissionList2
if emissionItem is not in Emission2 then set end of emissionList3 to emissionItem
end repeat
set Emission3 to (choose from list emissionList3 with prompt "Select emission 3" default items {"45/40"} without multiple selections allowed) as string
set Flow3 to characters 1 thru 2 of Emission3 as string
set Return3 to characters 4 thru 5 of Emission3 as string
set emissionList4 to {}
repeat with p from 1 to count of items of emissionList3
set emissionItem to item p of emissionList3
if emissionItem is not in Emission3 then set end of emissionList4 to emissionItem
end repeat
set Emission4 to (choose from list emissionList4 with prompt "Select emission 4" default items {"35/30"} without multiple selections allowed) as string
set Flow4 to characters 1 thru 2 of Emission4 as string
set Return4 to characters 4 thru 5 of Emission4 as string
end if
end tell