RetouchPRO

Go Back   RetouchPRO > Tools > Software > Photoshop Scripting
Register Blogs FAQ Site Nav Search Today's Posts Mark Forums Read


Photoshop Scripting Learning and sharing for all platforms

Hello World :)

Reply
 
Thread Tools
  #1  
Old 12-13-2004, 08:38 AM
Lasse Lasse is offline
Member
 
Join Date: Dec 2004
Location: Europe
Posts: 54
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 ?
Reply With Quote top
  #2  
Old 12-13-2004, 09:02 AM
v.bampton's Avatar
v.bampton v.bampton is offline
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.
Reply With Quote top
  #3  
Old 12-13-2004, 09:19 AM
byRo's Avatar
byRo byRo is offline
Senior Member
 
Join Date: May 2004
Location: Goianésia, Brazil
Posts: 1,609
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
Reply With Quote top
  #4  
Old 12-13-2004, 10:22 AM
Lasse Lasse is offline
Member
 
Join Date: Dec 2004
Location: Europe
Posts: 54
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
Reply With Quote top
  #5  
Old 12-14-2004, 05:39 AM
byRo's Avatar
byRo byRo is offline
Senior Member
 
Join Date: May 2004
Location: Goianésia, Brazil
Posts: 1,609
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
Reply With Quote top
  #6  
Old 12-14-2004, 07:37 AM
MBChamberlain's Avatar
MBChamberlain MBChamberlain is offline
Senior Member
 
Join Date: Nov 2004
Location: Knoxville Tennessee
Posts: 281
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
Reply With Quote top
  #7  
Old 12-14-2004, 04:45 PM
byRo's Avatar
byRo byRo is offline
Senior Member
 
Join Date: May 2004
Location: Goianésia, Brazil
Posts: 1,609
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
Reply With Quote top
Reply

  RetouchPRO > Tools > Software > Photoshop Scripting


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
World Series Craig Walters Salon 2 11-02-2005 07:57 AM
Miss Digital World Doug Nelson Salon 2 11-10-2003 04:16 PM
A sad loss in the Photo Art world ArtistColumbus Salon 1 08-01-2003 02:45 PM
Photoshop World d_kendal Events 0 11-08-2002 10:03 PM
The world mourns us Lorraine Doodles 5 09-16-2001 12:57 PM


All times are GMT -6. The time now is 01:20 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
Copyright © 2016 Doug Nelson. All Rights Reserved