variable p

30 20 array$ MENU

16 allot constant BUFFER

>comp

"  Forth-Code "   0 MENU $!
"  Options "      1 MENU $!
" "               2 MENU $!
"  Infos... "     3 MENU $!
" "               4 MENU $!
"  Code/Decode "  5 MENU $!
"  Multi Decode " 6 MENU $!
" --------------" 7 MENU $!
"  Exit "         8 MENU $!
" "               9 MENU $!

>comp

0 MENU menu      constant TREE
7 gemindex 0 TREE menu_ienable

>comp

\ n chaine code -> dcale les lettres majuscules de +n
\ n string code -> shift all letters by +n

: code
   p !
   .b size
   begin
      p )@
      ?dup
   while
      dup 65 90 <seg> if
         over +
         dup 90 > if 26 - then
         dup 65 < if 26 + then
      then
      p )+!
   repeat
   drop
;

\ Bote d'information
\ Information box

: infos
   1 " [1][ Forth Code ][ Ok ]" form_alert
;

\ codage interactif
\ interactive code

: code-decode
   15 >ifflag
      ." Cl   : " input cr
      ." Texte : " input$ cr
   >endf
   -15 >ifflag
      ." Key   : " input cr
      ." Text  : " input$ cr
   >endf
   code
   pad type cr
;

\ dcodage brut
\ raw decoding

: multi-decode
   15 >ifflag
      ." Texte : " input$ cr drop
   >endf
   -15 >ifflag
      ." Text  : " input$ cr drop
   >endf
   26 1 do
      i . space
      1 pad code
      pad type cr
   loop
;

\ procdure principale
\ main routine

: main
   fastopen drop cls
   1 TREE menu_bar
   begin
      begin
         BUFFER evnt_mesag
         BUFFER w@ 10 =
      until
      BUFFER 8 + w@
      strindex
      case
         3 of infos        0 endof
         5 of code-decode  0 endof
         6 of multi-decode 0 endof
         8 of              1 endof
         drop 0
      endcase
      BUFFER 6 + w@ 1 TREE menu_tnormal
   until
   0 TREE menu_bar
;

>comp

\ lance automatiquement le programme compil
\ mais ne fait rien sous l'interprteur

\ auto run the compiled program, but
\ does nothing when running the interpretor

-13 >ifflag
   0 v_show_c
   main
>endf




