So I’m writing a script to calculate the difference between radius corner boxes so that when they are positioned in InDesign the arc if the corner is parallel.

I’ve cracked the script more or less but I’ve messed up the repeat bit at the end and I can’t work it out (my brain must be mush!)

Can anyone help please?

setrtoreturn

setwelcomeResulttobutton returnedof(display dialog“Radius Corner Nesting Box Calculator” & r & r & “A small application to quickly and easily calculate a correct radius for a nested radius corner box within another to ensure that the radius angle matches and is parallel” & r & r & “The formulas for these calculations are:” & r & “Outer radius – gap distance = Inner radius” & r & “Inner Radius + Gap Distance = Outer radius” buttons {“Cancel”, “Let’s work”} default button “Let’s work”)

ifwelcomeResultis“Cancel”then

errornumber -128 – User canceled

else

mymainFunction()

endif

– Function to calculate outer radius based on inner radius and gap distance

oncalculateOuterRadius(innerRadius, gapDistance)

returninnerRadius + gapDistance

endcalculateOuterRadius

– Function to calculate inner radius based on outer radius and gap distance

oncalculateInnerRadius(outerRadius, gapDistance)

returnouterRadius - gapDistance

endcalculateInnerRadius

– Main function to execute the script

onmainFunction()

– Prompt user for calculation choice

setcalculationChoicetochoose from list{“Calculate the radius of the inner box”, “Calculate the radius of the outer box”} with prompt “Choose the calculation:” default items {“Calculate the radius of the inner box”}withoutmultiple selections allowedandempty selection allowed

ifcalculationChoiceisfalsethen

display dialog“Thanks for using the app - have a great day!” buttons {“Quit”} default button “Quit”

return

endif

– Set radius dialog box text based on the calculation choice

setradiusTypePromptto“”

ifitem1ofcalculationChoiceis“Calculate the radius of the outer box”then

setradiusTypePromptto“Enter the radius of the inner box:”

else

setradiusTypePromptto“Enter the radius of the outer box:”

endif

– Prompt user for inner or outer radius and gap distance

setradiustotext returnedof(display dialogradiusTypePrompt default answer “”)

setgapDistancetotext returnedof(display dialog“Enter the gap distance between the two boxes:” default answer “”)

try

– Convert text input to numbers

setradiustoradiusasnumber

setgapDistancetogapDistanceasnumber

onerror

display dialog“Script error: Please note that you should only enter numeric values into the calculation boxes. Decimal points are allowed, however.” with iconcautionbuttons {“Quit”, “Try again”} default button “Try again”

ifbutton returnedoftheresultis“Quit”then

errornumber -128 – User canceled

else

mymainFunction()

endif

endtry

– Perform selected calculation

ifitem1ofcalculationChoiceis“Calculate the radius of the outer box”then

setresultRadiustocalculateOuterRadius(radius, gapDistance)

setresultTypeto“The outer box radius should be”

else

setresultRadiustocalculateInnerRadius(radius, gapDistance)

setresultTypeto“The inner box radius should be”

endif

– Copy the result to the clipboard

do shell script“echo " & (resultRadiusastext) & " | pbcopy”

– Display the result

display dialogresultType & ": " & resultRadius buttons {“Copy result & quit”, “Copy Cost to Clipboard & Calculate Again”} default button “Copy result & quit”

setnextActiontobutton returnedof(display dialogbuttons {“Copy result & quit”, “Copy Cost to Clipboard & Calculate Again”} default button “Copy Cost to Clipboard & Calculate Again”)

set the clipboard toresultRadius

if(nextActionis“Copy result & quit”)thenexitrepeat

endmainFunction