Highlighted

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

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

 

 

 

 

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

Views

24

Likes

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

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

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

 

 

 

 

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

Views

25

Likes

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
Nov 09, 2020 0
Explorer ,
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

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 09, 2020 0