25.01.2015 Views

Using Caché ObjectScript - InterSystems Documentation

Using Caché ObjectScript - InterSystems Documentation

Using Caché ObjectScript - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Syntax Rules<br />

In an explicit namespace name, the first character must be a letter or a percent sign (%). The remaining characters must be<br />

letters, numbers, hyphens (–), or underscores (_). The name cannot be longer than 255 characters.<br />

When <strong>Caché</strong> translates an explicit namespace name to a routine or class name (for example, when creating a cached query<br />

class/routine name), it replaces punctuation characters with lowercase letters, as follows: % = p, _ = u, – = d. An implied<br />

namespace name may contain other punctuation characters; when translating an implied namespace name, these punctuation<br />

characters are replaced by a lowercase "s". Thus the following seven punctuation characters are replaced as follows: @ =<br />

s, : = s, / = s, \ = s, [ = s, ] = s, ^ = s.<br />

When using <strong>Caché</strong> MultiValue, each MultiValue account is mapped to a <strong>Caché</strong> namespace. The naming conventions for<br />

MultiValue accounts and <strong>Caché</strong> namespaces differ. For details about how MultiValue account names are translated to<br />

namespace names, refer to the CREATE.ACCOUNT command in the <strong>Caché</strong> MultiValue Commands Reference.<br />

For information on using namespaces, see Namespaces and Databases in the <strong>Caché</strong> Programming Orientation Guide. For<br />

information on creating namespaces, see Configuring Namespaces in the <strong>Caché</strong> System Administration Guide.<br />

2.8.1 Extended References<br />

An extended reference is a reference to an entity that is located in another namespace. The namespace name can be specified<br />

as a string literal enclosed in quotes, as a variable that resolves to a namespace name, as an implied namespace name, or<br />

as a null string ("") a placeholder that specifies the current namespace. There are three types of extended references:<br />

• Extended Global Reference: references a global variable in another namespace. The following syntactic forms are<br />

supported: ^["namespace"]global and ^|"namespace"|global. For further details, refer to Global Variables<br />

section of the “Variables” chapter of this manual.<br />

• Extended Routine Reference: references a routine in another namespace.<br />

– The DO command, the $TEXT function, and user-defined functions support the following syntactic form:<br />

|"namespace"|routine.<br />

– The JOB command supports the following syntactic forms: routine|"namespace"|,<br />

routine["namespace"], or routine:"namespace".<br />

In all these cases, the extended routine reference is prefaced by a ^ (caret) character to indicate that the specified entity<br />

is a routine (rather than a label or an offset). This caret is not part of the routine name. For example, DO<br />

^|"SAMPLES"|fibonacci invokes the routine named fibonacci, which is located in the SAMPLES namespace.<br />

The command WRITE $$fun^|"SAMPLES"|house invokes the user-defined function fun() in the routine house,<br />

located in the SAMPLES namespace.<br />

• Extended SSVN Reference: references a structured system variable (SSVN) in another namespace. The following<br />

syntactic forms are supported: ^$["namespace"]ssvn and ^$|"namespace"|ssvn. For further details, refer to<br />

the ^$GLOBAL, ^$LOCK, and ^$ROUTINE structured system variables.<br />

All extended references can, of course, specify the current namespace, either explicitly by name, or by specifying a null<br />

string placeholder.<br />

2.9 Reserved Words<br />

There are no reserved words in <strong>Caché</strong> <strong>ObjectScript</strong>; you can use any valid identifier as a variable name, function name, or<br />

label. At the same time, it is best to avoid using identifiers that are command names, function names, or other such strings.<br />

Also, since <strong>ObjectScript</strong> code includes support for embedded SQL, it is prudent to avoid naming any function, object,<br />

variable, or other entity with an SQL reserved word, as this may cause difficulties elsewhere.<br />

14 <strong>Using</strong> <strong>Caché</strong> <strong>ObjectScript</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!