Skip to main content
Inspiring
November 9, 2020
Answered

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

  • November 9, 2020
  • 1 reply
  • 285 views

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"); 

 

 

 

 

This topic has been closed for replies.
Correct answer davidn5918184

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 + "\"");

1 reply

davidn5918184AuthorCorrect answer
Inspiring
November 9, 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 + "\"");