PathToTableName$() function - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

Purpose

Returns a string representing a table alias (such as "_2013_Data") from a complete file specification (such as "C:\MapInfo\Data\2013 Data.tab"). You can call this function from the MapBasic window in MapInfo Pro.

Syntax

PathToTableName$( filespec ) 

filespec is a string expression representing a full file specification.

Return Value

String, up to 31 characters long.

Description

Given a full file name that identifies a table's .TAB file, this function returns a string that represents the table's alias. The alias is the name by which a table appears in the MapInfo Pro user interface (for example, on the title bar of a Browser window).

To convert a file name to a table alias, MapInfo Pro removes the directory path from the beginning of the string and removes ".TAB" from the end of the string. Any special characters (for example, spaces or punctuation marks) are replaced with the underscore character (_). If the table name starts with a number, MapInfo Pro inserts an underscore at the beginning of the alias (this increases the number of characters by 1, so if the table name is 30 characters adding an underscore makes it 31 characters in length). If the resulting string is longer than 31 characters, MapInfo Pro trims characters from the end; aliases cannot be longer than 31 characters.

Note that a table may sometimes be open under an alias that differs from its default alias. For example, the following Open Table statement uses the optional As clause to force the World table to use the alias "Earth":

Open Table "C:\MapInfo\Data\World.tab" As Earth 

Furthermore, if the user opens two tables that have identical names but different directory locations, MapInfo Pro assigns the second table a different alias, so that both tables can be open at once. In either of these situations, the "default alias" returned by PathToTableName$() might not match the alias under which the table is currently open. To determine the alias under which a table was actually opened, call the TableInfo() function with the TAB_INFO_NAME code.

Example

Dim s_filespec, s_tablename As String 
s_filespec = "C:\MAPINFO\DATA\STATES.TAB" 
s_tablename = PathToTableName$(s_filespec) 
' s_tablename now contains the string "STATES" 

See Also:

PathToDirectory$() function, PathToFileName$() function, TableInfo() function