Dialogue box results "not a number"


hello! i'm new indesign scripting (as of today) , having difficulty using dialogue box results in script. script i've put creates calligraphy line guides down page, , got working fine wanted able specify distances between lines in dialogue box rather in script, , it's not working.

 

i know line 43 downwards works if remove dialogue box , create variables using parseint() rather pulling them in dialogue box, try use values dialogue box comes error 30491 on line 60 ascenderheight not number (and presumably can't use calculate within geometricbounds). i've tried converting test variable integer beneath line 43, it's not making difference. using measurementeditbox in indesign scripting tutorial, figured integer 1 remove excess baggage. if let me know i'm going wrong, i'd appreciate it!

 

var mydialog = app.dialogs.add({name: "set line guide parameters",cancancel:true}) ; (mydialog){ //add labels dialog column. with(dialogcolumns.add()){     statictexts.add({staticlabel:"x-height ascender (mm)"});     statictexts.add({staticlabel:"x-height (mm)"});     statictexts.add({staticlabel:"descender height (mm)"});     statictexts.add({staticlabel:"slant angle"});     }   //add entry dialog column with(dialogcolumns.add()){   //create integer & angle entry fields.     var ascenderheightfield = integereditboxes.add({editvalue:5}) ;     var xheightmmfield = integereditboxes.add({editvalue:5}) ;     var descenderheightfield = integereditboxes.add({editvalue:2}) ;     var slantanglefield = angleeditboxes.add({editvalue:-30}) ; } }     //display dialog box.     var myresult = mydialog.show() ;     if (myresult == true) {         //get values dialog box controls         var ascenderheight = ascenderheightfield;         var xheightmm = xheightmmfield;         var descenderheight = descenderheightfield;         var slantangle = slantanglefield;         //remove dialog box memory.         mydialog.destroy();         buildguide (ascenderheight, xheightmm, descenderheight, slantangle);         }     else{         mydialog.destroy() ;         }            function buildguide (ascenderheight, xheightmm, descenderheight, slantangle) {      var ascenderheight = parseint(ascenderheight);   var lineheight = (descenderheight+xheightmm+ascenderheight);   //create lines guide, specified distance apart on margin of 13mm (set in variables once maths working!)   var capheight = app.activewindow.activepage.graphiclines.add() ; capheight.geometricbounds = [13, 13, 13, 197] ; capheight.strokeweight = 2 ;   var xheight = app.activewindow.activepage.graphiclines.add() ; xheight.geometricbounds = [(13+ ascenderheight), 13, (13+ ascenderheight), 197] ; xheight.strokeweight = 1.5 ;   var baseline = app.activewindow.activepage.graphiclines.add() ; baseline.geometricbounds = [(13+ +ascenderheight+ xheightmm), 13, (13+ascenderheight+xheightmm), 197] ; baseline.strokeweight = 2 ;   var descender = app.activewindow.activepage.graphiclines.add() ; descender.geometricbounds = [(13+lineheight), 13, (13+lineheight), 197] ; descender.strokeweight = 1.5 ;    /*app.activedocument.distribute( app.activewindow.activespread.pageitems.everyitem().getelements(), distributeoptions.vertical_space, undefined, true, xheightmm);*/    //create x mark baseline , diagonal @ specified slant var linemarker = app.activewindow.activepage.textframes.add() ; linemarker.geometricbounds = [(13+ascenderheight), 13,(13+lineheight),17] ; linemarker.contents = "x" ;   var diagonal = app.activewindow.activepage.graphiclines.add() ; diagonal.geometricbounds = [13, 30, (13+lineheight+2), 30] ; diagonal.strokeweight = 1.5 ; diagonal.absoluterotationangle = slantangle ;   //group created duplicate down length of page var mygroup = new array () ; mygroup.push(capheight) ; mygroup.push(xheight) ; mygroup.push(baseline) ; mygroup.push(descender) ; mygroup.push(linemarker) ; mygroup.push(diagonal) ; var mylinegroup = app.activewindow.activepage.groups.add(mygroup);   var mygroup2 = mylinegroup.duplicate(undefined,[0,lineheight+2]);   (var = lineheight+2; < (271-lineheight); i=i+lineheight+2){     var dup_groups = app.activewindow.activepage.groups.lastitem().duplicate(undefined, [0,i]) ;     } ;    } ; 

without getting entirety of script, let's @ dialog box:

take code dialog box , copy separate script.

now instead of calling build guide, replace line test see values of variables:

[ascenderheight, xheightmm, descenderheight, slantangle];

when run script, see problem is: result is:

result: [object integereditbox],[object integereditbox],[object integereditbox],[object angleeditbox]

you getting reference dialog box widgets, not edit value.

add .editvalue each of variable definitions read:

        var ascenderheight = ascenderheightfield.editvalue; 

        var xheightmm = xheightmmfield.editvalue; 

        var descenderheight = descenderheightfield.editvalue; 

        var slantangle = slantanglefield.editvalue;

this should solve problem.

bottom line: when having problems, isolate code , evaluate results.

hope helps.



More discussions in InDesign Scripting


adobe

Comments

Popular posts from this blog

Soustraire une selection

After Effects: could not find dvaeve_dialogs.txt

Illustrator cs6 "Invalid Serial Number"