Restoring a path for Browse Button

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Restoring a path for Browse Button

Post by Phil Pendlebury » Fri Feb 05, 2010 10:02 pm

Here's an interesting one:

In my FTP script here: http://www.mjtnet.com/forum/viewtopic.php?p=26385#26385

There is a small section that writes the path chosen by a Macro Scheduler Browse (open) command to my ini file.

When next starting the path is loaded from the ini file into the browse edit area.

There are different sections in the ini file for each FTP site and the idea was that the application would start up in the same directory that you left off - different for each FTP site, as stored in the ini file.

However - although the path is loaded into the edit area and all the correct variables seem to be set, when you hit "Browse" it simply browses to teh last location you were at, ignoring the path that is in the browse dialog.

Hmm...

So I tried a last ditch attempt to get it working by copying the path to clipboard and waiting for the window "Open" to open and then pasting the path into the Open dialog. Unfortunately even that won;t work as "open" window is not recognised.

So can anyone think of a way round this?

I also found another issue which I will post separately.

Cheers everyone,

Phil.
Phil Pendlebury - Linktree

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Sat Feb 06, 2010 6:37 am

From Help for Dialog FileBrowse:
ButtonObjectName,TextObjectName[,mask[,open|save|dir[,initialdir[,filename]]]]

Therefore your filebrowse line would look something like:

FileBrowse=Browse,msEdit6,,open,%def_folder%

Though I'm not sure I've stuck in the correct variable for the path you want.

User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Sat Feb 06, 2010 2:17 pm

Thanks JRL that I think, is pretty much it I think.

No need to add you to credits as you are already there.

:-)
Phil Pendlebury - Linktree

User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Sat Feb 06, 2010 2:41 pm

OK. I just realised that is exactly what I had originally.

If you have time, give this a try:

Make a small dialog with a browse button.

Then do something like this.

FileBrowse=Browse,msEdit6,,open,yourpathvariable,thisfile.jpg

With a way of changing the "yourpathvariable" when loading the dialog.

On my system there is nothing entered into the file browser edit box unless I put the variable as the default value of the edit box too. AND when the "Open" window is opened it always browses back to the last path browsed not the path stored in the variable. But the filename thisfile.jpg has been entered.

Does that make sense?
Phil Pendlebury - Linktree

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Sun Feb 07, 2010 12:09 am

Hi Phil,

I think what you're looking for is found in Dialog FileBrowse Help.
initialdir and filename allow the browse box to default to a directory and/or filename. To set initialdir and/or filename at run time set DialogName.TextObjectName.fbinit=initialdir,filename
Here's a sample demonstrating. remark out the Let>Dialog1.msEdit1.fbinit=%item_1% line and FileBrowse will always default to the c:\ root. Leave the line unremarked and FileBrowse will default to the last folder visited. You must pick the "Ok" button after browsing to reset all the variables.

Hope this helps.

Code: Select all

Dialog>Dialog1
   Caption=Browse Sample
   Width=442
   Height=140
   Top=165
   Left=48
   Edit=msEdit1,38,41,267,
   Button=Browse,315,39,75,25,0
   Button=Ok,132,80,75,25,3
   FileBrowse=Browse,msEdit1,,open,c:\
EndDialog>Dialog1

Show>Dialog1

Label>Loop
  GetDialogAction>Dialog1,res1
  If>res1=2
    Exit>0
  EndIf
  If>Res1=3
    GoSub>Process
  EndIf
goto>Loop

SRT>Process
    MDL>Dialog1.msEdit1
    //I'm sure Bob can write a RegEx to replace most of the following block.
    ////////////////////////////////////////////////////////////////////////
    Separate>Dialog1.msEdit1,\,item
    Let>kk=1
    Repeat>kk
      Add>kk,1
      Let>value=item_%kk%
      Concat>item_1,\%value%
    Until>%kk%={(%item_count%-1)}
    //This is the line that resets the file browse default.
    Let>Dialog1.msEdit1.fbinit=%item_1%
    /////////////////////////////////////////////////////////////////////////
    ResetDialogAction>Dialog1
END>Process

User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Sun Feb 07, 2010 4:32 pm

Hi JRL,

Using your simple example I can demonstrate my problem easily.

Take this script:

Code: Select all

Let>path=d:/

Dialog>Dialog1
   Caption=Browse Sample
   Width=442
   Height=140
   Top=165
   Left=48
   Edit=msEdit1,38,41,267,
   Button=Browse,315,39,75,25,0
   Button=Ok,132,80,75,25,3
   FileBrowse=Browse,msEdit1,,open,%path%
EndDialog>Dialog1

Show>Dialog1

Label>Loop
  GetDialogAction>Dialog1,res1
  If>res1=2
    Exit>0
  EndIf
  If>Res1=3
    GoSub>Process
  EndIf
goto>Loop
Notice that whatever value you set path to (in the first line) is ignored, it always opens to the last place you have browsed to.

If you actually put the path in there instead of "%path%" for example:

Code: Select all

FileBrowse=Browse,msEdit1,,open,d:/
Then it seems to work.

Please try it and see.

Howvere, adding:

Code: Select all

SRT>Process
Let>Dialog1.msEdit1.fbinit=%path%
rda>Dialog1
END>Process
Seems to work so I will give that a go.

:)
Phil Pendlebury - Linktree

User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Sun Feb 07, 2010 4:47 pm

Ok fixed it with this:

/////////////////////////////////////////
IF>fromsendto=False
Let>FTPDialog.msEdit6.fbinit=%def_file%
rda>FTPDialog
ENDIF
/////////////////////////////////////////

See the FTP script.

Thanks again. Still not sure why the initial idea didn't work before adding fbinit (see above).

:-)
Phil Pendlebury - Linktree

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts