Copy link to clipboard
Copied
Hi everyone,
I did this UI script but I am receiving this error:
Error string: Invalid value for set properly 'dropCaplines'. Expected Short Integer (0 - 25), but received "2".
Source: p.dropCaplines = lcnt
The complet java scripting:
var dialog = new Window("dialog", undefined, undefined, {maximizeButton: true, independent: true});
dialog.text = "Dropword";
dialog.preferredSize.width = 300;
dialog.preferredSize.height = 211;
dialog.orientation = "column";
dialog.alignChildren = ["center","top"];
dialog.spacing = 10;
dialog.margins = 16;
// PANEL1
// ======
var panel1 = dialog.add("panel", undefined, undefined, {name: "panel1"});
panel1.text = "Paragraph Style";
panel1.preferredSize.width = 200;
panel1.preferredSize.height = 53;
panel1.orientation = "column";
panel1.alignChildren = ["left","top"];
panel1.spacing = 10;
panel1.margins = 10;
var edittext1 = panel1.add('edittext {properties: {name: "edittext1", multiline: true}}');
edittext1.text = "Drop Style";
edittext1.preferredSize.width = 150;
edittext1.preferredSize.height = 23;
// PANEL2
// ======
var panel2 = dialog.add("panel", undefined, undefined, {name: "panel2"});
panel2.text = "número de linhas";
panel2.preferredSize.width = 144;
panel2.preferredSize.height = 53;
panel2.orientation = "column";
panel2.alignChildren = ["left","top"];
panel2.spacing = 10;
panel2.margins = 10;
var edittext2 = panel2.add('edittext {properties: {name: "edittext2"}}');
edittext2.text = "2";
edittext2.preferredSize.width = 50;
// PANEL3
// ======
var panel3 = dialog.add("panel", undefined, undefined, {name: "panel3"});
panel3.text = "número de palavras";
panel3.preferredSize.width = 150;
panel3.preferredSize.height = 53;
panel3.orientation = "column";
panel3.alignChildren = ["left","top"];
panel3.spacing = 10;
panel3.margins = 10;
var edittext3 = panel3.add('edittext {properties: {name: "edittext3"}}');
edittext3.text = "1";
edittext3.preferredSize.width = 50;
edittext3.preferredSize.height = 23;
var convert_button = dialog.add ("button", undefined, "OK");
convert_button.onClick = function () { e.text = edittext1.text; edittext2.text; edittext3.text; }
dialog.show ();
var dsName = edittext1.text
// number of lines for the dropcap height
var lcnt = edittext2.text
//number of words to dropcap
var wcnt = edittext3.text
var ds = app.selection[0].paragraphs
for(var i=0; i < ds.length; i++){
var p=ds.item(i);
if (p.appliedParagraphStyle.name == dsName && p.lines.length > lcnt-1) {
var dc = p.words.itemByRange(p.words[0], p.words[wcnt-1]);
p.dropCapCharacters = dc.characters.length+1
p.dropCapLines = lcnt
}
}
Everything is working except the last line.
Please, any help would be great.
Sami
Hi Sami,
I think you are passing a string and it is expecting an Integer, so you may be able to fix it by forcing lcnt to be a number using
pasreInt ( lcnt, 10);
or
Number ( lcnt);
Copy link to clipboard
Copied
Hi Sami,
I think you are passing a string and it is expecting an Integer, so you may be able to fix it by forcing lcnt to be a number using
pasreInt ( lcnt, 10);
or
Number ( lcnt);
Copy link to clipboard
Copied