2 Replies Latest reply on May 22, 2014 9:47 PM by CarlosCanto

    How to change variable type

    neil leep

      Hi I am starting to write a script to draw an image with different dimensions that I can input.

      so Here is what I have so far:


      // Create Window
      var StartingPointWindow = new Window ("dialog", "Form");
      // Add text: "Starting Point X:" to window
      StartingPointWindow.add ("statictext", undefined, "Start Point X:");
      var inputX=0;
      //Add edit text box 
      var StartPointX = StartingPointWindow.add ("edittext", undefined, inputX);
      // Ready to enter text
      StartPointX.active = true;
      // Maximm charicters 5
      StartPointX.characters = 5;
      // add OK and Cancel button
      StartingPointWindow .add ("button", undefined, "ok");
      StartingPointWindow .add ("button", undefined, "Cancel");
      if (StartingPointWindow.show () == 1)
          inputX= StartPointX.contents;
       //   inputX.append (String.to Number)
         var docRef = documents.add();
         var piRef = activeDocument.pathItems;
         var pathRef = piRef.add();
      //Draw line from points (X,Y) to (X,Y)
        pathRef.setEntirePath( new Array(
        new Array((inputX), (200)),
        new Array((400), (500)) ) ) ;
      //PresrtPointX changes
      StartingPointWindow.close( StartPointX.DONOTSAVECHANGES );


      So this my starting point for some testing but the problem I seem to have is that it wont accept the inputX variable on line 48 - I think this because the edittext is saving the input number as a string? I may be wrong so any help would be appreciated.

      Many Thanks