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

Visual Studio Code question...

Contributor ,
May 19, 2023 May 19, 2023

Copy link to clipboard

Copied

Hi Everyone,

The other day I upgraded my OS and have to now use Visual Studio Code.

Are there any useful resources to check I'm using VSC correctly when writing/executing my scripts?

I've installed VSC and one other question I have is, if I'm using $.writeln is there somewhere I can see the output of this as per the JS Console in ESTK ?

Thanks.

TOPICS
Scripting , SDK

Views

1.1K

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 , May 20, 2023 May 20, 2023

if I'm using $.writeln is there somewhere I can see the output of this as per the JS Console in ESTK

 

Hi @deckarduk , Also, your $.writeln() should show in the debug console panel:

 

Screen Shot 8.png

Votes

Translate

Translate
Community Expert , May 23, 2023 May 23, 2023

Hi @deckarduk, with ExtendScript debugger for VSCode, use //@ instead of # for targetengine and include directives.

 

//@targetengine "main"
//@include '~/Desktop/myLibrary.js'

 

- Mark 

 

P.S. you can set the default targetengine in your launch.json file. See my example above ("engineName").

Votes

Translate

Translate
Community Expert ,
May 20, 2023 May 20, 2023

Copy link to clipboard

Copied

Hi @deckarduk, I've got lots to say about VSCode. I actually love using it, compared to the old ways. I'm assuming you have installed the ExtendScript Debugger. Here's a few quick things:

 

1. This is my launch.json file. Bring up the command palette and type launch.json to edit it.

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "extendscript-debug",
            "request": "attach",
            "name": "Attach Indesign",
            "hostAppSpecifier": "indesign",
            "engineName": "main",
            "hiddenTypes": [
                "builtin",
            ],
        },
    ]
}

 

2. Here's my debugging keyboard shortcuts. Bring up command palette and type key and choose "Open keyboard shortcuts (JSON) to edit. You'll need to set the keys how you like.

    {
        "key": "alt+cmd+.",
        "command": "workbench.debug.panel.action.clearReplAction"
    },
    {
        "key": "ctrl+alt+cmd+a",
        "command": "workbench.action.debug.stop",
        "when": "inDebugMode"
    },
    {
        "key": "ctrl+alt+cmd+a",
        "command": "workbench.action.debug.run",
        "when": "debuggersAvailable && debugState == 'inactive'"
    },
    {
        "key": "cmd+r",
        "command": "extension.extendscript-debug.evalInAttachedHost",
        "args": {
            "debugLevel": 1,
            "bringToFront": false
        }
    },
    {
        "key": "cmd+shift+r",
        "command": "extension.extendscript-debug.evalInAttachedHost",
        "args": {
            "debugLevel": 1,
            "bringToFront": true
        }
    },
    {
        "key": "cmd+.",
        "command": "extension.extendscript-debug.haltInHost",
        "when": "inDebugMode"
    },
    {
        "key": "ctrl+.",
        "command": "workbench.action.debug.stop",
        "when": "inDebugMode"
    },
    {
        "key": "ctrl+m",
        "command": "workbench.action.debug.stepInto",
        "when": "debugState != 'inactive'"
    },
    {
        "key": "ctrl+i",
        "command": "workbench.action.debug.stepOut",
        "when": "debugState == 'stopped'"
    },
    {
        "key": "ctrl+l",
        "command": "workbench.action.debug.stepOver",
        "when": "debugState == 'stopped'"
    },
    {
        "key": "ctrl+shift+l",
        "command": "workbench.action.debug.continue",
        "when": "debugState == 'stopped'"
    },
    {
        "key": "ctrl+shift+c",
        "command": "editor.debug.action.runToCursor",
        "when": "debugState == 'stopped'"
    },

 

3. To see the debug console, type cmd-shift-Y (MacOS) probably ctrl-shift-Y on Windows.

debug console.jpg

 

Hope that helps a bit. Post back if you get stuck.

- 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
Contributor ,
May 22, 2023 May 22, 2023

Copy link to clipboard

Copied

Hi Mark,

Wow! Thanks for all the help, that's great.

I'll work through the stuff above and see I how I get on.

Thanks again for all help 👍

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
Contributor ,
May 22, 2023 May 22, 2023

Copy link to clipboard

Copied

Hi Mark,

I'm using the 'Evaluate the active file in a host application' button in the bottom bar.

Each time I have to specify a version of InDesign and then, because I'm working on a palette, select the dialog engine.

Am I using VSC correctly?

Thanks

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 ,
May 22, 2023 May 22, 2023

Copy link to clipboard

Copied

Hi @deckarduk , I’m sure Mark will have more tips, but for me the major difference between VSC and ESTK, is VSC wants you to identify a working folder for your scripts and associate a .JSON configuration for the scripts in that folder.

 

So, I have a folder that contains all of the InDesign scripts I want to test and use. When I open that folder via VS Codes’s File>Open Folder..., the scripts are listed in Code’s Explorer, from there I can open a script and edit or run. The launch.json file sets the debugging preferences for the scripts in the Explorer folder:

 

Screen Shot 20.png

 

Screen Shot 21.png

 

Then Run and Debug to run a script. My launch.json runs the selected script in InDesign and displays errors and writeln output in the Console

 

Screen Shot 19.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
Contributor ,
May 23, 2023 May 23, 2023

Copy link to clipboard

Copied

Hi Rob,

Thanks for the help, really appreciate it.

One of your screen grabs covers a question I was going to ask about ...

#targetengine "session";

which I have in the project I'm working on. VSC tells me I have a problem with that line - ';' expected. To get the palette to execute I have to select a different engine to main - com.adobe.ccx.sharesheet.dialog_Engine_Id - is that correct?

I also have to select a version of InDesign each time I execute my script, is that correct?

I'll set up my json file as per yours and see if that helps.

Many thanks once again, Rob.

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
Advocate ,
May 23, 2023 May 23, 2023

Copy link to clipboard

Copied

quote

I also have to select a version of InDesign each time I execute my script, is that correct?

Enter in the launch.json under hostAppSpecifierEnter your current version number of InDesign in the launch.json under hostAppSpecifier:

"hostAppSpecifier": "indesign-18.064"
Viele Grüße
Mario

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 ,
May 23, 2023 May 23, 2023

Copy link to clipboard

Copied

Hi @deckarduk, with ExtendScript debugger for VSCode, use //@ instead of # for targetengine and include directives.

 

//@targetengine "main"
//@include '~/Desktop/myLibrary.js'

 

- Mark 

 

P.S. you can set the default targetengine in your launch.json file. See my example above ("engineName").

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
Contributor ,
May 24, 2023 May 24, 2023

Copy link to clipboard

Copied

LATEST

Thanks for the help Mario 👍

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 ,
May 20, 2023 May 20, 2023

Copy link to clipboard

Copied

if I'm using $.writeln is there somewhere I can see the output of this as per the JS Console in ESTK

 

Hi @deckarduk , Also, your $.writeln() should show in the debug console panel:

 

Screen Shot 8.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
Contributor ,
May 22, 2023 May 22, 2023

Copy link to clipboard

Copied

Hi Rob,

Many thanks for the help.

Glad to see we can still do that sort of thing, I use it quite a lot.

I've only spent 1.5 days using VSC so still learning and the upgrade came during a reasonable sized project.

Thanks again 👍

 

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 ,
May 23, 2023 May 23, 2023

Copy link to clipboard

Copied

@deckarduk, there is some info in this thread, too.

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 ,
May 24, 2023 May 24, 2023

Copy link to clipboard

Copied

Hi @m1b,

A question, by replacing # with //@ we would make VSCode happy but would that execute fine when the script would be executed by other means. Let's say via the Scripts Panel?

-Manan

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 ,
May 24, 2023 May 24, 2023

Copy link to clipboard

Copied

Hi @Manan Joshi, it has never been a problem for me. - 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