GetFileOpen


The GetFileOpen function uses the Windows Open dialog to browse for a file name string but does not open the file. The Open dialog's behavior can be modified by passing parameters from a FileNameParams table.

To override the default properties of this function, you do not have to create a FileNameParams table or specify all parameters. Simply create a table and set the values using the exact names used in the FileNameParams table.

Syntax

sName, FileNameParams_New = GetFileOpen( tblParams )

sName, FileNameParams_New = GetFileOpen()

sName = GetFileOpen( tblParams )

sName = GetFileOpen()

bullet.gif    tblParams is an optional table containing values from the FileNameParams table. If omitted, the internal default FileNameParams values are used.

bullet.gif    FileNameParams_New is a FileNameParams table containing updated values from the Open dialog. You do not have to catch or use this returned table.

bullet.gif    sName is the full path name of the selected file.

bullet.gif    If the [Open] button is clicked, sName and FileNameParams_New are returned.

bullet.gif    If the dialog was closed using [Cancel] or [X], nil, nil is returned.

Examples

The scripts below show the use of GetFileOpen with and without overriding the FileNameParams values.

sName = GetFileOpen()

-- use the default GetFileOpen dialog

if sName then Printf("name=%s\n",sName) end

-- exit the script if sName is nil

 

 

Params =

-- setup a table with FileNameParams overrides

{

-- (use a comma after each value)

  sOpenTitle = "Open the Source File",

-- the new title for the Open dialog

}

 

str = GetFileOpen(Params)

-- use GetFileSave with new properties

 

 

Params =

-- setup a FileNameParams table

{

-- (use a comma after each value)

  sOpenTitle = "Open the Source File",

-- the new title for the Open dialog

}

 

str, NewParams = GetFileOpen(Params)

-- use GetFileOpen and use the returned properties

if str ~= nil then

-- check that valid results are returned

  Printf("Ext=%s\n", NewParams.sFileExt)

-- list the new file extension

end

 

Related Topics

Dialog Functions

Directory Functions

new_fileopen

GetFileSave

FileNameParams

GetString

SetFlipFITS

GetFolder


Mira Pro x64 Script User's Guide, v.8.77 Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.