Skip to main content
Inspiring
Mar 31, 2021 9:48 PM UTC
Answered

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

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 is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Mar 31, 2021 10:28 PM UTC

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,

2 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Mar 31, 2021 10:28 PM UTC

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,

Translate
yosimoAuthor
Inspiring
Apr 1, 2021 6:10 AM UTC

Ohh yes, that works.

Thank you very much.

 

Regards

Yosimo

Translate