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

Participant ,
Nov 09, 2020 Nov 09, 2020

Copy link to clipboard

Copied

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

Views

71

Likes

translate

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

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

Likes

translate

Translate

Translate
Participant ,
Nov 09, 2020 Nov 09, 2020

Copy link to clipboard

Copied

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

Likes

translate

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