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

ES does not recognize an environment variable

Participant ,
Oct 15, 2015 Oct 15, 2015

Copy link to clipboard

Copied

Hello fellows,

On my Win 7 system, I've redefined the HOME environment variable as C:\Users\bnks (by default, it's C:\Documents and Settings\Users\bnks).

I'd like to save an FM file to C:\Users\bnks\Checkout\Test\, so in my extendscript, I've defined the following variable:


var docLib = "~\\Checkout\\Test\\";


where the tilde (~) should be parsed by extendscript as the HOME environment variable (according to Chapter 3, “File System Access” in the JavaScript Tools Guide).


Unfortunately, the tilde is ignored when I try to save the file:

...

var dname = docLib + rName + ".fm";

doc.Save(dname, saveParams, returnParams);

...


Any idea why this happens?


Thank you!!!



TOPICS
Scripting

Views

1.2K

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

Explorer , Oct 15, 2015 Oct 15, 2015

The tilde doesn't work for me either (FM11), but you can get the value of an environment variables with $.getenv():

var docLib = $.getenv("HOME") + "\\Checkout\\Test\\";

Votes

Translate

Translate
Explorer ,
Oct 15, 2015 Oct 15, 2015

Copy link to clipboard

Copied

The tilde doesn't work for me either (FM11), but you can get the value of an environment variables with $.getenv():

var docLib = $.getenv("HOME") + "\\Checkout\\Test\\";

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
Participant ,
Oct 19, 2015 Oct 19, 2015

Copy link to clipboard

Copied

Hi JoH,

Thank you for your response and for the suggestion! It does work. I wonder why tilde doesn't.

BTW, why is the $ sign used before the getenv(" ") function?

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
Enthusiast ,
Oct 19, 2015 Oct 19, 2015

Copy link to clipboard

Copied

Hi rombanks

BTW, why is the $ sign used before the getenv(" ") function?

have a look at:

Chapter 8, page 216, “Dollar ($) object” in the JavaScript Tools Guide

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
Participant ,
Oct 19, 2015 Oct 19, 2015

Copy link to clipboard

Copied

LATEST

Hi Klaus,

Thank you for the pointer. I appreciate your 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