Applescript toggle to do This, this time, and That, next time?
You can do it by setting your own defaults parameter, to store the value between uses/reboots etc, otherwise an Applescript will not remember your current toggled state.

This is a quick example that will set a user-defined parameter [replace with actual company &amp;/or product name &amp; memorable parameter name if you have one, otherwise the example data will do fine] then will just say out loud, 'yes' or 'no' depending on the state of the defaults parameter switch.

You can run it from the open script or save it as an application.

set newTestParameter to "YES"
try
    set oldTestParameter to do shell script "defaults read com.myCo.myApp myParamSet"
    if oldTestParameter is in {"1", "YES"} then
        set newTestParameter to "NO"
    end if
end try
do shell script "defaults write com.myCo.myApp myParamSet " &amp; newTestParameter

--your actual code, dependant on above switch
if newTestParameter is in {"1", "YES"} then
    say "Yes"
    -- run thisCode
else
    say "No"
    -- run thatCode
end if


On first run it will write a new file to ~/Library/Preferences called com.myCo.myApp.plist &amp; will contain one parameter, with the current state of your toggle, like this

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
    &lt;key&gt;myParamSet&lt;/key&gt;
    &lt;string&gt;NO&lt;/string&gt;
&lt;/dict&gt;
&lt;/plist&gt;


You don't need to do anything to 'maintain' this on your own, you can simply keep sending its new value with each script run.