• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

VS Code Javascript Debug

Engaged ,
Apr 01, 2022 Apr 01, 2022

Copy link to clipboard

Copied

I'm working through "JavaScript for InDesign" (second edition) by Peter Kahrel. I'm on MacOS Big Sur so have installed VS Code, set the launch.json from some youtube instructions and managed to get the basic hello world alert working without any problems. However, in Chapter 6 "InDesign’s Object Model" section I'm trying to do the equivalent of what is being asked to be done in the ESTK (app.selection[0] resulting in JavaScript console feedback "[object InsertionPoint]") and cannot for the life of me figure out how to get this sort of feedback in VS Code. I thought I was onto something in the docsforadobe.dev "JavaScript Tools Guide CC" section called "Getting Started with the VS Code Debugger" but don't have a menu option Debug > Start Debugging (if that's even what I'm supposed to be doing?!). I'm a bit lost and going to bed in the hope someone can nudge me in the right direction in the morning when I get up! Any help gratefully received!

TOPICS
Scripting

Views

966

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Apr 01, 2022 Apr 01, 2022

Hi @MrZZY, when you say the "hello world" alert was working—it made Indesign show an alert? If so, good! Your launch.json is okay. In that case just use $.writeln(myObject) in your code and run that script through the ExtendScript debugger—the same way as you ran the alert('Hello world') script.

As for the Object Model viewer of ESTK, that isn't working too well in ExtendScript Debugger 1.0 which you are probably using. They are working on a new version 2.0 that is much better but we'll have to

...

Votes

Translate

Translate
Community Expert , Apr 02, 2022 Apr 02, 2022

Hi @MrZZY , also, in case you haven’t done it, create a root folder for storing and editing your scripts, then open that folder via File>Open Folder. The first time you open a folder you will be prompted to create a json, that will be associated with the scripts in the folder. From the Explorer you can then make copies of templates or existing scripts by Option dragging or right-clicking a script.

 

Screen Shot 9.png

 

To Debug you should be able to use the default F5 key, or from the menu it should be Run>Start

...

Votes

Translate

Translate
Community Expert ,
Apr 01, 2022 Apr 01, 2022

Copy link to clipboard

Copied

Hi @MrZZY, when you say the "hello world" alert was working—it made Indesign show an alert? If so, good! Your launch.json is okay. In that case just use $.writeln(myObject) in your code and run that script through the ExtendScript debugger—the same way as you ran the alert('Hello world') script.

As for the Object Model viewer of ESTK, that isn't working too well in ExtendScript Debugger 1.0 which you are probably using. They are working on a new version 2.0 that is much better but we'll have to wait for that. In the meantime, see what you can glean from the object model in this documentation. It lists all the objects and their properties.

It's well worth persevering—VSCode is a great IDE in my opinion.

- Mark

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 02, 2022 Apr 02, 2022

Copy link to clipboard

Copied

LATEST

Thanks. I have bookmarked the object model documentation. Yes I was able to get InDesign to show the alert, it was the debug output that I couldn't reproduce in VS Code as I'm on Mac and can't use the ESTK toolkit thing that doesn't even appear as a download in my creative cloud installer app thing. Good to hear that VSC is held in good regard 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 02, 2022 Apr 02, 2022

Copy link to clipboard

Copied

Hi @MrZZY , also, in case you haven’t done it, create a root folder for storing and editing your scripts, then open that folder via File>Open Folder. The first time you open a folder you will be prompted to create a json, that will be associated with the scripts in the folder. From the Explorer you can then make copies of templates or existing scripts by Option dragging or right-clicking a script.

 

Screen Shot 9.png

 

To Debug you should be able to use the default F5 key, or from the menu it should be Run>Start Debugging (not Debug>Start Debugging. Here my selection is an insertion point and I can get info on the selection via $.writeIn() in the Debug Console

 

Screen Shot 10.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 02, 2022 Apr 02, 2022

Copy link to clipboard

Copied

Yes! Thank you so much for this. I was able to use your code (eventually, I kept thinking it was WriteIn (in) but got there in the end!).

 

I can now get the feedback mentioned in the book and continue my studies. I was getting so down banging my head against a wall trying to figure this out. It looks like a fab book you just can't follow this chapter on Mac using VS Code (without further help such as you've provided.)

 

CleanShot 2022-04-03 at 03.50.14.png

Yay! Check it out! No more crying into my keyboard!

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines