Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat's wrong with this "if"?
    text
    copied!<p>I'm currently trying to make an AppleScript which should recognize the selected file in Finder and do the relative command in Terminal.</p> <p>Everything was going fine since I reached the part where it should define the language of the selected file: it just doesn't check the ifs. I checked if it writes fileExtension correctly (via return) and it does.</p> <p>Thanks</p> <pre><code>--&gt; Useful variables set fileCheck to false set languageCheck to false set selectionCheck to false set fileExtension to "" set myCommand to "" --&gt; Get selected file tell application "Finder" if selection is {} then tell application "Terminal" activate end tell else set finderSelection to selection as alias list set selectionCheck to true end if end tell --&gt; Get file POSIX path if selectionCheck is true then set filePath to quoted form of POSIX path of finderSelection end if --&gt; Get file extensions if filePath contains "." then set fileCheck to true set fileExtension to text ((offset of "." in filePath) + 1) thru -1 of filePath end if --&gt; Check language -- No Extension if fileCheck is false then display dialog "warning: the file you selected has no extension" buttons ("Ok") default button 1 -- Text else if fileExtension is "txt" then set myCommand to "open" set languageCheck to true -- Perl else if fileExtension = "pl" then set myCommand to "perl" set languageCheck to true -- Ruby else if fileExtension is "rb" then set myCommand to "ruby" set languageCheck to true -- Python else if fileExtension is "py" then set myCommand to "python" set languageCheck to true -- AppleScript else if fileExtension is "scpt" then set myCommand to "osascript" set languageCheck to true else display dialog "warning: the extension is not supported" buttons ("Ok") default button 1 end if --&gt; Terminal time! if fileCheck is true and languageCheck is true then do shell script "" &amp; myCommand &amp; " " &amp; filePath end if </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload