' Purpose: Demonstrate the FileSaveAsDlg() function
'Includes
Include "mapbasic.def"
'Declares
Declare Sub Main()
Declare Sub WorkWithCopyOfTable(ByVal sTarget As String)
Define DEF_TABLE_TO_COPY "STATES"
Define DEF_NEW_TABLE_NAME "STATES_NEW"
' Procedure: Main()
' Purpose: Main Control
Sub Main ()
Dim sNewTable As String
' Make sure the table to be copied exists.
If (FileExists(DEF_TABLE_TO_COPY + ".tab")) Then
' Use FileOpenDlg() to get file path.
' You will use this path to save a copy of the table later.
sNewTable = FileSaveAsDlg(ApplicationDirectory$(),
DEF_NEW_TABLE_NAME + ".tab",
"TAB",
"Make copy of " + DEF_TABLE_TO_COPY + ":")
' Verify that user did not click CANCEL.
If (sNewTable <> "" ) Then
Open Table DEF_TABLE_TO_COPY
' Save old table under a new name and path.
Commit Table DEF_TABLE_TO_COPY As sNewTable
Close Table DEF_TABLE_TO_COPY
' Call routine to process only the copy.
Call WorkWithCopyOfTable(sNewTable)
Else
' User clicked Cancel.
Note "No name chosen for copy. Exiting program."
End If
Else
' The call to FileExists() returned False.
Note "Table to be copied does not exist."
End If
End Sub
' Procedure: WorkWithCopyOfTable()
' Purpose: Carry out tasks on table
Sub WorkWithCopyOfTable(ByVal sTargetTable As String)
' Work with copied table here.
If (sTargetTable <> "") Then
Open Table sTargetTable
' Use the TableInfo() function to obtain the tablename
sTargetTable = TableInfo(0, TAB_INFO_NAME)
Map From sTargetTable ' Open a map window
Browse * From sTargetTable ' Open a browser
Else
Note "No Table Found"
End Program
End If
End Sub