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

objects in global scope not available to included scripts

Engaged ,
Oct 26, 2017 Oct 26, 2017

Copy link to clipboard

Copied

Hi,

I have a few scripts that are functions that I include in one main file.

This main file is called from a custom menu item.

I want some objects to be available to all of my scripts, including the ones that I include.

For some reason none of my included scripts recognise the global objects.

The code below is the start of my main file. below that is a function, which is called by the menu item when it's clicked.

How do I make the objects below available to all of my included scripts?

#include "C:/Users/jcahill/AppData/Roaming/Adobe/InDesign/Version 12.0-ME/en_AE/Scripts/Scripts Panel/import translations/indexof.jsx"
#include "C:/Users/jcahill/AppData/Roaming/Adobe/InDesign/Version 12.0-ME/en_AE/Scripts/Scripts Panel/import translations/add_hyperlinks_v3.jsx"
#include "C:/Users/jcahill/AppData/Roaming/Adobe/InDesign/Version 12.0-ME/en_AE/Scripts/Scripts Panel/import translations/proofread_translations_v1.1.jsx"
#include "C:/Users/jcahill/AppData/Roaming/Adobe/InDesign/Version 12.0-ME/en_AE/Scripts/Scripts Panel/import translations/open_files_v1.1.jsx"
#include "C:/Users/jcahill/AppData/Roaming/Adobe/InDesign/Version 12.0-ME/en_AE/Scripts/Scripts Panel/import translations/add_pages.jsx"
#include "C:/Users/jcahill/AppData/Roaming/Adobe/InDesign/Version 12.0-ME/en_AE/Scripts/Scripts Panel/import translations/add_sections.jsx"
#include "C:/Users/jcahill/AppData/Roaming/Adobe/InDesign/Version 12.0-ME/en_AE/Scripts/Scripts Panel/import translations/get_each_language_data_v1.1.jsx"
#include "C:/Users/jcahill/AppData/Roaming/Adobe/InDesign/Version 12.0-ME/en_AE/Scripts/Scripts Panel/import translations/add_child_bookmarks.jsx"
#include "C:/Users/jcahill/AppData/Roaming/Adobe/InDesign/Version 12.0-ME/en_AE/Scripts/Scripts Panel/import translations/add_crossreferences.jsx"
#include "C:/Users/jcahill/AppData/Roaming/Adobe/InDesign/Version 12.0-ME/en_AE/Scripts/Scripts Panel/import translations/resize_overset_table.jsx"
#include "C:/Users/jcahill/AppData/Roaming/Adobe/InDesign/Version 12.0-ME/en_AE/Scripts/Scripts Panel/import translations/sort_headings.jsx"
#include "C:/Users/jcahill/AppData/Roaming/Adobe/InDesign/Version 12.0-ME/en_AE/Scripts/Scripts Panel/progress bar.jsx"

// this script is the entry point of the import IDML translations script
var ENGLISH = {
    FULL: "English",
    ABBR: "EN"
    },
FRENCH = {
    FULL: "French",
    ABBR: "FR"
    },
GERMAN = {
    FULL: "German",
    ABBR: "DE"
    },
ITALIAN = {
    FULL: "Italian",
    ABBR: "IT"
    },
SPANISH = {
    FULL: "Spanish",
    ABBR: "ES"
    },
NORWEGIAN = {
    FULL: "Norwegian",
    ABBR: "NO"
    },
RUSSIAN = {
    FULL: "Russian",
    ABBR: "RU"
    },
TURKISH = {
    FULL: "Turkish",
    ABBR: "TR"
    },
ARABIC = {
    FULL: "Arabic",
    ABBR: "AR"
    };

TOPICS
Scripting

Views

509

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 1 Correct answer

Community Expert , Oct 26, 2017 Oct 26, 2017

If you want your included files to recognise your global object, you'll have to define and initialise that object before calling the the include files. (Same confusion as in the British government about Brexit: May/Davies think that they can negotiate a deal after it was made!)

P.

Votes

Translate

Translate
Guide ,
Oct 26, 2017 Oct 26, 2017

Copy link to clipboard

Copied

I hope you have to use #includepath not #include...

if you use #include then all the scripts including the main script should be place in the same folder..

for more refer..

[JS CS3] Making the #includepath work

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 ,
Oct 26, 2017 Oct 26, 2017

Copy link to clipboard

Copied

If you want your included files to recognise your global object, you'll have to define and initialise that object before calling the the include files. (Same confusion as in the British government about Brexit: May/Davies think that they can negotiate a deal after it was made!)

P.

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
People's Champ ,
Oct 26, 2017 Oct 26, 2017

Copy link to clipboard

Copied

Good one Peter (cf Theresa May) Thought it was typically french those kind of "oopsie" troubles

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 ,
Oct 26, 2017 Oct 26, 2017

Copy link to clipboard

Copied

LATEST

Thanks Peter,

I solved it by putting the objects in an include file called global_objects.jsx.

Then, I just included that file first

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