log in

Magic Summary

2008-02-07 06:36 UTC

Symbol Reference

@A     Evaluates the macro A
A^B    Assigns A to B
A_B    Concatenates A and B
A!B    Logical or; also, max(A,B)
A&B    Logical and; also, min(A,B)
A+B    Addition (duh)
A-B    Subtraction (also duh)
A=B    Boolean equality
A>B    Boolean greater-than
A<B    Boolean less-than
'A     Logical negation
A'>B   Boolean less-than or equal
A'<B   Boolean greater-than or equal
A'=B   Boolean not equal
A:nC   The format operator (see below)
A?nC   The match operator
A%n    Returns all characters of A after the nth (0-indexed)
A$n    Returns all characters of A before the nth
A#n    Returns the nth character of A
A'%n   Returns all characters of A NOT after the nth
A'$n   Returns all characters of A NOT before the nth
A'#n   Returns all characters of A EXCEPT the nth
A#"nB" Splits A with delimiter B and returns the nth element
#      Refers to stdin/out, used with ^
!      Refers to the currently open device, used with ^ (e.g. printer)
A's.B  Pointer-to-member of a field; the field equivalent of A->B in C/C++

The format operator:

This operator is pretty complicated, and I don't 100% understand it yet, but here's what I know:
Let A = "ABCD"
    B = "Hello world"
    C = 123.456
    D = "1Bad characters2"

A:2  => "ABCDABCD" (repetition)
B:0S => "Helloworld" (strip spaces)
C:2D => 123.46 (round to 2 decimal places)
B:5T => "Hello" (truncate)
D:0X => "Bad characters" (strip non-printables)

The match operator:

I haven't actually seen this used but I'm fairly sure it works similarly to MUMPS' version, though the pattern-codes are likely a bit different: