RetouchPRO

Go Back   RetouchPRO > Tools > Software > Photoshop Scripting

Notices

Photoshop Scripting Learning and sharing for all platforms

Reply
 
LinkBack Thread Tools
  #1  
Old 12-13-2004, 07:38 AM
Member
 
Join Date: Dec 2004
Location: Europe
Posts: 48
Smile 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 ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #2  
Old 12-13-2004, 08:02 AM
v.bampton's Avatar
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #3  
Old 12-13-2004, 08:19 AM
byRo's Avatar
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #4  
Old 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #5  
Old 12-14-2004, 04:39 AM
byRo's Avatar
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #6  
Old 12-14-2004, 06:37 AM
MBChamberlain's Avatar
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #7  
Old 12-14-2004, 03:45 PM
byRo's Avatar
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
World Series Kraellin 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


All times are GMT -6. The time now is 08:48 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
Copyright © 2008 Doug Nelson. All Rights Reserved




1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51