11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - 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.

<strong>Caché</strong> <strong>ObjectScript</strong> FunctionsintegerThe integer parameter is used when variable is a subscripted reference. If the value of integeris 0, $NAME returns only the name of the variable. If the value of integer is less than thenumber of subscripts in variable, $NAME returns the number of subscripts indicated by thevalue of integer. If integer is greater than the number of subscripts in variable, $NAMEreturns the full subscripted reference.If variable is an unsubscripted variable, the value of integer is ignored; $NAME returns thevariable name. If integer is the null string ("") or a non-numeric string, $NAME returns thevariable name with no subscripts.The value of integer receives standard integer parsing. For example, leading zeros and theplus sign are ignored. Decimal fractions are truncated and ignored. A negative integer valueresults in a error.ExamplesIn this example, the integer parameter specifies the level to return. If the specified numberof subscripts in integer matches or exceeds the number of subscript levels (in this case, 3),then $NAME returns all defined levels, behaving as if you specified the one-parameter form.If you specify an integer level of zero (0), the null string (""), or any non-numeric string (suchas "A"), $NAME returns the name of the array (in this case “^client”)SET ^client(4)="Vermont"SET ^client(4,1)="Brattleboro"SET ^client(4,1,1)="Yankee Ingenuity"SET ^client(4,1,2)="Vermonster Systems"WRITE !,$NAME(^client(4,1,1),1) ; returns 1 levelWRITE !,$NAME(^client(4,1,1),2) ; returns 2 levelsWRITE !,$NAME(^client(4,1,1),3) ; returns 3 levelsWRITE !,$NAME(^client(4,1,1),4) ; returns all (3) levelsWRITE !,$NAME(^client(4,1,1),0) ; returns array nameWRITE !,$NAME(^client(4,1,1),"") ; returns array nameWRITE !,$NAME(^client(4,1,1)) ; returns all (3) levelsIn the following example, $NAME is used with a naked reference in a loop to output thevalues for all elements in the current (user-supplied) array level.READ !,"Array element: ",arySET x=@ary ; dummy operation to set current array and levelSET y=$ORDER(^("")) ; null string to find beginning of levelFOR i=0:0 {WRITE !,@$NAME(^(y))SET y=$ORDER(^(y))QUIT:y=""}The first SET command performs a dummy assignment to establish the user-supplied arrayand level as the basis for the subsequent naked references. The $ORDER function is used264 <strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong>

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

Saved successfully!

Ooh no, something went wrong!