Examples of $GET()

Example:

    I '$D(^PNT(NAME,TSTR)) S STATUS="NEW TEST"
    E I ^PNT(NAME,TSTR)="" S STATUS="WAITING FOR RESULT"
    E S STATUS=^PNT(NAME ,TSTR)
    

This example can be reduced to two lines of code by using $GET(), shown in the following example. However, by using $GET() in its one-argument form, the distinction between an undefined variable and one with a null value is lost:

    S STATUS=$G(^PNT(NAME,TSTR))
    I STATUS="" S STATUS="WAITING FOR RESULT"
    

This is solved by using the two-argument form of $GET():

    S STATUS=$G(^PNT(NAME,TSTR),"NEW TEST")
    I STATUS="" S STATUS="WAITING FOR RESULT"