Using 'FileBrowse' feature in DIALOG

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
jwobrien2
Newbie
Posts: 4
Joined: Sat Dec 12, 2009 9:58 pm

Using 'FileBrowse' feature in DIALOG

Post by jwobrien2 » Tue Jul 27, 2010 9:29 pm

Within a script I would like to be able to allow the user to 'navigate' to any particular file somewhere on a disk in the system.

I am trying to use 'FileBrowse' in a DIALOG, and am having only marginal success.
I am UNABLE to get the 'initialdir' and/or 'filename' default parameters to work, so when 'FileBrowse' opens, it always does so in the home directory that the script is running in!

Also, would like to specify it to ONLY display files of type *.xml, but cannot get that parameter of this object to work either!

Can you give me an example of how to use the 'FileBrowse' object in DIALOG? (or is there a different/better way to capture the user's desire for a location and filename to get to?
John
helpJOB

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

Post by JRL » Tue Jul 27, 2010 10:36 pm

A pre-version12 sample

Code: Select all

Dialog>Dialog1
   Caption=Filebrowse Sample
   Width=717
   Height=200
   Top=10
   Left=CENTER
   Edit=FileLocation,104,48,513,
   Button=Browse,624,50,65,20,0
   Filebrowse=Browse,FileLocation,All|*.txt,open,
EndDialog>Dialog1

Show>Dialog1
Let>Dialog1.FileLocation.fbinit=C:\
ResetDialogAction>Dialog1
Label>Loop
  GetDialogAction>Dialog1,res1
  If>res1=2
    Exit>0
  EndIf
  Wait>0.01
Goto>Loop
For Version 12 (or later) from the "Dialogs - File Browse Example" provided with the software

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 469
  Top = 146
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'File Browse Example'
  ClientHeight = 288
  ClientWidth = 308
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  Position = poDesigned
  ShowHint = True
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 16
    Top = 16
    Width = 53
    Height = 13
    Caption = 'Enter a file:'
  end
  object Edit1: TEdit
    Left = 16
    Top = 41
    Width = 248
    Height = 21
    TabOrder = 8
  end
  object MSButton1: tMSButton
    Left = 269
    Top = 41
    Width = 21
    Height = 21
    DoubleBuffered = True
    Glyph.Data = {
      F6000000424DF600000000000000760000002800000010000000100000000100
      0400000000008000000000000000000000001000000010000000000000000000
      80000080000000808000800000008000800080800000C0C0C000808080000000
      FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00777777777777
      77777777777777777777000000000007777700333333333077770B0333333333
      07770FB03333333330770BFB0333333333070FBFB000000000000BFBFBFBFB07
      77770FBFBFBFBF0777770BFB0000000777777000777777770007777777777777
      7007777777770777070777777777700077777777777777777777}
    ParentDoubleBuffered = False
    TabOrder = 9
    BitmapFile =
      'C:\Documents and Settings\Marcus\My Documents\RAD Studio\Project' +
      's\msched_work\open.bmp'
    DoBrowse = False
    Filter = 'Text files (*.txt)|*.TXT|Any file (*.*)|*.*'
    BrowseStyle = fbOpen
  end
  object MSMemo1: tMSMemo
    Left = 16
    Top = 72
    Width = 273
    Height = 161
    ScrollBars = ssBoth
    TabOrder = 10
  end
  object MSButton2: tMSButton
    Left = 215
    Top = 247
    Width = 75
    Height = 25
    Caption = 'Close'
    DoubleBuffered = True
    ModalResult = 2
    ParentDoubleBuffered = False
    TabOrder = 11
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,MSButton1,OnClick,DoBrowse

Show>Dialog1,r

SRT>DoBrowse
  SetDialogProperty>Dialog1,MSButton1,DoBrowse,True
  GetDialogProperty>Dialog1,MSButton1,Filename,strFileName
  SetDialogProperty>Dialog1,Edit1,Text,strFileName
  ReadFile>strFileName,strFileData
  SetDialogProperty>Dialog1,MSMemo1,Text,strFileData
END>DoBrowse

jwobrien2
Newbie
Posts: 4
Joined: Sat Dec 12, 2009 9:58 pm

Help with 'FileBrowse' feature in DIALOG

Post by jwobrien2 » Thu Jul 29, 2010 3:04 pm

'JRL'...
Thanks for your prompt response to my questions... I appreciate your help (and the samples)!
John
helpJOB

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