%%HP: T(3)A(D)F(.);

@ read read.me first!!!

@ ------------------------------------------------------------------------

@ This program let you add/view the codes from your device (IRCODES).

@ PRESUPPOSITIONS:
@   IRCODES in HOME BATCHES
@   this file in HOME BATCHES

@ SOURCE:
@   HP48G Series Advanced User's Reference Manual
@   Page 69ff

@ ------------------------------------------------------------------------

\<< 'IRCODES'
VTYPE
  IF -1 ==
  THEN { }
'IRCODES' STO
  END
  WHILE

    " Alpha-IR-Codes"
 { { "Enter Code" 1 }
   { "View Codes" 2 } }

  1 CHOOSE
  REPEAT \-> c

    \<<
      CASE

   c 1 ==              @ if you want to enter Codes...
        THEN
          WHILE
       "Add Code"
      { { "Bez.:" "Enter the Name of the Code"                2  }
        { "Code:" "Enter the number of the Code like # 12Ah"  10 } }
      { } { } { }
      INFORM                   @ create a form with that!
          REPEAT
          DUP
            IF { NOVAL } HEAD POS
            THEN                    @ one value is missing
              DROP
              "You have to enter both values!"
              MSGBOX
            ELSE 1
              \->LIST IRCODES +     @ everything's OK ...
              SORT 'IRCODES'        @ ... save it!
              STO
            END
          END
        END

   c 2 ==            @ if you want to view the codes...
        THEN
          IF
            { } IRCODES SAME     @ if IRCODES empty...
          THEN
             "You have to enter at least one Code before viewing!"
             MSGBOX              @ ...prompt an error-msg
          ELSE
            WHILE                @ if IRCODES has values...
              "View Codes"       @ ...create a choose-box...
              IRCODES 1 CHOOSE   @ ...with the contents of IRCODES
            REPEAT
              \->STR MSGBOX      @ and if you press OK/ENTER show the value
            END
          END     @ from: if..then..else
        END  
      END         @ from: case c 2 ==
    \>>
  END             @ from: repeat
\>>
