Here you\'ll find tutorials that don\'t belong to either of the above categories. This is the place for the most extraordinary materials.  Home Photoshop Miscellaneous Photoshop Scripting Basics: Scripting for Photoshop

Photoshop Scripting Basics: Scripting for Photoshop

Browse Pages: << < 1  2  3  4  5  > >>

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:
  • String - text or sentence. Strings must be enclosed in quotes ("")
  • Numbers - Numbers can be used in mathematical equations.
  • Booleans - true or false

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!";
alert(myVar);
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.

image 2 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.


Author's URL: FotoFects
Thank you for voting.
Rate this Materials:
Bad 
1 2 3 4 5 Excellent
Browse Pages: << < 1  2  3  4  5  > >>
print this page subscribe to newsletter subscribe to rss

Advance your current skills or acquire new skills in Photoshop by creating projects using our step-by-step tutorials. More Tutorials: Most Popular Materials | Fresh Materials | TutorialKit New Photoshop Tutorials

Add comments to "Photoshop Scripting Basics: Scripting for Photoshop"

Only registered users can write comment

No comments yet...