|Photoshop Scripting Learning and sharing for all platforms|
| ||Thread Tools|
Hello World :)
But on to the question:
This is what i wrote:
var originaiUnit = app.preferences.rulerUnits; app.preferences.rulerUnits = Units.INCHES; var docRef = app.documents.add( 4, 2, 72, "Hello, World!"); var artLayerRef = docRef.artLayers.add(); artLayerRef.kind = LayerKind.TEXT; var textItemRef = artLayerRef.textItem; textItemRef.contents = "Hello, World!"; docRef = null; artLayerRef = null; textItemRef = null; app.preferences.rulerUnits = originalUnit;
I know nothing, but it looks to me like a spelling mistake on the first line - original has got an i instead of an l.
as v.bampton said...
You declared one variable and used another, so originalUnit is undefined.
Also,as you observed, Java is very case sensitive - you can lose a lot of time fixing these errors. Best to define a personal "standard" for the different type of object etc.. and stick to it.
- 1st letter lower case, 2nd word first letter upper case (Java's ugly standard);
- All lower;
- All upper;
- 1st letter upper case, 2nd word first letter upper case;
- Underline between words
If you have a standard it'll be much easier to get it right than having to remember how you declared each variable.
ohh so i can just keep everything a lowercase? think you mentioned it but thhis would make ti that much easyer.
Ofcause to look over a very compleks script a system might help but if it gets out of hand ill come up with one.
You can keep anything that you define in lower case, without any problem.
For all the other, pre-defined , words you have to use them exactly as defined.
Another common convention for programming is called Hungarian Notation...if works like this:
You use a two or three letter combination to indicate the type of variable,
bl = boolean
int = integer
obj = object
str = string
sng = single
dbl = double
lng = long
then you add your variable name with the first letter of each word capitalized.
Your variable for a person's first name would look like this: strFirstName
I usually program in C and Perl so I don't know if you have to define a variable type in Java, but it is a good idea anyway. The big advantage is you can read "strFirstName" easier than "strfirstname" and you know what kind of data is in it when you start performing mathematical operations or concatination.
Again, you can do it anyway you want as long as it is identical to both the declaration and call, but a good naming convention makes things easier for you, and especially for anyone else who reads through your code, in the long run.
Thanks, Michael, good idea. I'll be using this next time.
Java in Photoshop can be pretty confusing when you are trying to remember whether your variable / object is a color, or a layer, or a point etc... etc...
Probably have to start up a whole new naming convention:
rgb = RGB color (rgbViolet) ;
lyr = layer (lyrHP50);
pt = point (ptCenter).
|Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)|
|Thread||Thread Starter||Forum||Replies||Last Post|
|World Series||Craig Walters||Salon||2||11-02-2005 06:57 AM|
|Miss Digital World||Doug Nelson||Salon||2||11-10-2003 03:16 PM|
|A sad loss in the Photo Art world||ArtistColumbus||Salon||1||08-01-2003 01:45 PM|
|Photoshop World||d_kendal||Events||0||11-08-2002 09:03 PM|
|The world mourns us||Lorraine||Doodles||5||09-16-2001 11:57 AM|