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

When I append an additional variable to a string it stops working

Engaged ,
Nov 09, 2020 Nov 09, 2020

I have a function which creates a new tif file in a folder on the desktop. It has a global variable 'bCode' that works but as soon as I append an additional variable 'cCode' it no longer works. Any idea what would cause this?

This works

 

 

var bCode = "007745";
function save4x6() {
    var saveFileTif = new File("~/Desktop/" + bCode + "_Mock_ups/" + bCode + "_CVR.tif"); 

 

 

this doesn't, just adding the additional variable cCode it fails, it doesn't output. 

 

var bCode = "007745";
var cCode = "NLA";
function save4x6() {
    var saveFileTif = new File("~/Desktop/" + bCode + "_Mock_ups/" + bCode + "_CVR" + cCode+".tif"); 

 

 

 

 

TOPICS
Scripting
305
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

Engaged , Nov 09, 2020 Nov 09, 2020

I got it. The issue was that this was a bridge talk from ID to Pshop and I needed to grep the var. 

 

psScript = psScript.replace(/bCode/g, "\"" + bCode + "\"");
psScript = psScript.replace(/cCode/g, "\"" + cCode + "\"");
Translate
Engaged ,
Nov 09, 2020 Nov 09, 2020
LATEST

I got it. The issue was that this was a bridge talk from ID to Pshop and I needed to grep the var. 

 

psScript = psScript.replace(/bCode/g, "\"" + bCode + "\"");
psScript = psScript.replace(/cCode/g, "\"" + cCode + "\"");
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