• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Javascript testing - seems to work but a few strange results

Explorer ,
Aug 28, 2022 Aug 28, 2022

Copy link to clipboard

Copied

I'm playing around with Page Label detection and created a simple if else code to see if I can get the results I want.  Essentially, the script will go through each page of the document and pull the Page Label (PLcheck).  It will examine the results to see if it's a number from 0 to 1000 and if so return the results in the console w.  If it's not between 0 to 1000 (either as a number or roman numeral), it will return the results for z.

var w = 0;
var x = 0;
var z = 0;

var PLcheck = getPageLabel(x);
console.println(PLcheck);

for (var p = 0; p < this.numPages; p++) { 
if (PLcheck >= 0 && PLcheck <= 1000){
	x = x + 1;
	w = w + 1;
	PLcheck = getPageLabel(x);
	console.println("w");
	console.println(PLcheck);
}
else {
	x = x + 1;
	z = z + 1;
	PLcheck = getPageLabel(x);
	console.println("z");
	console.println(PLcheck);
}
}
console.println(w);
console.println(x);    
console.println(z);  
console.println("Final");
console.println(PLcheck);

 It seems to report the proper results but at the end I noticed two abnormal results.  I get the following error.

 

TypeError: Invalid argument type.
Doc.getPageLabel:12:Console undefined:Exec
===> Parameter nPage.
undefined

 

Also, the last 5 console.println commands don't print out.  What am I doing wrong here?

TOPICS
How to , JavaScript

Views

94

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
community guidelines
Community Expert ,
Aug 29, 2022 Aug 29, 2022

Copy link to clipboard

Copied

LATEST

May be that x is not lower then this.numPages.

Votes

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
community guidelines