Applescript to run another Applescript

I would like to run an applescript who pass variables contents to another applescript but it doesn’t work:

set myScript to load script file ((path to desktop folder as text) & "flagsmaker.scpt")
tell myScript
	set its ORDINE to "123456"
	set its RIGA to "01"
	set its COPIE to "001"
	set its TIPO to "Nationals"
end tell

The error I receive is:

error “Can’t make ORDINE into type reference.” number -1700 from ORDINE to reference

Anyone can help me? :slight_smile:

AppleScript: 2.7
Browser: Safari 605.1.15
Operating System: macOS 10.14

I have two suggestions, each of which consists of two scripts. Firstly,

-- first script
set theScript to (path to desktop folder as text) & "Script Two.scpt"

set ORDINE to "123456"
set RIGA to "01"
set COPIE to "001"
set TIPO to "Nationals"

run script file theScript with parameters {ORDINE, RIGA, COPIE, TIPO}

-- second script
on run {ORDINE, RIGA, COPIE, TIPO}
	display dialog ORDINE & space & RIGA & space & COPIE & space & TIPO
end run

Secondly,

-- first script
set myScriptPath to (path to desktop folder as text) & "Script Two.scpt"
set myScript to load script file myScriptPath

tell myScript
	set its ORDINE to "123456"
	set its RIGA to "00001"
	set its COPIE to "001"
	set its TIPO to "Nationals"
end tell

myScript's displayDialog()
-- second script
property ORDINE : missing value
property RIGA : missing value
property COPIE : missing value
property TIPO : missing value

on displayDialog()
	display dialog ORDINE & space & RIGA & space & COPIE & space & TIPO
end displayDialog

Hey peavine,
Thank you for your answer, the second solution worked perfectly to me!!!

To add to peavine’s two solutions, a third option is to pass values via a handler call. In the following example, the handler called main accepts the passed values:


-- First script
set myScriptPath to (path to desktop folder as text) & "Script Two.scpt"
set myScript to load script file myScriptPath

set ORDINE to "123456"
set RIGA to "01"
set COPIE to "001"
set TIPO to "Nationals"

myScript's main(ORDINE, RIGA, COPIE, TIPO)

-- Second script
on main(ORDINE, RIGA, COPIE, TIPO)
	displayDialog(ORDINE, RIGA, COPIE, TIPO)
end main

on displayDialog(ORDINE, RIGA, COPIE, TIPO)
	display dialog ORDINE & space & RIGA & space & COPIE & space & TIPO
end displayDialog