Skip to main content
Inspiring
March 31, 2021
Answered

Why does the dialog box show the page number with additional 6 zeros?

  • March 31, 2021
  • 1 reply
  • 681 views

I would like to display the page number of the current document in a dialog box. However, in the dialog box the page number always appears with a decimal point and six zeros. For a 64-page document I get the indication: 64.000000. Why is that? Since I want to continue calculating with this specification, I need the number without the decimal point and without the zeros.

// Dialog Definition
var oDlg = {
	strName1: "",
	initialize: function (dialog) {
		dialog.load({
			"page": this.strName1,
		});
	},
	commit: function (dialog) {
		var data = dialog.store();
		this.strName1 = data["page"];
	},
	description: {
		name: "Window titel",
		elements:
		[{
				type: "view",
				elements:
				[{
						type: "cluster",
						name: "Page count",
						align_children: "align_left",
						elements:
						[{
								type: "view",
								elements: [{
										type: "static_text",
										name: "Pages in this document:         ",
									}, {
										item_id: "page",
										type: "edit_text",
										readonly: "true",
										char_width: 25,
									}
								]
							},
						]
					}, {
						type: "ok_cancel",
					},
				]
			},
		]
	}
};

// Dialog Activation
oDlg.strName1 = this.numPages;
if ("ok" == app.execDialog(oDlg)) {
	console.println("Lin1: " + oDlg.strName1);
}

 

Does anyone have a hint for me why the dialog box does not display the page number correctly?

 

Regards

yosimo

This topic has been closed for replies.
Correct answer try67

That's how numbers are displayed in the dialog object.

To change it you need to convert the value to a string. You can do so by changing this line:

"page": this.strName1,

To this:

"page": ""+this.strName1,

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
March 31, 2021

That's how numbers are displayed in the dialog object.

To change it you need to convert the value to a string. You can do so by changing this line:

"page": this.strName1,

To this:

"page": ""+this.strName1,

yosimoAuthor
Inspiring
April 1, 2021

Ohh yes, that works.

Thank you very much.

 

Regards

Yosimo