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

$ORDER

Draft MDC Standard

7.1.5.15 $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:

When t follows s in the ordering sequence or if s is the empty string, CO(s,t) returns t.

Otherwise, CO(s,t) returns s.

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

  1. If $Order refers to an ssvn, then the algorithm is determined by the value of ^$System($SYstem, "COLLATE"); if that node does not exist, then the value of
       $Get(^$Character(^$System,"CHARACTER"),"COLLATE"))
    is used.
  2. If $Order refers to a gvn with name ^global then the algorithm is determined by the value of ^$Global( "^global ", "COLLATE"); if that node does not exist, then the value of
       $Get(^$Character(^$Global("^global","CHARACTER"),"COLLATE"))
    is used.
  3. If $Order does not refer to either of the above, then the algorithm is determined by the value of $Get(^$Character(^$Job($Job,"CHARACTER"),"COLLATE")).
  4. 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 such that, s is in A if and only if:

  1. CO(sn,s) = s and
  2. $Data(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 in A 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 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 such that, s is in A if and only if:

    1. CP(sn, s) = s and
    2. $Data(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 in A 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 to 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.

Some specifications are "approved for inclusion in a future standard". Note that the MUMPS Development Committee cannot guarantee that such future standards will indeed be published.

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

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