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

Script doesn't work in Photoshop CS3

Contributor ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

Hello everyone!
Guys is there any possibility of a script working correctly in Photoshop CS3.
It serves to import a price table via a text.text file into a dialog window, once the text is loaded, I will have to make some changes to the text after saving.
At the company I work for, it works perfectly on the latest versions, however, in my house my computer is very limited and I can only work with the CS3 version of Photoshop
and this script I will need to use more often in my house.
All help is valid!
Here the script and the price list:

 

    dle = new Window("dialog"); dle.text = "Tabela de Preços!"; 
    dle.orientation = "column"; 
    fFile = File ( "~/desktop/Preços.txt" );
    fFile.open("r");  stringFromTextFile = fFile.read();  valores =  stringFromTextFile.split();
    edittext1 = dle.add('edittext {size: [240.59,305.556], properties: {name: "edittext1", multiline: true}}'); 
    edittext1.text = valores
    gp1 = dle.add("group", undefined, {name: "gp1"}); 
    bt2 = gp1.add("button", undefined, undefined, {name: "bt2"}); 
    bt2.text = "Salvar";  bt2.preferredSize.width = 90; 
    bt1 = gp1.add("button", undefined, undefined, {name: "bt1"}); 
    bt1.text = "Fechar";  bt1.preferredSize.width = 90; 

    bt2.onClick = function (){
        dle.close(); var URL = new File("~/desktop/Preços.txt");  URL.open("w"); URL.writeln(edittext1.text); 
    }
    dle.show();

 

 

Preços.txt

ADESIVO: 
75,00  | Amador
65,00  | Profissional
-----------------------------
CANVAS:
85,00  | Amador
75,00  | Profissional
-----------------------------
LONA:
95,00  | Amador
85,00  | Profissional
-----------------------------
PAPEL:
150,00 | Amador
120,00 | Profissional
-----------------------------
OUTRO:
0,00
-----------------------------    
TOPICS
Actions and scripting

Views

1.2K

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

Guide , Nov 07, 2021 Nov 07, 2021

I found a user with windows XP and Photoshop CS3 installed 😄😄😄
In general, it looks like this is a feature of a particular version - it really cannot display an array as a string. There is no such problem in CS2, but multiline is not supported there. 

2021-11-08_00-31-02.png

The solution is to remove the .split ()

 

dle = new Window("dialog"); dle.text = "Tabela de Preços!"; 
    dle.orientation = "column"; 
    fFile = File ( "~/desktop/Preços.txt" );
    fFile.open("r");  stringFromTextFile = fFile.read();  valore
...

Votes

Translate

Translate
Adobe
LEGEND ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

What you mean it does not work for you correctly?

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
Contributor ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

Hi @Kukurykus , for you it worked on the CS3 version??
In mine here it doesn't work.

Capturar.PNG

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 ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

Loll you talk like I have pretty old one realese ðŸ˜‰

 

In ESTK CC there's no problem as well as Ps & Br CS6.

 

Try without: , properties: {name: "edittext1", multiline: true}

 

If you'll see .txt content in one row, use more edittexts to display them separatly.

 

The last chance is to try this workaround: edittext1.text = eval(valores.toSource())

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
Contributor ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

@Kukurykus  tentei todas as suas alternativas porém sem sucesso

1: edittext1 = dle.add('edittext {size: [240.59,305.556]}'); ///

2: fFile.open("r"); stringFromTextFile = fFile.read(); valores = stringFromTextFile.split();
edittext1 = dle.add('edittext {size: [240.59,305.556], properties: {name: "edittext1", multiline: true}}');
edittext1.text = eval (valores.toSource ())

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 ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

Could also see if trying first tip, so removing the part I asked makes all in one row?

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
Guide ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

why is split () here? The string will simply turn into an array with one element, which is what your edittext1 shows

valores =  stringFromTextFile.split();

 

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
Contributor ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

Oi @jazz-y ! Este script não é meu, não tenho conhecimento de fazer scripts, encontrei em outro fórum há muito tempo. Não tenho ideia de como fazer isso. Sua ajuda é muito valiosa. Ele funciona bem em versões recentes, mas não funciona no meu Photoshop CS3.

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
Guide ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

Just remove .split() from this line

stringFromTextFile.split()

 

 

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 ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

Good catch! It seems later versions evaluate array content.

Still I wonder if my workaround makes the same. Let's see!

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
Guide ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

Perhaps this is a feature of CS3, since in later versions I repeatedly displayed the contents of the array simply by passing it to the textbox.

 

dle = new Window("dialog"); dle.text = "Tabela de Preços!"; 
edittext1 = dle.add('edittext {size: [240.59,305.556], properties: {name: "edittext1", multiline: true}}'); 
edittext1.text = ['test1','test2','test3']
dle.show();

 

2021-11-07_18-45-17.png


P.S. if there are problems with displaying the array, then  why eval? 🙂

edittext1.text = eval(valores.toSource())

 

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
Contributor ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

@jazz-y  Aqui testado no notebook do vizinho e funciona bem em versões recentes.

Capturar.PNG

I opened the window, modified the table text, saved it, then opened it again with the values correctly updated.

 

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 ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

Loll, then maybe double eval will help:

edittext1.text = eval(eval(valores.toSource()))

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
Contributor ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

I added and it still doesn't work

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 ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

More important now is to check what I asked 35 minutes ago.

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
Guide ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

I found a user with windows XP and Photoshop CS3 installed 😄😄😄
In general, it looks like this is a feature of a particular version - it really cannot display an array as a string. There is no such problem in CS2, but multiline is not supported there. 

2021-11-08_00-31-02.png

The solution is to remove the .split ()

 

dle = new Window("dialog"); dle.text = "Tabela de Preços!"; 
    dle.orientation = "column"; 
    fFile = File ( "~/desktop/Preços.txt" );
    fFile.open("r");  stringFromTextFile = fFile.read();  valores =  stringFromTextFile;
    edittext1 = dle.add('edittext {size: [240.59,305.556], properties: {name: "edittext1", multiline: true}}'); 
    edittext1.text = valores
    gp1 = dle.add("group", undefined, {name: "gp1"}); 
    bt2 = gp1.add("button", undefined, undefined, {name: "bt2"}); 
    bt2.text = "Salvar";  bt2.preferredSize.width = 90; 
    bt1 = gp1.add("button", undefined, undefined, {name: "bt1"}); 
    bt1.text = "Fechar";  bt1.preferredSize.width = 90; 

    bt2.onClick = function (){
        dle.close(); var URL = new File("~/desktop/Preços.txt");  URL.open("w"); URL.writeln(edittext1.text); 
    }
    dle.show();

 

2021-11-08_00-40-27.png

P.S.

@Kukurykus wrote:

Try without: , properties: {name: "edittext1", multiline: true}


Does what you would expect from removing the multiline, but does not solve the problem (the array still cannot be displayed).


But another obvious option works: 🙂

 

  edittext1.text = valores[0]

 

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
Valorous Hero ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

quote

...
There is no such problem in CS2, but multiline is not supported there. 

...


By @jazz-y

 

Untitled-1.jpg

 

: )

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
Guide ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

It should be read literally 🤣🤣🤣
When multiline is enabled In CS2, the text wraps width of control. However, ASCII control characters do not work, that is, you cannot control the contents of the textbox:

2021-11-08_01-32-50.png

🤷

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 ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

I don't have CS2 anymore, but maybe try to turn vlaores to jsxbin and use in the code as eval('jsxbinCode'). That sometimes helps to not miss out the '\' characters. Just an idea.

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
Guide ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

They are not lost - if we read the contents of the textbox character by character, then all the control codes will be in their place.

They just don't work.

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 ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

What about changing \n to \r or etcetera? Probably another faux pas from my side 😛

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
Valorous Hero ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

quote

2021-11-08_01-32-50.png

🤷


By @jazz-y

 

valores = valores.replace(RegExp("\\n", "g"), "\r\n");

 

: )

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 ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

You mean that's going to work in CS2?

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
Valorous Hero ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

quote

You mean that's going to work in CS2?


By @Kukurykus

 

Well, yes

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 ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

Another good found that recalled me something from deep past when I had problem with $.screens. After I put at end [0] it finally started to work with .left, .right etc. Too bad I didn't remember that earlier 😄

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