After OSX 10.8.4 update, this small script stopped working
tell application "Adobe Photoshop CS6"
do javascript "alert('hello world')"
end tell
Can anyone confirm it's a change in AppleScript syntax introduced in last updated,
or I'm missing something?
Can your reproduce this script on OSX 10.8.4?
The exact error I get is:
Syntax error
Expected end of line but found identifier.
And JavaScript is highlighted.
I just struggled with a similar problem in Illustrator CC on 10.8.5 for a few hours.
I was running the script through a shell command in a .sublime-build file (Sublime Text 2).
Running the same basic script once from the official AppleScript Editor subsequently fixed it.
I still need to investigate why. If you have an idea, please comment.
I think the problem your experiencing is due to the fact that you have to specify a tab for applescript to run the JS code in. For example:
do JavaScript "alert('Hey');" in tab 1 of front window
If you don't specify which tab to run the javascript code in, it always throws the same 'identifier' error.
Hope this helps. (I've been frustrated by this one myself. It's easy to forget)
--Sorry, just realized you were talking about Illustrator. My mind immediately went to Safari's 'do javascript'.
Related
In Chrome's console (Tools ยป Developer Tools) the script I'm debugging is showing up without linebreaks even though the actual file has them. This has happened to me before, but I can figure out if it's something with the spaces in the file or a setting in Chrome. But it's pretty impossible to debug something when every error comes up as being on line 1. I tried restarting Chrome but no dice. Any idea how to get it back to normal?
Open your file with Notepad or some other editor and save it again. It seems like you ran into the same problem as the one mentioned here.
http://196.23.168.153/support/forum/p/Chrome/thread?tid=0936a4d8f8b915b5&hl=en
If that doesn't work, use the pretty print button :-)
It sounds like the file has been minified. Do you know if it's run through any kind of build process before you're looking at it?
If not, I'm not sure exactly why that might be happening. There is a halfway decent workaround:
Open the script in the Scripts tab, and click the {} prettyprint button at the bottom to restore the formatting. It's kind of annoying to have to do that all the time, though.
Is there a public link we could see? I can imagine that there might be some line-ending issues if the file was created on one platform (Mac/Linux/Windows) and is being viewed on another. Haven't run into this one myself yet.
I had this problem and it was the EOL line endings. I changed them from Mac Classic (\n) to Windows Dos (\n\r).
I'm developing in Javascript for quite a long time now. Usually when I hit an error in IE I know roughly where it originated even if the message received from IE is useless bunch of text. When I don't know where the error originated, I usually try to "delete" parts of my code, until the error doesn't repeat itself, and that start manually checking line by line until I find the error.
I'm sure that it's far from the best approach, so I'd like to ask you how you debug error like these:
If you are using IE8+, you can press F12 on a page to open the Developers Tools.
This contains a JavaScript debugger, much like Firebug & Chrome Dev Tools
EDIT:
In response to the comment under the question, if IE is throwing a cryptic error that you are unsure of, there is a couple of steps I would do.
Is it an IE only error? Does the same error occur in Firefox? Chrome?
Is the error occurring in a 3rd party library. If you believe it is, use an un-minified version of the library.
Can you replicate the error outside of your website? Can you make the error occur in a http://jsfiddle.net/ for instance?
If you still can't narrow down the issue, post a question on SO with your code, any error messages, and expectations of the result.
HTH
Try using non-minified version of jQuery - it will give you a better idea where exactly the error is. Also, if you use VS 2010 to debug your js code in IE, it will break at the error line. This always works fine for me.
IE is the only browser that I've managed to successfully use the fantastic Visual Studio script debugger with - in my experience Visual Studio is hands down the best script debugger out there, so quite often I find myself in the reverse situation to you (running broken scripts in IE just so I can use the script debugger)
See How to debug JavaScript in Internet Explorer for instructions on how to use Visual Studio Express to debug scripts in IE - if you own a full edition of Visual Studio then its much simpler (just attach to IE as normal).
I am working on a phonegap based project. I'd like to use some debug tools, to be able to debug some variables etc into XCode console, etc. Now, I've found, that in order to do this, I need to call function console.log.
The problem is, however, when running the application in simulator no debug info is displayed in XCode console... I am using phonegap version 0.9.3, what am I doing wrong?
Thanks for an answer
This feature was completed very recently (two days ago), and is not included in the 0.9.3 release. You can see this ticket in the issue tracker for more information.
To get this working, you have to pull the latest code from the PhoneGap GitHub repository. From a shell:
$ git clone git://github.com/phonegap/phonegap-iphone.git
... and then go about building up the source from scratch. You should see it then!
Alternatively, you replace your console.log statements with debug.log, and that will work in 0.9.3.
Lukas, there is a fantastic tool you can use to debug your phonegap project.
With iWebInspector you basically have Firebug for your Phonegap Application. You can even live-change the code.
Paste the following somewhere near the start of your document so that it gets executed before any of your other JavaScript.
<script type="text/javascript">
window.onerror = function(message, url, lineNumber) {
console.log("Error: "+message+" in "+url+" at line "+lineNumber);
}
</script>
And enjoy viewing details of your Javascript errors in the Xcode console window.
UPDATE: The above technique will log errors such as undefined variables. But syntax errors such as missing commas will still cause the entire script to break without logging anything.
Therefore you should add the following to the start of your onDeviceReady function:
console.log('Javascript OK');
If you don't see "JavaScript OK" appearing in your log window when the app launches, then it means you have a syntax error somewhere.
To save hunting for missing commas, the easiest thing is to paste your code into a Javascript validator such as this one:
http://www.javascriptlint.com/online_lint.php
and let it find the error for you.
Hopefully that takes some of the pain out of debugging.
I'm trying to debug a Javascript error which only occurs in Internet Explorer. I have Microsoft Script Debugger installed, and have used it successfully in the past. On this error, though, I select "Yes" to do-you-want-to-debug?, and it opens up Script Debugger, which displays nothing. Running documents window is empty, call stack is empty, as though nothing is being debugged.
Can anyone tell me what causes this?
I've had these sorts of issues before with the Microsoft Script Debugger but never managed to find a solution - if you have a license the script debugger inside Visual Studio 2008 is far far better.
There is an article here about how you can use VS 2008 Express (free) as a script debugger.
I've seen this issue with code inside a try/catch/finally block--for some reason the debugger gets confused by the finally block. Try commenting them out.
I know this is old but I thought I would point out that this is still an issue. Microsoft plain sux. Developers are being forced to support products that are broken....this is a crime
Something broke and I get "Object Expected" error on my live site, but I can't figure out where. If I run visual studio at the same time, it breakpoints it and shows the error as being half way along the viewstate, highlighted yellow... which is useless as its just gobbledegook.
How can I debug this? I want to know what javascript its trying to run that is breaking it.
Firefox and Firebug.
http://getfirebug.com/
Never debug Javascript without it.
Check out ScriptCanary.com so you can get all the details from live site errors and vastly improve your chances of quickly fixing them.