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()).
  #PB_Requester_GoogleDrive: Uses the Google file requester to select a file. UseGoogleDrive() has to be
                             successfully initialized before using this requester. Note: to be able to open
                             the requester, a domain name needs to be used (ip address won't work), and this domain
                             needs to be allowed in the google developper console. For testing purpose,
                             you can modify your /etc/hosts file and put a domain alias for 127.0.0.1, and
                             then set the 'web server address' compiler option of the SpiderBasic IDE.
                             

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() ->