OpenFileRequester()

Syntax

Filename$ = OpenFileRequester(Pattern$, Callback [, Flags])
Description
Opens the standard requester for the user to choose one or several local files. For security reason, the requester can be opened only from an event callback triggered by a real user action (ie: when the user click on a gadget). This commands needs to be put in an event procedure, like in the example below. The selected file is get with NextSelectedFile() and SelectedFileName() in the callback.

Parameters

Pattern$ A standard filter which allow to display only the files which end with such or such extension. It has to be in the MIME form : "image/*", "audio/*" etc. A list of most common MIME types can be found here: http:://www.freeformatter.com.
Callback The callback to be called if the user has selected one or several file. It won't be called if the user canceled the requester. It has to use the following syntax:
  Procedure Callback()
    ; Code here
  EndProcedure
Flags (optional) It can be a combination of one of the following values:
  #PB_Requester_MultiSelection: Enable the multiselection (see NextSelectedFile()).

Return value

None.

Example

  Procedure RequesterSuccess()
    
    ; Process all the selected filename
    ;
    While NextSelectedFile()
      Debug "Filename: " + SelectedFileName()
    Wend
  EndProcedure
  
  Procedure ButtonEvent()
    OpenFileRequester("", @RequesterSuccess(), #PB_Requester_MultiSelection)
  EndProcedure
    
  If OpenWindow(0, 100, 100, 200, 55, "File")
    ButtonGadget(0, 10, 10, 170, 25, "Open local file...")
    BindGadgetEvent(0, @ButtonEvent())
  EndIf

See Also

NextSelectedFile()

Supported OS

All

<- NextSelectedFile() - Requester Index - SelectedFileID() ->