Copy link to clipboard
Copied
Hi
I have several scripts in which our php systems generates a JSX file based on mysql data.
Some of these data values have quotes in the text value, which causes errors in photoshop due to the syntax.
Can anyone confirm how we can escape these quotes in photoshop scripting?
For example i have the below code
activeDocument.activeLayer.textItem.contents="' . $text1 . '";
For example the $text1 value could contain
"Test Value"
With quotes either side.
So how would we go about escaping the two quotes in script?
Thanks
When I have the same problem, triple quotes will help on this:
The layer will catch the inner double quote contained in the triple double quotes:
activeDocument.activeLayer.textItem.contents="""" . $text1 . """";
Copy link to clipboard
Copied
When I have the same problem, triple quotes will help on this:
The layer will catch the inner double quote contained in the triple double quotes:
activeDocument.activeLayer.textItem.contents="""" . $text1 . """";
Copy link to clipboard
Copied
I just had to change to tripple quotes but that has sorted that problem. Thanks for your help.
activeDocument.activeLayer.textItem.contents=""" . $text1 . """;
Copy link to clipboard
Copied
It doesn't enter into text layer value of variable so "Test Value", but name of variable ($text1). Is that you wanted. Can you also explain those dots?
Copy link to clipboard
Copied
What are those dots? I have other example that evaulates variable to its value and keep the dots, however I'm not sure what they are for, and the result of my code is different, but I thought it's what you wanted:
$text1 = "Test Value", activeDocument.activeLayer.textItem.contents = ". " + $text1 + " ."
Copy link to clipboard
Copied
The code is within our PHP script. It compliles the parameters via a number of statements ie; if then else code to generate a final jsx
So the dots basically come out of the php variable $design_code, and claim the value from a php variable, and then go back to the script.
See below example:
// SAVE PSD ON SERVER
$savefilename = $o['order_id'] . "_" . $rs_item["order_item_id"];
$design_code .= '
var Path = "/z/DESIGN_SERVER/";
var Name = "' . $savefilename . '";
var saveFile = File(Path + "/" + Name + ".psd");
SavePSD(saveFile, 8);
function SavePSD(saveFile){
psdSaveOptions = new PhotoshopSaveOptions();
psdSaveOptions.embedColorProfile = true;
psdSaveOptions.alphaChannels = true;
activeDocument.saveAs(saveFile, psdSaveOptions, true,
Extension.LOWERCASE);
}
';