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

ES does not recognize an environment variable

Participant ,
Oct 15, 2015 Oct 15, 2015

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
1.5K
Translate
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\\";

Translate
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\\";

Translate
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

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!

Translate
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

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

Translate
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
LATEST

Hi Klaus,

Thank you for the pointer. I appreciate your help!

Translate
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