Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples

$ORDER

1995 Version of ANSI (Equivalent to Current ISO Version) of Standard

7.1.5.11 $Order

$O[RDER] ( glvn )

This form returns a value which is a subscript according to a subscript ordering sequence. This ordering sequence is specified below with the aid of a function, CO, which is used for definitional purposes only, to establish the collating sequence.

CO(s,t) is defined, for strings s and t, as follows:

The ordering sequence is defined using the collation algorithm determined as follows:

  1. If $Order refers to a gvn with name global then the value of $Get(^$Global("global","COLLATE")) determines the algorithm.
  2. If $Order does not refer to a gvn, then the value of $Get(^$Character(^$Job($Job,"CHARACTER"),"COLLATE")) determines the algorithm.
  3. If the resulting algorithm is the empty string, then the collation algorithm of the charset M defined in Annex A is used.

The collation value order of a string subscript using a collation algorithm collate may be determined by executing the expression ("S order="_collate_"(subscript)"). Two collation values are compared on a character-by-character basis using the $ASCII values (i.e. equivalent to the follows (]) operator).

Only subscripted forms of glvn are permitted. Let glvn be of the form NAME(s1, s2, ..., sn) where sn may be the empty string. Let A be the set of subscripts that follow sn. That is, for all s in A:

  1. CO(sn,s) = s and
  2. $D(NAME(s1, s2, ..., sn–1, s)) is not zero.

Then $Order(NAME(s1, s2, ..., sn)) returns that value t in A such that CO(t,s) = s for all s not equal to t; that is, all other subscripts which follow sn also follow t.

If no such t exists, $Order returns the empty string.

$O[RDER] ( glvn , expr )

Let S be the value of expr. Then $Order(glvn,expr) returns:

  1. If S = 1, the function returns a result identical to that returned by $Order(glvn).
  2. If S = –1, the function returns a value which is a subscript, according to a subscript ordering sequence. This ordering sequence is specified below with the aid of a functions CO and CP, which are used for definitional purposes only, to establish the collating sequence.

    CO(s,t ) is defined, for strings s and t, according to the collation algorithm of the specific charset.

    CP(s,t ) is defined, for strings s and t, as follows:

    When t follows s in the ordering sequence and s is not the empty string, CP(s,t ) returns s.
    Otherwise, CP(s,t ) returns t.

    The following cases define the ordering sequence for CP:

    1. CP("",t) = t.
    2. CP(s,t) = t if CO(s,t) = s; otherwise, CP(s,t) = s.

    Only subscripted forms of glvn are permitted. Let glvn be of the form NAME(s1, s2, ..., sn ) where sn may be the empty string. Let A be the set of subscripts that precede sn. That is, for all s in A:

    1. CP(sn, s) = s and
    2. $D(NAME(s1, s2, ..., sn–1, s)) is not zero.

    Then $Order(NAME(s1, s2, ..., sn ), –1) returns that value t in A such that CP(t,s) = t for all s not equal to t; that is, all other subscripts which precede s also precede t.

    If no such t exists, $Order(NAME(s1, s2, ..., sn ), –1) returns the empty string.

  3. Values of S other than 1 and –1 are reserved for future extensions of the $Order function.
Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples

Copyright © Standard Documents; 1977-2024 MUMPS Development Committee;
Copyright © Examples: 1995-2024 Ed de Moel;
Copyright © Annotations: 2003-2008 Jacquard Systems Research
Copyright © Annotations: 2008-2024 Ed de Moel.

This page most recently updated on 15-Nov-2023, 13:10:43.

For comments, contact Ed de Moel (demoel@jacquardsystems.com)