Variables
Variables are used to store value for organizational purposes. For example, if you have the title "My Photos" used several time in a script, you can set that as a variable and every time you want to change the title, you can simply edit the variable instead the the entire script. Lets create a simple script using a variable. Open a text editor such as Notepad to type the code.
var |
1. To begin, you need to tell Photoshop what you want to do. In this case, we want to create a variable and to create a variable, you can simply type in the keyword "var". | |
| |
||
var myVar |
2. Now we need to name the variable. Variable names can only contain alphanumeric characters and underscores. Lets call our variable "myVar" by typing it next to var. Variables are case-sensitive. | |
| |
||
var myVar = "Hello World" |
3. Now we need to tell Photoshop what
we want the value of myVar to be. There are three types of values you can enter:
Lets create a string variable called "Hello World!" by typing an = sign and then ""Hello World!"". Because this value is a string, don't forget to add the quotes. |
|
| |
||
var myVar = "Hello World!"; |
4. Finally, you need to end the instruction
by simply adding a ; at the end. Lets test the variable by creating an alert pop-up with the variable. To do this, type in alert(), add myVar inside the parenthesis and type a ; to instruction the instruciton. |
|
| |
||
![]() |
5. Save your file as a *.jsx file on your desktop. You can name it whatever you want. Open Photoshop and run the file (File> Scripts> Browse). an alert dialog should popup with your variable as the text. | |

10 Random Photoshop Miscellaneous :
10 Random TutorialKit Materials:













More Photoshop: