table rename ... headers

Prev Next

Function Names

table rename headers, table rename column headers, table rename existing headers

Description

This function renames specified table headers. Whereas table rename column headers asserts exceptions if headers are not found, the table rename existing headers will simply ignore the headers not found.

Note: Every table header will be renamed only once.

The function name table rename column headers is declared obsolete and will be replaced by the new name table rename headers in order to make the naming more consistent.

Call as: procedure or function

Restrictions

Indirect parameter passing is disabled

Parameter count

3

Parameters

No.TypeDescription
1
input
string Name of existing table

2
input
table columns Existing header name(s) or column number(s)

See table columns as function parameters for general ruling for this parameter.
Specific rules apply for this function:

  • Any number of header names and column numbers may be specified

3
input
set or string New header name(s)

List the new header names corresponding to the existing ones specified in the previous function parameter.
Use string to specify a single table, or a set or softquoted string (single quotation marks) with names separated by comma to specify multiple columns.

Return value

TypeDescription
numeral Number of renamings done

Exceptions

Table not found
Header name not found
number of existing and new headers is inconsistent

Examples

       table initialize ( table, { { First Name, Last Name, Phone No, Age }, { Archer, Jim, "1-212-555-1212", 28 } } );

       count[] = table rename existing headers( table, { Last Name, First Name, Family Name }, {First Name, Last Name, Other Name} );

       table list ( table );
       echo;
       echo("Number of headers renamed: ", count[]);

       echo( new line, "This example demonstrates that each "First Name" column is touched only once.", new line );
       table initialize ( table,       { { First Name, First Name, Phone No, Age }, { Tanner, Lisa, "1-212-555-1212", 28 } } );
       table rename headers( table,  { First Name, First Name }, { Last Name, Given Name } );
       table list ( table );

Output

    0 : Last Name | First Name | Phone No       | Age
    1 : Archer    | Jim        | 1-212-555-1212 | 28


Number of headers renamed: 2

This example demonstrates that each "First Name" column is touched only once.

    0 : Last Name | Given Name | Phone No       | Age
    1 : Tanner    | Lisa       | 1-212-555-1212 | 28

Try it yourself: Open LIB_Function_table_rename_headers.b4p in B4P_Examples.zip. Decompress before use.

See also

table correct headers
table check headers