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

Escape "Quotes" in Photoshop Scripts

Explorer ,
Jun 21, 2018 Jun 21, 2018

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

TOPICS
Actions and scripting

Views

1.8K

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

Enthusiast , Jun 21, 2018 Jun 21, 2018

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

Votes

Translate

Translate
Adobe
Enthusiast ,
Jun 21, 2018 Jun 21, 2018

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

Votes

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
Explorer ,
Jun 21, 2018 Jun 21, 2018

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

Votes

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
LEGEND ,
Jun 21, 2018 Jun 21, 2018

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?

Votes

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
LEGEND ,
Jun 21, 2018 Jun 21, 2018

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 + " ."

Votes

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
Explorer ,
Jun 21, 2018 Jun 21, 2018

Copy link to clipboard

Copied

LATEST

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

            }

';

Votes

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