## \$JUSTIFY

### M[UMPS] by Example

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.

In the examples below, the open square character (⋥) is displayed where the resulting strings contain spaces, so that the number if space-characters becomes visible.

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,