Planet PDF Forum Archive

Planet PDF ForumWowsers! This is page is old, head to the LIVE Planet PDF Forum. It features more than 10 conferences, covering everything from beginner to in-depth developer and pre-press discussions. If you wish to continue... one & two archive covers 1999-2011 (160,000 pages).


New Forum | Previous | Next | (P-PDF) Developers


Topic: Name Spaces - or Lack Thereof...
Conf: (P-PDF) Developers, Msg: 54807
From: terrill
Date: 5/29/2002 05:08 PM

Here's a good one for ya! I've been programming in C since 1984, and this blew me away... sorry for the length, but I don't like leaving out details (it's the Assembler Language programmer in me):

1. Create two text fields. We'll call 'em "fa" and "fb"

2. In the "validate" tab for fa, click on the "Custom validate scrip," and edit the script.

3. Copy/Paste the following code:

// ----CODE STARTS ----
var y;
var x;

var arSections = new Array();
arSections.push(
   "bill",
   "ship",
   "tec"
);

var arSectionsLen = arSections.length

for (var i = 0; i < arSectionsLen; i++) {
   x += arSections[i] + "\n";
}

app."X: " + x);
// ----CODE ENDS ----

4. Save the code. You should (in Acrobat 4.05, at least) get an alert. The results look like:

--RESULTS--
X: undefinedbill
ship
tec
-----------

5. Now, click the "hand" and make a change in fa, and press tab (do it a couple times, for fun!):

--RESULTS--
X: undefinedbill
ship
tec
bill
ship
tec
-----------

6. In the validate tab of fb, Add the following code:

// ----CODE STARTS ----

var x;

app."X: " + x);

// ----CODE ENDS ----

7. Save it. Start in either field you'd like, but things are now getting hairy! Seems
both fields share a name space.

What's worse, the "var x;" does not create a new variable. Which means, if you happen to be working in a team environment, and you pick names similar to those of your co-works, you're BOTH screwed!

I even tried the "old C programmers" trick of declaring a new "var x" inside the braces of a for loop:

// ----CODE STARTS ----

var x = "hi";

app."X: " + x);

for (var i = 0; i < 2; i++) {
   x = i;
}

app."X2: " + x);

// ----CODE ENDS ----

If you try this, after Adobe crashes... remove the last alert.

Don't know who designed the name space in this, but they sure do leave a LOT to be desired!!!

WORK-A-ROUND #1: THE SEQUEL

When creating variables, assign them values:

var x = new String;
var i = 0;
var myX = "";

ANYTHING! Just rememeber... you're tromping on someone else's "x!" And it COULD be your own!!!

BETTER SOLUTION: THE ART OF NAMING?

Give every variable a prefix of whatever field/event you're in:

// cust.name blur event
var custNameBlurX = 0;
var custNameBlurS = new Array();

Hey, enjoy!!! It's just "programming" in the 21st Century... "Code Without Thought."



PDF In-Depth Free Product Trials Ubiquitous PDF

Debenu Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link...

Download free demo

Debenu PDF Tools Pro

It's simple to use and will let you preview and edit PDF files, it's a Windows application that makes...

Download free demo

Back to the past, 15 years ago! Open Publish 2002

Looking back to 2002, it's amazing how much of the prediction became a reality. Take a read and see what you think!

September 14, 2017
Platinum Sponsor





Search Planet PDF
more searching options...
Planet PDF Newsletter
Most Popular Articles
Featured Product

Debenu PDF Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link control. Take Acrobat to the next level.

Features

Adding a PDF Stamp Comment

OK, so you want to stamp your document. Maybe you need to give reviewers some advice about the document's status or sensitivity. This tip from author Ted Padova demonstrates how to add stamps with the Stamp Tool along with related comments.