How to refresh a global variable

Explorer ,
Aug 24, 2017

Copy link to clipboard

Copied

Hi,

I have a batch labeling action wizard which stores the starting document # in a global variable as "global.dnum".  The default start value is 1 (e.g., document 1).  I noticed if the user does not completely close Adobe Acrobat after labeling a batch of documents and then starts the action wizard again to label the next batch of documents, the action wizard skips the first document and instead labels the 2nd document with document 1 instead of document 2.  My guess is this happens because the global variable needs to be reset.  How can I force a reset/refresh of global.dnum so the user can label a set of say 10 documents and then label another set of 15 different documents, etc. without having to close Adobe Acrobat to ensure the right starting document number of 1 for each batch of documents?

Using Acrobat Pro IX.

Thx.

Sue

TOPICS
Acrobat SDK and JavaScript

Views

440

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

How to refresh a global variable

Explorer ,
Aug 24, 2017

Copy link to clipboard

Copied

Hi,

I have a batch labeling action wizard which stores the starting document # in a global variable as "global.dnum".  The default start value is 1 (e.g., document 1).  I noticed if the user does not completely close Adobe Acrobat after labeling a batch of documents and then starts the action wizard again to label the next batch of documents, the action wizard skips the first document and instead labels the 2nd document with document 1 instead of document 2.  My guess is this happens because the global variable needs to be reset.  How can I force a reset/refresh of global.dnum so the user can label a set of say 10 documents and then label another set of 15 different documents, etc. without having to close Adobe Acrobat to ensure the right starting document number of 1 for each batch of documents?

Using Acrobat Pro IX.

Thx.

Sue

TOPICS
Acrobat SDK and JavaScript

Views

441

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 24, 2017 0
Most Valuable Participant ,
Aug 24, 2017

Copy link to clipboard

Copied

You can create a folder-level script that adds a new menu item which

deletes or resets the global variable, if it exists.

On Thu, Aug 24, 2017 at 5:28 PM, sargums46564804 <forums_noreply@adobe.com>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 24, 2017 0
Adobe Community Professional ,
Aug 24, 2017

Copy link to clipboard

Copied

Add...

delete global['dnum'];

to the end of your batch.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 24, 2017 0
Most Valuable Participant ,
Aug 24, 2017

Copy link to clipboard

Copied

How would you know when the batch ends?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 24, 2017 0
Explorer ,
Aug 25, 2017

Copy link to clipboard

Copied

Hi,

I tried adding delete global.[dNum] to the javascript portion of this action wizard as Joel suggested but it did not do clear the variable after the batch ended.  Instead it reset the global variable after each time it labeled a document so try67 was right. 

Note I don't really have a traditional loop in the code.  Instead, the label gets applied to the first open document and then the remaining hidden documents which were selected for the batch.  After no more hidden documents are found, then it stops labeling and therefore ends the batch.  This was my work around for not being able to have a loop in the code b/c the action wizard sequence makes it difficult to have one.

I need to be able to reset the global variable after the batch ends so any advise would be so appreciated.  Some thoughts I had were:

1) Is there a way to identify the last hidden document in the sequence?

2) Is there a way to force the closing of the entire Adobe Acrobat after (1) is identified?

Then I can create an if then statement to do (2) when (1) happens or delete global variable when (1) happens.

Thx.

Sue

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 25, 2017 0
Most Valuable Participant ,
Aug 25, 2017

Copy link to clipboard

Copied

1) Only if you know the number of files that are going to be processed in advance.

2) No, but you don't need to. If you know the number of files you can simply delete the global variable when you get to it.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 25, 2017 0
Explorer ,
Aug 25, 2017

Copy link to clipboard

Copied

How do I count the number of files the user decides to batch label?  This is going to vary so I would need to get the count each time.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 25, 2017 0
Most Valuable Participant ,
Aug 25, 2017

Copy link to clipboard

Copied

Again, using a global variable, but if it varies each time then you'll have the same issue.

My solution of manually resetting the variable at the end of the process is the one only that will work, I think.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 25, 2017 0
Explorer ,
Aug 25, 2017

Copy link to clipboard

Copied

So the user would have to manually reset the global variable if they decide to do another batch of labeling without closing the entire Adobe application?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 25, 2017 0
try67 LATEST
Most Valuable Participant ,
Aug 25, 2017

Copy link to clipboard

Copied

Correct.

On Fri, Aug 25, 2017 at 7:19 PM, sargums46564804 <forums_noreply@adobe.com>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 25, 2017 0