| Notices | Welcome to RetouchPRO . You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload images and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. | | Photoshop Scripting Learning and sharing for all platforms | 
12-13-2004, 07:38 AM
| | Member | | Join Date: Dec 2004 Location: Europe
Posts: 48
| | Hello World :) im reading the adobe photoshop scripting guide right now. Just made the hello world test, the first example and discovered that java is case sensive!! im going to use plent of hours correcting case letters i think
But on to the question:
This is what i wrote: Code: 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;
and then it tells me the last lines originalunit is undefined..? dosent it say that when the casething is wrong or is just an error message for dont know what your writing there  ? | 
12-13-2004, 08:02 AM
|  | Member | | Join Date: Nov 2004 Location: Southampton
Posts: 78
| | | 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. | 
12-13-2004, 08:19 AM
|  | Moderator | | Join Date: May 2004 Location: Goiânia, Brazil
Posts: 1,549
| | | 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.
Alternatives....
- 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
etc...
etc...
If you have a standard it'll be much easier to get it right than having to remember how you declared each variable.
byRo | 
12-13-2004, 09:22 AM
| | Member | | Join Date: Dec 2004 Location: Europe
Posts: 48
| | | 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.
Thanks, Lasse | 
12-14-2004, 04:39 AM
|  | Moderator | | Join Date: May 2004 Location: Goiânia, Brazil
Posts: 1,549
| | | 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.
byRo | 
12-14-2004, 06:37 AM
|  | Senior Member | | Join Date: Nov 2004 Location: Knoxville Tennessee
Posts: 210
| | | Hungarian Notation 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
etc, etc...
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.
Take care,
Michael | 
12-14-2004, 03:45 PM
|  | Moderator | | Join Date: May 2004 Location: Goiânia, Brazil
Posts: 1,549
| | | 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).
byRo |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | All times are GMT -6. The time now is 08:48 PM. | |
|