Tell application : Variable : end tell

I want to be able to send any command to any application. this is what I have:

set target to (choose application)
set command to the text returned of (display dialog "Insert command:" default answer "" buttons {"Cancel", "OK"} default button "OK")
tell target
	command
end tell

the command can’t be sent.

Model: iMac
AppleScript: 2.1.1
Browser: Safari 417.9.3
Operating System: Mac OS X (10.4)

Hi,

in some cases this works:

set target to (choose application)
set command to the text returned of (display dialog "Insert command:" default answer "" buttons {"Cancel", "OK"} default button "OK")
tell target
	run script command
end tell

IT WORKS! Thank you for the quick reply!

ok, new problem. THe 1st works, the 2nd doesent. Why?

set target to (choose application)

set command to the text returned of (display dialog "Insert command:" default answer "" buttons {"Cancel", "OK"} default button "OK")
tell target
	run script command
end tell
set target to the text returned of (display dialog "Insert program name:" default answer "" buttons {"Cancel", "OK"} default button "OK")

set command to the text returned of (display dialog "Insert command:" default answer "" buttons {"Cancel", "OK"} default button "OK")
tell target
	run script command
end tell

I only changed the application choosing method.

Nevermind, I forgot to put tell APPLICATION because it was text.

you forgot the word “application” :wink:

set target to the text returned of (display dialog "Insert program name:" default answer "" buttons {"Cancel", "OK"} default button "OK")

set command to the text returned of (display dialog "Insert command:" default answer "" buttons {"Cancel", "OK"} default button "OK")
tell application target
	run script command
end tell

Yes, I’d realised. :stuck_out_tongue: Thanks for trying to help!