Programmer Guide/Command Reference/NAME: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{Command Reference}}
== Syntax check/improvement ==
== Syntax check/improvement ==
  NAME <var>string</var> [ <var>type</var>|* [ <var>correct</var> ]]
  NAME <var>string</var> [ <var>type</var>|* [ <var>correct</var> ]]
Line 13: Line 14:
:The type of name to check for syntactic correctness. The following values are supported:
:The type of name to check for syntactic correctness. The following values are supported:
:<code>ITEM</code> - string should be a syntactically correct shell item name.
:<code>ITEM</code> - string should be a syntactically correct shell item name.
:<code>SEGMENT</code> - string should be a syntactically correct segment name.
:<code>SEGMENT</code> - string should be a syntactically correct segment name. See [[User_Guide/Project/Segment#Segment_Name_Restrictions|Segment Name Restrictions]] for details.
:<code>TABLEFIELD</code> - string should be a syntactically correct table field name.
:<code>TABLEFIELD</code> - string should be a syntactically correct table field name.
:<code>XMLATTRIBUTE</code> - string should be a syntactically correct XML attribute. Note that since XML attributes are used in {{STX}} in, e.g., tables, this function also checks that are valid {{STX}} identifiers and is hence more restrictive than the XML specification.
:<code>XMLATTRIBUTE</code> - string should be a syntactically correct XML attribute. Note that since XML attributes are used in {{STX}} in, e.g., tables, this function also checks that are valid {{STX}} identifiers and is hence more restrictive than the XML specification.
Line 34: Line 35:
  NAME <var>filepath</var> UNC [ <var>copy</var> ]
  NAME <var>filepath</var> UNC [ <var>copy</var> ]


If <var>filepath</var> points to a file on a mapped network drive, then the UNC (Uniform Naming Convention) file path to this file is returned. If <var>filepath</var> does not exist, is not a file, or is not on a mapped network drive, an empty string is returned. E.g.:
If <var>filepath</var> points to a file on a mapped network drive, then the UNC (Uniform Naming Convention) file path to this file is returned. If <var>filepath</var> does not exist, is not a file, or is not on a mapped network drive, an empty string is returned.


;<var>copy</var>
;<var>copy</var>
:If copy is set to 1, and there is no corresponding UNC file path for <var>filepath</var>, then <var>filepath</var> is returned.
:If copy is set to 1, and there is no corresponding UNC file path for <var>filepath</var>, then <var>filepath</var> is returned.
:If copy is set to <code>0</code>, and there is no corresponding UNC file path for <var>filepath</var>, an empty string is returned.
:If copy is set to <code>0</code>, and there is no corresponding UNC file path for <var>filepath</var>, an empty string is returned.


<pre>
<pre>
<code>// if the z drive is mapped to \\server1\data, then '\\server1\data\ds.xml' is returned</code>
// if the z drive is mapped to \\server1\data, then '\\server1\data\ds.xml' is returned
<code>#uncfilename := name 'z:\ds.xml' unc</code>
#uncfilename := name 'z:\ds.xml' unc
<code>// if the z drive is *not* mapped to \\server1\data, then an empty string is returned</code>
// if the z drive is *not* mapped to \\server1\data, then an empty string is returned
<code>#uncfilename := name 'z:\ds.xml' unc</code>
#uncfilename := name 'z:\ds.xml' unc
<code>// if the z drive is *not* mapped to \\server1\data, then 'z:\ds.xml' is returned</code>
// if the z drive is *not* mapped to \\server1\data, then 'z:\ds.xml' is returned
<code>#uncfilename := name 'z:\ds.xml' unc 1</code>
#uncfilename := name 'z:\ds.xml' unc 1
</pre>
</pre>

Latest revision as of 17:30, 30 August 2016

Syntax check/improvement

NAME string [ type|* [ correct ]]

Check the syntactical validity of the name string. If correct is set to 1, the command returns the name string with any invalid characters replaced by valid ones. If correct is set to 0, the command returns the name string if it is valid and an empty string if the name string is invalid.

string
The string to check for validity.
type
The type of name to check for syntactic correctness. The following values are supported:
ITEM - string should be a syntactically correct shell item name.
SEGMENT - string should be a syntactically correct segment name. See Segment Name Restrictions for details.
TABLEFIELD - string should be a syntactically correct table field name.
XMLATTRIBUTE - string should be a syntactically correct XML attribute. Note that since XML attributes are used in STx in, e.g., tables, this function also checks that are valid STx identifiers and is hence more restrictive than the XML specification.
XMLID - should be a string which conforms to the STx doctype specification for an ID attribute value.
The default is ITEM (if an asterisk is specified or the parameter is missing).
correct
1 if invalid characters should be replaced by valid characters (if string is not empty, a valid name is always returned) or 0 if an empty string should be returned if invalid characters are found.
The default is 0.
// correct the segment name $#name
#name := set $(NAME $#name segment 1)

UNC Path

NAME filepath UNC [ copy ]

If filepath points to a file on a mapped network drive, then the UNC (Uniform Naming Convention) file path to this file is returned. If filepath does not exist, is not a file, or is not on a mapped network drive, an empty string is returned.

copy
If copy is set to 1, and there is no corresponding UNC file path for filepath, then filepath is returned.
If copy is set to 0, and there is no corresponding UNC file path for filepath, an empty string is returned.
// if the z drive is mapped to \\server1\data, then '\\server1\data\ds.xml' is returned
#uncfilename := name 'z:\ds.xml' unc
// if the z drive is *not* mapped to \\server1\data, then an empty string is returned
#uncfilename := name 'z:\ds.xml' unc
// if the z drive is *not* mapped to \\server1\data, then 'z:\ds.xml' is returned
#uncfilename := name 'z:\ds.xml' unc 1

Navigation menu

Personal tools