Skip to main content
Known Participant
October 20, 2010
Answered

Need fullpath for selected file in editbox

  • October 20, 2010
  • 2 replies
  • 556 views

Hi All,

I've created below script. It is working fine.

Here is my question:

When I select my folder my edit box show my selected folder full path.

Please help me.

Thanks in advance.

var myDialog = new Window('dialog',);

myDialog.myPanel4 = myDialog.add('panel');

          myDialog.myPanel4.helpTip = "Choose text file";

          myDialog.myPanel4.Group15 = myDialog.myPanel4.add('group',undefined);

          myDialog.myPanel4.Group15.EditText5 = myDialog.myPanel4.Group15.add('edittext',undefined,"/mytextfile");

          myDialog.myPanel4.Group15.EditText5.preferredSize.width = 400;

          myDialog.myPanel4.Group15.Button5 = myDialog.myPanel4.Group15.add('button',undefined,"Select");

myDialog.myPanel4.Group15.Button5.onClick = function ()

{

Folder.selectDialog ("Choose my text file");

var myfilePath

myfilePath=Folder.selectDialog

}

myDialog.show()

This topic has been closed for replies.
Correct answer tomaxxi

OK, I changed it little bit

var myDialog = new Window('dialog', 'Choose text file');
var myPanel = myDialog.add('panel');
var myTextField = myPanel.add('edittext',undefined,"/mytextfile");
var myBrowse = myPanel.add('button',undefined,"Select...");

myPanel.orientation = 'row';
myPanel.helpTip = "Choose text file";
myTextField.preferredSize = [400,20];

myBrowse.onClick = function (){
    var myfilePath = Folder.selectDialog();
    if(myfilePath != null)myTextField.text = myfilePath.fsName;
}

myDialog.center();

myDialog.show();

Hope that helps.

--

tomaxxi

http://indisnip.wordpress.com/

2 replies

tomaxxi
tomaxxiCorrect answer
Inspiring
October 20, 2010

OK, I changed it little bit

var myDialog = new Window('dialog', 'Choose text file');
var myPanel = myDialog.add('panel');
var myTextField = myPanel.add('edittext',undefined,"/mytextfile");
var myBrowse = myPanel.add('button',undefined,"Select...");

myPanel.orientation = 'row';
myPanel.helpTip = "Choose text file";
myTextField.preferredSize = [400,20];

myBrowse.onClick = function (){
    var myfilePath = Folder.selectDialog();
    if(myfilePath != null)myTextField.text = myfilePath.fsName;
}

myDialog.center();

myDialog.show();

Hope that helps.

--

tomaxxi

http://indisnip.wordpress.com/

tansk02Author
Known Participant
October 21, 2010

Hi Tomaxxi,

Thanx a ton for your correct answer and advice.

you are such a great & talented guy.

tomaxxi
Inspiring
October 20, 2010

Hey!

Try this:

var myDialog = new Window('dialog',);
myDialog.myPanel4 = myDialog.add('panel');
          myDialog.myPanel4.helpTip = "Choose text file";
          myDialog.myPanel4.Group15 = myDialog.myPanel4.add('group',undefined);
          myDialog.myPanel4.Group15.EditText5 = myDialog.myPanel4.Group15.add('edittext',undefined,"/mytextfile");
          myDialog.myPanel4.Group15.EditText5.preferredSize.width = 400;
          myDialog.myPanel4.Group15.Button5 = myDialog.myPanel4.Group15.add('button',undefined,"Select");
myDialog.myPanel4.Group15.Button5.onClick = function ()
{
    var myfilePath = Folder.selectDialog();
    if(myfilePath != null)myDialog.myPanel4.Group15.EditText5.text = myfilePath.fsName;
}
myDialog.show();

Also, I suggest you to rewrite your script, it's really messy!

Hope that helps.

--

tomaxxi

http://indisnip.wordpress.com/