OpenFileDialogBox

From GECK
Jump to: navigation, search


A function added by the SUP NVSE Plugin.

Description

Opens native Windows "Choose file" dialog box and returns a filepath to a file which user has chosen.

Syntax

[help]
(FilePath:string) OpenFileDialogBox UDF:script File extension:string

Example

OpenFileDialogBox MyUDF

Will open a new file choose dialog box and will call MyUDF when user has chosen the file.

OpenFileDialogBox MyUDF "txt"

Will open a new file choose dialog box(user can only choose "txt" files) and will call MyUDF when user has chosen the file.

Handler Script

A skeleton handler script for this event:

Scriptname MyUDF

int iSuccess
string_var sv_FilePath


begin function {iSuccess,sv_FilePath}
	Print "Success is " + $iSuccess

        if iSuccess == 1 ; iSuccess will retirn 0 if file is not chosen by user.
          Print "File Path is " + $sv_FilePath
        endif

end


Notes

  • Works only on Windows Vista+ systems(Windows Vista,Windows7,Windows8, Windows10, Windows11). Doesn't work on Windows XP. You can check Windows version with GetPCTrait.
  • During Windows choose file dialog box game execution is halted.
  • Some filepath symbols might not be supported, for instance, English version of Fallout:New Vegas will not display cyrillic symbols.
  • Any form ID can be specified instead of script for testing purposes;
  • When using string result, keep in mind that it's returning case-sensitive file path(while GetFalloutDirectory returns case-insensitive path). Thus you need to use case insensitive string search if you want to check if chosen file contains file directory to remove path from string output later.

See Also