1 Reply Latest reply on Oct 3, 2013 7:00 PM by pixxxel schubser

    how to get user input via prompt

    hilukasz Level 1

      I have this working without the prompt, if I under manually the margin via var margin = 10; it works. it also seems to return correctly when I print what the input from the user is, but it doesnt seem to want to work and freezes any idea what I am doing wrong?


      it says "point value expected"


      //Helper functions
      function print(i) {
          if(i == "object"){ 
              print("you are trying to printObject, use printObj(); function"); 
          else {  
      // Program
      app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
      var doc = app.activeDocument;
      var selected = doc.selection;
      //print(selection[0].height+", "+selection[0].position);
      var selectedHeight = selected[0].height;
      print("selectedHeigh: "+selectedHeight);
      var selectedPosition = selected.position;
      var newItem = selected[0].duplicate( doc, ElementPlacement.PLACEATEND );
      print("newitem position: "+newItem.position);
      var margin = prompt('enter margin','10');
      print("margin prompt: "+margin);
      var newHeight = selectedHeight + newItem.position[1]+margin;
      print("newHeight: "+newHeight);
      newItem.position = [newItem.position[0], newHeight];