Variable-driven if statement

Kind of bizarre but I’m going to ask anyways…obviously I have incorrect syntax but is there a way to echo out the contents of a variable that will build out part of an if statement?

Logic example:

set var1 to " or equal to 2"

if 1 is less than & var1 & then
	log "go!"
end if

Thanks

Hi,

there is a way, but it’s generally not recommended.
Second level evaluation is quite expensive because it creates a bunch of overhead


set var1 to " or equal to 2"

run script "1 is less than" & var1
if result then
	log "go!"
end if


Hmm ya that probably won’t do it for me.

Does Applescript have ternary operators? In PHP, I could do something like this:

Which would give me “Hello World. Now Goodbye”.

Thanks for the response.

PHP code is interpreted at runtime, AppleScript code must be compiled before running the script

Oh ya, that’s true. Thank you for the help.

Compile or run time has nothing to with it.

Applescript doesn’t support conditional expressions; conditional statements only.
Applescript doesn’t support ternary operations; binary only