M[UMPS] Functions - $J[USTIFY]

Introduced in the 1977 ANSI M[UMPS] language standard.

This function returns a formatted reproduction of the string passed as a parameter. The actual formatting depends on further parameters.

SET X=12.35

Reference   Value
$JUSTIFY(X,6)   "~12.35"
$JUSTIFY(X,5)   "12.35"
$JUSTIFY(X,4)   "12.35"
$JUSTIFY(X,3)   "12.35"
$JUSTIFY(X,7,4)   "12.3500"
$JUSTIFY(X,7,3)   "~12.350"
$JUSTIFY(X,7,2)   "~~12.35"
$JUSTIFY(X,7,1)   "~~~12.4"
$JUSTIFY(X,7,0)   "~~~~~12"
$JUSTIFY(X,1,1)   "12.4"

SET Y=197

Reference   Value
$JUSTIFY(Y,7,2)   "~197.00"
$JUSTIFY(Y,2,0)   "197"

SET Z="A"

Reference   Value
$JUSTIFY(Z,5)   "~~~~A"
$JUSTIFY(Z,5,2)   "~0.00"

Inverse function for adjustment of numeric values: $TRANSLATE($JUSTIFY(123,9)," ")=123

Note that +$JUSTIFY(123,9) = +"      123" = 0

Examples with naked references:

$JUSTIFY(VALUE,LENGTH)
SET ^ABC(1,2)="reset naked indicator"
; Naked indicator is now ^ABC(1,
SET ^(3,4)=$JUSTIFY(^(5,6),^(7,8))

; 1. fetch ^(5,6) = ^ABC(1,5,6)
; 2. fetch ^(7,8) = ^ABC(1,5,7,8)
; 3. store ^(3,4) = ^ABC(1,5,7,3,4)
; Naked indicator is now: ^ABC(1,5,7,3,

$JUSTIFY(VALUE,LENGTH,DECIMALS)
SET ^ABC(1,2)="reset naked indicator"
; Naked indicator is now ^ABC(1,
SET ^(3,4)=$JUSTIFY(^(5,6),^(7,8),^(9,10))

; 1. fetch ^(5,6) = ^ABC(1,5,6)
; 2. fetch ^(7,8) = ^ABC(1,5,7,8)
; 3. fetch ^(9,10) = ^ABC(1,5,7,9,10)
; 4. store ^(3,4) = ^ABC(1,5,7,9,3,4)
; Naked indicator is now: ^ABC(1,5,7,9,3,


This document is © Ed de Moel, 1995-2005.
It is part of a book by Ed de Moel that is published under the title "M[UMPS] by Example" (ISBN 0-918118-42-5).
Printed copies of the book are no longer available.