home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / util / misc / mcalc / source / mcalc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-18  |  63.5 KB  |  2,523 lines

  1. /*
  2. Auto:        smake MCalc
  3. */
  4.  
  5.  
  6. /* $Revision Header built automatically *************** (do not edit) ************
  7. **
  8. ** © Copyright by GuntherSoft
  9. **
  10. ** File             : SnakeSYS:CPrgs/MUICalc/MCalc.c
  11. ** Created on       : Saturday, 02.10.93 02:12:50
  12. ** Created by       : Kai Iske
  13. ** Current revision : V1.0
  14. **
  15. **
  16. ** Purpose
  17. ** -------
  18. **   - This is a quite flexible, powerful Calculator made for all
  19. **     those of you, who like to calc around ;) Even for
  20. **     programmers...
  21. **
  22. ** Revision V1.0
  23. ** --------------
  24. ** created on Saturday, 02.10.93 02:12:50  by  Kai Iske.   LogMessage :
  25. **     --- Initial release ---
  26. **
  27. *********************************************************************************/
  28.  
  29.  
  30.  
  31. /**********************************************************************/
  32. /*                    Externals to Scanner/Parser                     */
  33. /**********************************************************************/
  34. extern    UWORD        PCharRead;
  35. extern    UWORD        PColumn;
  36. extern    UWORD        PError;
  37. extern    UWORD        NonDouble;
  38. extern    int        yynerrs;
  39. extern    int        yychar;
  40. extern    int        yy_init;
  41. extern    int        yy_start;
  42. extern    FILE        *yyin, *yyout;
  43. extern    void        *yy_current_buffer;
  44.  
  45.  
  46. extern UWORD        RXIntType;
  47. extern UWORD        RXIntBase;
  48. extern UWORD        RXIntSign;
  49. extern UWORD        RXIntAngle;
  50.  
  51.  
  52. /**********************************************************************/
  53. /*    Aehm, SAS 6.50 seams to open up a window just as it likes ;)    */
  54. /**********************************************************************/
  55. char __stdiowin[] = "NIL:";
  56.  
  57.  
  58.  
  59. /**********************************************************************/
  60. /*                 External variables of ARexx module                 */
  61. /**********************************************************************/
  62. extern struct MUI_Command    RXCommands[];
  63.  
  64.  
  65.  
  66.  
  67. /**********************************************************************/
  68. /*                      Routines for that module                      */
  69. /**********************************************************************/
  70. static BOOL OpenLibs(void);
  71. static void CloseLibs(void);
  72. static void SetMainWinCycle(void);
  73. static BOOL OpenMainWin(void);
  74. static void CloseMainWin(void);
  75. static ULONG    __saveds __asm InsertFunc(register __a0 struct Hook *MyHook, register __a2 APTR Obj, register __a1 APTR *Data);
  76. static ULONG    __saveds __asm DispConstructFunc(register __a0 struct Hook *MyHook, register __a2 APTR MemPool, register __a1 struct ListStruct *Data);
  77. static ULONG    __saveds __asm DispDestructFunc(register __a0 struct Hook *MyHook, register __a2 APTR MemPool, register __a1 struct ListStruct *Data);
  78. static ULONG    __saveds __asm DispViewFunc(register __a0 struct Hook *MyHook, register __a2 char **array, register __a1 struct ListStruct *Data);
  79. static void InsertText(char *NewText);
  80. static void WriteClip(char *Entry);
  81. static void HandleInputs(void);
  82.  
  83.  
  84.  
  85.  
  86. /**********************************************************************/
  87. /*                           Library-Bases                            */
  88. /**********************************************************************/
  89. extern    struct ExecBase    *SysBase;
  90.  
  91. struct    IntuitionBase    *IntuitionBase        = NULL;
  92. struct    GfxBase        *GfxBase        = NULL;
  93. struct    Library        *UtilityBase        = NULL;
  94. struct    Library        *IconBase        = NULL;
  95. struct    Library        *MUIMasterBase        = NULL;
  96. struct    Library        *MathIeeeDoubBasBase    = NULL;
  97. struct    Library        *MathIeeeDoubTransBase    = NULL;
  98. struct    Library        *IFFParseBase        = NULL;
  99.  
  100.  
  101.  
  102.  
  103. /**********************************************************************/
  104. /*                            The Objects                             */
  105. /**********************************************************************/
  106. static    struct    DiskObject    *DObject    = NULL;
  107. APTR        AppObject            = NULL;        // Is referenced through ARexx module
  108. static    APTR    MainWindow;
  109. static    APTR    InOutGroup;
  110. static    APTR    InputGroup;
  111. APTR        InputString;                    // Is referenced through ARexx module
  112. static    APTR    OutputGroup;
  113. APTR        OutputBox;                    // Is referenced through ARexx module
  114. static    APTR    FunctionCycle;
  115. static    APTR    PageObject;
  116. static    APTR    InGads[63];
  117. static    APTR    ExeObj;
  118. static    APTR    ClrObj;
  119. static    APTR    AllClrObj;
  120.  
  121. static    APTR    MainGroup;
  122. static    APTR    FuncGroup;
  123. static    APTR    InGroup;
  124.  
  125. static    APTR    PrefsWindow;
  126. static    APTR    InOutObj;
  127. static    APTR    DFuncObj;
  128. static    APTR    DInObj;
  129. static    APTR    TypeObj;
  130. static    APTR    SizeObj;
  131. static    APTR    SignObj;
  132. static    APTR    AngleObj;
  133. static    APTR    LinesObj;
  134. static    APTR    LookObj;
  135. static    APTR    ClearInObj;
  136. static    APTR    FlushObj;
  137. static    APTR    ClipObj;
  138. static    APTR    OkObj;
  139. static    APTR    SaveObj;
  140. static    APTR    CancelObj;
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147. /**********************************************************************/
  148. /*                 Strings for Functions Cycle-Gadget                 */
  149. /**********************************************************************/
  150. static const char *FunctionEntries[] =
  151. {
  152.     "Mathematical set",
  153.     "Programmer`s set",
  154.     NULL
  155. };
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162. /**********************************************************************/
  163. /*                      Strings for Prefs-Cycles                      */
  164. /**********************************************************************/
  165. static const char *InOutLookEntries[] =
  166. {
  167.     "Input then Output",
  168.     "Output then Input",
  169.     NULL
  170. };
  171.  
  172. static const char *TypeEntries[] =
  173. {
  174.     "Decimal",
  175.     "HexDecimal",
  176.     "Octal",
  177.     "Binary",
  178.     NULL
  179. };
  180.  
  181. static const char *SizeEntries[] =
  182. {
  183.     "8-Bit",
  184.     "16-Bit",
  185.     "32-Bit",
  186.     NULL
  187. };
  188.  
  189. static const char *SignEntries[] =
  190. {
  191.     "Signed",
  192.     "Unsigned",
  193.     NULL
  194. };
  195.  
  196. static const char *AngleEntries[] =
  197. {
  198.     "Radians",
  199.     "Degree",
  200.     NULL
  201. };
  202.  
  203. static const char *LookEntries[] =
  204. {
  205.     "Input & Output",
  206.     "Output & Input",
  207.     "Input",
  208.     "Output",
  209.     NULL
  210. };
  211.  
  212.  
  213. static const char *LookTemplates[] =
  214. {
  215.     "COL=0 DELTA=12 P=\033r MAW=100 MIW=0, COL=1 DELTA=12 P=\033r MAW=-1 MIW=-1",
  216.     "COL=1 DELTA=12 P=\033r MAW=-1 MIW=-1, COL=0 DELTA=12 P=\033r MAW=100 MIW=0",
  217.     "COL=0 DELTA=12 P=\033r MIW=100",
  218.     "COL=1 DELTA=12 P=\033r MIW=100"
  219. };
  220.  
  221.  
  222.  
  223. /**********************************************************************/
  224. /*                   Chars/String for window title                    */
  225. /**********************************************************************/
  226. static const char TypeChar[] =
  227. {
  228.     'D',
  229.     'H',
  230.     'O',
  231.     'B'
  232. };
  233.  
  234. static const char *BaseStr[] =
  235. {
  236.     "8",
  237.     "16",
  238.     "32"
  239. };
  240.  
  241.  
  242. static const char SignChar[] =
  243. {
  244.     'S',
  245.     'U',
  246. };
  247.  
  248.  
  249. static const char *AngleStr[] =
  250. {
  251.     "RAD",
  252.     "DEG",
  253. };
  254.  
  255.  
  256.  
  257.  
  258. /**********************************************************************/
  259. /*                          Menu-Definition                           */
  260. /**********************************************************************/
  261. static struct    NewMenu MainMenuDef[] =
  262. {
  263.     NM_TITLE, "Project", NULL, 0, NULL, NULL,
  264.     NM_ITEM, "Preferences...", "P", 0, NULL, (APTR)ID_PREFS,
  265.     NM_ITEM, NM_BARLABEL, NULL, 0, NULL, NULL,
  266.     NM_ITEM, "About...", "?", 0, NULL, (APTR)ID_ABOUT,
  267.     NM_ITEM, NM_BARLABEL, NULL, 0, NULL, NULL,
  268.     NM_ITEM, "Quit", "Q", 0, NULL, (APTR)ID_QUIT,
  269.  
  270.     NM_TITLE, "Edit", NULL, 0, NULL, NULL,
  271.     NM_ITEM, "Clear", "X", 0, NULL, (APTR)ID_CLEAR,
  272.     NM_ITEM, "All Clear", "Y", 0, NULL, (APTR)ID_ALLCLEAR,
  273.  
  274.     NM_TITLE, "History", NULL, 0, NULL, NULL,
  275.     NM_ITEM, "Pick left entry", "L", 0, NULL, (APTR)ID_PICKLEFT,
  276.     NM_ITEM, "Pick right entry", "R", 0, NULL, (APTR)ID_PICKRIGHT,
  277.     NM_ITEM, NM_BARLABEL, NULL, 0, NULL, NULL,
  278.     NM_ITEM, "Copy left entry", "F", 0, NULL, (APTR)ID_CLIPCUTLEFT,
  279.     NM_ITEM, "Copy right entry", "G", 0, NULL, (APTR)ID_CLIPCUTRIGHT,
  280.  
  281.     NM_TITLE, "Display Bases", NULL, 0, NULL, NULL,
  282.     NM_ITEM, "Decimal", "D", CHECKIT|MENUTOGGLE, 14, (APTR)ID_DECIMAL,
  283.     NM_ITEM, "Hexadecimal", "H", CHECKIT|MENUTOGGLE, 13, (APTR)ID_HEXDECIMAL,
  284.     NM_ITEM, "Octal", "O", CHECKIT|MENUTOGGLE, 11, (APTR)ID_OCTAL,
  285.     NM_ITEM, "Binary", "B", CHECKIT|MENUTOGGLE, 7, (APTR)ID_BINARY,
  286.  
  287.     NM_TITLE, "Size", NULL, 0, NULL, NULL,
  288.     NM_ITEM, "8 Bit", "8", CHECKIT|MENUTOGGLE, 6, (APTR)ID_8BIT,
  289.     NM_ITEM, "16 Bit", "16", CHECKIT|MENUTOGGLE, 5, (APTR)ID_16BIT,
  290.     NM_ITEM, "32 Bit", "32", CHECKIT|MENUTOGGLE, 3, (APTR)ID_32BIT,
  291.  
  292.     NM_TITLE, "Sign", NULL, 0, NULL, NULL,
  293.     NM_ITEM, "Signed", "S", CHECKIT|MENUTOGGLE, 2, (APTR)ID_SIGNED,
  294.     NM_ITEM, "Unsigned", "U", CHECKIT|MENUTOGGLE, 1, (APTR)ID_UNSIGNED,
  295.  
  296.     NM_TITLE, "Angle", NULL, 0, NULL, NULL,
  297.     NM_ITEM, "Radians", "A", CHECKIT|MENUTOGGLE, 2, (APTR)ID_RAD,
  298.     NM_ITEM, "Degree", "E", CHECKIT|MENUTOGGLE, 1, (APTR)ID_DEG,
  299.  
  300.     NM_END, NULL, NULL, 0, NULL, NULL
  301. };
  302.  
  303.  
  304.  
  305.  
  306.  
  307. /**********************************************************************/
  308. /*                       Some global Variables                        */
  309. /**********************************************************************/
  310. static struct    Hook    InsertHook =             // This is our hook for the InputGadgets
  311. {
  312.     {NULL},
  313.     (APTR)InsertFunc,
  314.     NULL,
  315.     NULL
  316. };
  317.  
  318.  
  319. static struct    Hook    DispConstructHook =        // Hooks for multi-column display
  320. {
  321.     {NULL},
  322.     (APTR)DispConstructFunc,
  323.     NULL,
  324.     NULL
  325. };
  326.  
  327. static struct Hook    DispDestructHook =
  328. {
  329.     {NULL},
  330.     (APTR)DispDestructFunc,
  331.     NULL,
  332.     NULL
  333. };
  334.  
  335. static struct Hook    DispViewHook = 
  336. {
  337.     {NULL},
  338.     (APTR)DispViewFunc,
  339.     NULL,
  340.     NULL
  341. };
  342.  
  343.  
  344. char    *ParseInput;                // This has to be global, so that the scanner my find it ;)
  345. APTR    ParsePool;                // Pointer to parser`s memory pool
  346. char    Title[80];                // Title of main window
  347.  
  348.  
  349. double    Value,                    // Value being displayed and memories
  350.     XMem,
  351.     YMem,
  352.     ZMem;
  353.  
  354.  
  355. UWORD    InOutLook    = 0;                // How to order the String and ListView gadgets
  356. UWORD    NoFuncs        = FALSE;            // Display function gadgets ???
  357. UWORD    NoInput        = FALSE;            // Display input gadgets ???
  358. UWORD    IntType        = ID_DECIMAL;            // Current output format
  359. UWORD    IntBase        = ID_32BIT;            // Current conversion base
  360. UWORD    IntSign        = ID_SIGNED;            // Current ouput sign-format
  361. UWORD    IntAngle    = ID_RAD;            // Current angle format
  362. UWORD    HistLines    = 32;                // Default number of history lines
  363. UWORD    ListLook    = 0;                // Look of ListView
  364. UWORD    FlushOnExit    = FALSE;            // Flush memory on exit ???
  365. UWORD    ClearInput    = FALSE;            // Clear input string after RETURN/EXEC ???
  366. UWORD    ClipUnit    = 0;                // Number of clipboard to use
  367. UWORD    ContainsUnDec;                    // This is to signal the main program,
  368.                             // that non-decimal digits have been used
  369.  
  370.  
  371.  
  372.  
  373.  
  374. /**********************************************************************/
  375. /*                        Do the wild thing ;)                        */
  376. /**********************************************************************/
  377. void main(void)
  378. {
  379.     APTR    FlushPtr;
  380.     int    i;
  381.  
  382.         // Try to open libs
  383.  
  384.     if(OpenLibs())
  385.     {
  386.             // Try to open the main window
  387.  
  388.         if(OpenMainWin())
  389.         {
  390.                 // Display "0" in desired format
  391.  
  392.             FormatOutput(FALSE);
  393.  
  394.                 // Handle incoming inputs
  395.  
  396.             HandleInputs();
  397.         }
  398.         CloseMainWin();
  399.     }
  400.     CloseLibs();
  401.  
  402.  
  403.         // Should memory be flushed ???
  404.  
  405.     if(FlushOnExit)
  406.     {
  407.         for(i = 0; i < 10; i++)
  408.         {
  409.             if((FlushPtr = AllocMem(0x1DCD6500, MEMF_PUBLIC)))
  410.                 FreeMem(FlushPtr, 0x1DCD6500);
  411.         }
  412.     }
  413.  
  414.     exit(0);
  415. }
  416.  
  417.  
  418.  
  419.  
  420. /**********************************************************************/
  421. /*                      Open-Up needed libraries                      */
  422. /**********************************************************************/
  423. static BOOL OpenLibs(void)
  424. {
  425.     if(!(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 37)))
  426.         return(FALSE);
  427.  
  428.     if(!(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 37)))
  429.         return(FALSE);
  430.  
  431.     if(!(UtilityBase = OpenLibrary("utility.library", 37)))
  432.         return(FALSE);
  433.  
  434.     if(!(IconBase = OpenLibrary("icon.library", 37)))
  435.         return(FALSE);
  436.  
  437.     if(!(MathIeeeDoubBasBase = OpenLibrary("mathieeedoubbas.library", 37)))
  438.         return(FALSE);
  439.  
  440.     if(!(MathIeeeDoubTransBase = OpenLibrary("mathieeedoubtrans.library", 37)))
  441.         return(FALSE);
  442.  
  443.     if(!(IFFParseBase = OpenLibrary("iffparse.library", 37)))
  444.         return(FALSE);
  445.  
  446.     if(!(MUIMasterBase = OpenLibrary("muimaster.library", 0)))
  447.         return(FALSE);
  448.  
  449.     return(TRUE);
  450. }
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458. /**********************************************************************/
  459. /*                          Close used libs                           */
  460. /**********************************************************************/
  461. static void CloseLibs(void)
  462. {
  463.     if(MUIMasterBase)
  464.         CloseLibrary(MUIMasterBase);
  465.  
  466.     if(IFFParseBase)
  467.         CloseLibrary(IFFParseBase);
  468.  
  469.     if(MathIeeeDoubTransBase)
  470.         CloseLibrary(MathIeeeDoubTransBase);
  471.  
  472.     if(MathIeeeDoubBasBase)
  473.         CloseLibrary(MathIeeeDoubBasBase);
  474.  
  475.     if(IconBase)
  476.         CloseLibrary(IconBase);
  477.  
  478.     if(UtilityBase)
  479.         CloseLibrary(UtilityBase);
  480.  
  481.     if(GfxBase)
  482.         CloseLibrary((struct Library *)GfxBase);
  483.  
  484.     if(IntuitionBase)
  485.         CloseLibrary((struct Library *)IntuitionBase);
  486. }
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493. /**********************************************************************/
  494. /*                  Set Cycle Chain for main window                   */
  495. /**********************************************************************/
  496. static void SetMainWinCycle(void)
  497. {
  498.     APTR    FirstCycle,
  499.         LastCycle;
  500.     int    GadNum;
  501.  
  502.     if(!InOutLook)
  503.     {
  504.         FirstCycle    = InputString;
  505.         LastCycle    = OutputBox;
  506.     }
  507.     else
  508.     {
  509.         FirstCycle    = OutputBox;
  510.         LastCycle    = InputString;
  511.     }
  512.         // Set Cycle chanin
  513.  
  514.     GadNum    = 0;
  515.     DoMethod(MainWindow, MUIM_Window_SetCycleChain,
  516.         FirstCycle,
  517.         LastCycle,
  518.         FunctionCycle,
  519.         InGads[GadNum++],
  520.         InGads[GadNum++],
  521.         InGads[GadNum++],
  522.         InGads[GadNum++],
  523.         InGads[GadNum++],
  524.         InGads[GadNum++],
  525.         InGads[GadNum++],
  526.         InGads[GadNum++],
  527.         InGads[GadNum++],
  528.         InGads[GadNum++],
  529.         InGads[GadNum++],
  530.         InGads[GadNum++],
  531.         InGads[GadNum++],
  532.         InGads[GadNum++],
  533.         InGads[GadNum++],
  534.         InGads[GadNum++],
  535.         InGads[GadNum++],
  536.         InGads[GadNum++],
  537.         InGads[GadNum++],
  538.         InGads[GadNum++],
  539.         InGads[GadNum++],
  540.         InGads[GadNum++],
  541.         InGads[GadNum++],
  542.         InGads[GadNum++],
  543.         InGads[GadNum++],
  544.         InGads[GadNum++],
  545.         InGads[GadNum++],
  546.         InGads[GadNum++],
  547.         InGads[GadNum++],
  548.         InGads[GadNum++],
  549.         InGads[GadNum++],
  550.         InGads[GadNum++],
  551.         InGads[GadNum++],
  552.         InGads[GadNum++],
  553.         InGads[GadNum++],
  554.         InGads[GadNum++],
  555.         InGads[GadNum++],
  556.         InGads[GadNum++],
  557.         InGads[GadNum++],
  558.         InGads[GadNum++],
  559.         InGads[GadNum++],
  560.         InGads[GadNum++],
  561.         InGads[GadNum++],
  562.         InGads[GadNum++],
  563.         InGads[GadNum++],
  564.         InGads[GadNum++],
  565.         InGads[GadNum++],
  566.         InGads[GadNum++],
  567.         InGads[GadNum++],
  568.         InGads[GadNum++],
  569.         InGads[GadNum++],
  570.         InGads[GadNum++],
  571.         InGads[GadNum++],
  572.         InGads[GadNum++],
  573.         InGads[GadNum++],
  574.         InGads[GadNum++],
  575.         InGads[GadNum++],
  576.         InGads[GadNum++],
  577.         InGads[GadNum++],
  578.         InGads[GadNum++],
  579.         InGads[GadNum++],
  580.         ClrObj,
  581.         AllClrObj,
  582.         ExeObj,
  583.     NULL);
  584. }
  585.  
  586.  
  587.  
  588.  
  589. /**********************************************************************/
  590. /*                    Open the Calculator`s Window                    */
  591. /**********************************************************************/
  592. static BOOL OpenMainWin(void)
  593. {
  594.     ULONG    Dummy, GadNum = 0;
  595.  
  596.  
  597.         // The input String Requester
  598.  
  599.     InputGroup    = VGroup, Child,
  600.         InputString    =    StringObject, StringFrame,
  601.                         MUIA_String_Contents,    "0",
  602.                         MUIA_String_MaxLen,    256,
  603.                         MUIA_String_Format,    MUIV_String_Format_Right,
  604.                         MUIA_String_BufferPos,    1,
  605.                     End,
  606.     End;
  607.  
  608.  
  609.         // The Output Box
  610.  
  611.     OutputGroup    = VGroup, Child,
  612.         OutputBox    =    ListviewObject,
  613.                         MUIA_Listview_Input,        TRUE,
  614.                         MUIA_Listview_List,    ListObject, InputListFrame,
  615.                             MUIA_Background,        MUII_ListBack,
  616.                             MUIA_List_Format,        "COL=0 DELTA=8 P=\033r MAW=50 MIW=10, COL=1 DELTA=8 P=\033r MAW=50 MIW=10",
  617.                             MUIA_List_ConstructHook,    &DispConstructHook,
  618.                             MUIA_List_DestructHook,        &DispDestructHook,
  619.                             MUIA_List_DisplayHook,        &DispViewHook,
  620.                         End,
  621.                     End,
  622.     End;
  623.  
  624.  
  625.         // Create the Application window
  626.  
  627.     AppObject    = ApplicationObject,
  628.                 MUIA_Application_Title,        "MCalc",
  629.                 MUIA_Application_Version,    MUIVERS,
  630.                 MUIA_Application_Copyright,    "©1993/94 Kai Iske",
  631.                 MUIA_Application_Author,    "Kai Iske",
  632.                 MUIA_Application_Description,    "Quite powerful calculator, GiftWare",
  633.                 MUIA_Application_Base,        "MCalc",
  634.                 MUIA_Application_SingleTask,    TRUE,
  635.                 MUIA_Application_DiskObject,    DObject = GetDiskObjectNew("PROGDIR:MCalc"),
  636.                 MUIA_Application_Commands,    &RXCommands[0],
  637.                 MUIA_HelpFile,            "MCalc.guide",
  638.  
  639.             // Now head for the main window
  640.  
  641.         SubWindow, MainWindow =    WindowObject,
  642.                         MUIA_Window_Title,    "MUIProCalc "REVISION" - "REVDATE,
  643.                         MUIA_Window_ID,        'MPCM',
  644.                         MUIA_Window_SizeGadget,    TRUE,
  645.                         MUIA_Window_Menu,    &MainMenuDef,
  646.                         MUIA_HelpNode,        NODE_MAIN,
  647.  
  648.                 // Do the gadgets
  649.  
  650.             WindowContents,
  651.             MainGroup = VGroup,
  652.  
  653.                     // First of all the Input and Output Group
  654.  
  655.                 Child,
  656.                 InOutGroup = VGroup, GroupFrame,
  657.                     MUIA_HelpNode,    NODE_INOUTPUT,
  658.                 End, // Input Area
  659.  
  660.                     // Now check for the Function Gadgets
  661.  
  662.                 Child,
  663.  
  664.                 FuncGroup = VGroup, GroupFrame,
  665.                     MUIA_HelpNode, NODE_FUNCTIONS,
  666.  
  667.                     Child, ColGroup(2),
  668.  
  669.                             // The Cycle Gadget for Function keys
  670.  
  671.                         Child, KeyLabel1("Function:", 'n'),
  672.                         Child, FunctionCycle    =    CycleObject, ButtonFrame,
  673.                                             MUIA_Cycle_Active,    0,
  674.                                             MUIA_Cycle_Entries,    FunctionEntries,
  675.                                             MUIA_ControlChar,    'n',
  676.                                             MUIA_ExportID,        'FPAG',
  677.                                         End,
  678.                     End, // Cycle Gadget
  679.  
  680.                     // Function Buttons
  681.  
  682.                     Child, PageObject = PageGroup,
  683.  
  684.                         Child, ColGroup(7), MUIA_Group_SameWidth, TRUE,
  685.  
  686.                                 // First row of Functions
  687.  
  688.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  689.                                                 MUIA_Text_Contents,    "Sin",
  690.                                                 MUIA_Text_PreParse,    "\33c",
  691.                                                 MUIA_Background,    MUII_ButtonBack,
  692.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  693.                                             End,
  694.  
  695.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  696.                                                 MUIA_Text_Contents,    "Cos",
  697.                                                 MUIA_Text_PreParse,    "\33c",
  698.                                                 MUIA_Background,    MUII_ButtonBack,
  699.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  700.                                             End,
  701.  
  702.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  703.                                                 MUIA_Text_Contents,    "Tan",
  704.                                                 MUIA_Text_PreParse,    "\33c",
  705.                                                 MUIA_Background,    MUII_ButtonBack,
  706.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  707.                                             End,
  708.  
  709.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  710.                                                 MUIA_Text_Contents,    "ASin",
  711.                                                 MUIA_Text_PreParse,    "\33c",
  712.                                                 MUIA_Background,    MUII_ButtonBack,
  713.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  714.                                             End,
  715.  
  716.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  717.                                                 MUIA_Text_Contents,    "ACos",
  718.                                                 MUIA_Text_PreParse,    "\33c",
  719.                                                 MUIA_Background,    MUII_ButtonBack,
  720.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  721.                                             End,
  722.  
  723.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  724.                                                 MUIA_Text_Contents,    "ATan",
  725.                                                 MUIA_Text_PreParse,    "\33c",
  726.                                                 MUIA_Background,    MUII_ButtonBack,
  727.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  728.                                             End,
  729.  
  730.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  731.                                                 MUIA_Text_Contents,    "SinH",
  732.                                                 MUIA_Text_PreParse,    "\33c",
  733.                                                 MUIA_Background,    MUII_ButtonBack,
  734.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  735.                                             End,
  736.  
  737.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  738.                                                 MUIA_Text_Contents,    "CosH",
  739.                                                 MUIA_Text_PreParse,    "\33c",
  740.                                                 MUIA_Background,    MUII_ButtonBack,
  741.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  742.                                             End,
  743.  
  744.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  745.                                                 MUIA_Text_Contents,    "TanH",
  746.                                                 MUIA_Text_PreParse,    "\33c",
  747.                                                 MUIA_Background,    MUII_ButtonBack,
  748.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  749.                                             End,
  750.  
  751.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  752.                                                 MUIA_Text_Contents,    "Log",
  753.                                                 MUIA_Text_PreParse,    "\33c",
  754.                                                 MUIA_Background,    MUII_ButtonBack,
  755.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  756.                                             End,
  757.  
  758.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  759.                                                 MUIA_Text_Contents,    "Log10",
  760.                                                 MUIA_Text_PreParse,    "\33c",
  761.                                                 MUIA_Background,    MUII_ButtonBack,
  762.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  763.                                             End,
  764.  
  765.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  766.                                                 MUIA_Text_Contents,    "Exp",
  767.                                                 MUIA_Text_PreParse,    "\33c",
  768.                                                 MUIA_Background,    MUII_ButtonBack,
  769.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  770.                                             End,
  771.  
  772.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  773.                                                 MUIA_Text_Contents,    "^",
  774.                                                 MUIA_Text_PreParse,    "\33c",
  775.                                                 MUIA_Background,    MUII_ButtonBack,
  776.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  777.                                             End,
  778.  
  779.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  780.                                                 MUIA_Text_Contents,    "Pi",
  781.                                                 MUIA_Text_PreParse,    "\33c",
  782.                                                 MUIA_Background,    MUII_ButtonBack,
  783.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  784.                                             End,
  785.  
  786.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  787.                                                 MUIA_Text_Contents,    "Sqrt",
  788.                                                 MUIA_Text_PreParse,    "\33c",
  789.                                                 MUIA_Background,    MUII_ButtonBack,
  790.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  791.                                             End,
  792.  
  793.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  794.                                                 MUIA_Text_Contents,    "Abs",
  795.                                                 MUIA_Text_PreParse,    "\33c",
  796.                                                 MUIA_Background,    MUII_ButtonBack,
  797.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  798.                                             End,
  799.  
  800.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  801.                                                 MUIA_Text_Contents,    "Cot",
  802.                                                 MUIA_Text_PreParse,    "\33c",
  803.                                                 MUIA_Background,    MUII_ButtonBack,
  804.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  805.                                             End,
  806.  
  807.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  808.                                                 MUIA_Text_Contents,    "e",
  809.                                                 MUIA_Text_PreParse,    "\33c",
  810.                                                 MUIA_Background,    MUII_ButtonBack,
  811.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  812.                                             End,
  813.  
  814.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  815.                                                 MUIA_Text_Contents,    "%",
  816.                                                 MUIA_Text_PreParse,    "\33c",
  817.                                                 MUIA_Background,    MUII_ButtonBack,
  818.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  819.                                             End,
  820.  
  821.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  822.                                                 MUIA_Text_Contents,    "%ch",
  823.                                                 MUIA_Text_PreParse,    "\33c",
  824.                                                 MUIA_Background,    MUII_ButtonBack,
  825.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  826.                                             End,
  827.  
  828.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  829.                                                 MUIA_Text_Contents,    "%t",
  830.                                                 MUIA_Text_PreParse,    "\33c",
  831.                                                 MUIA_Background,    MUII_ButtonBack,
  832.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  833.                                             End,
  834.                         End, // First Button Bank
  835.  
  836.                             // Second Button-Bank
  837.  
  838.                         Child, ColGroup(6), MUIA_Group_SameWidth, TRUE,
  839.  
  840.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  841.                                                 MUIA_Text_Contents,    "Mod",
  842.                                                 MUIA_Text_PreParse,    "\33c",
  843.                                                 MUIA_Background,    MUII_ButtonBack,
  844.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  845.                                             End,
  846.  
  847.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  848.                                                 MUIA_Text_Contents,    "And",
  849.                                                 MUIA_Text_PreParse,    "\33c",
  850.                                                 MUIA_Background,    MUII_ButtonBack,
  851.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  852.                                             End,
  853.  
  854.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  855.                                                 MUIA_Text_Contents,    "Or",
  856.                                                 MUIA_Text_PreParse,    "\33c",
  857.                                                 MUIA_Background,    MUII_ButtonBack,
  858.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  859.                                             End,
  860.  
  861.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  862.                                                 MUIA_Text_Contents,    "XOr",
  863.                                                 MUIA_Text_PreParse,    "\33c",
  864.                                                 MUIA_Background,    MUII_ButtonBack,
  865.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  866.                                             End,
  867.  
  868.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  869.                                                 MUIA_Text_Contents,    "Not",
  870.                                                 MUIA_Text_PreParse,    "\33c",
  871.                                                 MUIA_Background,    MUII_ButtonBack,
  872.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  873.                                             End,
  874.  
  875.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  876.                                                 MUIA_Text_Contents,    "Asl",
  877.                                                 MUIA_Text_PreParse,    "\33c",
  878.                                                 MUIA_Background,    MUII_ButtonBack,
  879.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  880.                                             End,
  881.  
  882.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  883.                                                 MUIA_Text_Contents,    "Asr",
  884.                                                 MUIA_Text_PreParse,    "\33c",
  885.                                                 MUIA_Background,    MUII_ButtonBack,
  886.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  887.                                             End,
  888.  
  889.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  890.                                                 MUIA_Text_Contents,    "Lsl",
  891.                                                 MUIA_Text_PreParse,    "\33c",
  892.                                                 MUIA_Background,    MUII_ButtonBack,
  893.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  894.                                             End,
  895.  
  896.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  897.                                                 MUIA_Text_Contents,    "Lsr",
  898.                                                 MUIA_Text_PreParse,    "\33c",
  899.                                                 MUIA_Background,    MUII_ButtonBack,
  900.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  901.                                             End,
  902.  
  903.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  904.                                                 MUIA_Text_Contents,    "Rol",
  905.                                                 MUIA_Text_PreParse,    "\33c",
  906.                                                 MUIA_Background,    MUII_ButtonBack,
  907.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  908.                                             End,
  909.  
  910.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  911.                                                 MUIA_Text_Contents,    "Ror",
  912.                                                 MUIA_Text_PreParse,    "\33c",
  913.                                                 MUIA_Background,    MUII_ButtonBack,
  914.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  915.                                             End,
  916.                             Child, HSpace(0),
  917.                         End, // Second Button Bank
  918.                     End, // Page-Group
  919.                 End, // Second Area
  920.  
  921.                 Child,
  922.                 InGroup = VGroup, GroupFrame,
  923.                     MUIA_HelpNode,    NODE_INPUTS,
  924.  
  925.                     Child, ColGroup(7), MUIA_Group_SameWidth, TRUE,
  926.  
  927.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  928.                                         MUIA_Text_Contents,    "A",
  929.                                         MUIA_Text_PreParse,    "\33c",
  930.                                         MUIA_Background,    MUII_ButtonBack,
  931.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  932.                                     End,
  933.  
  934.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  935.                                         MUIA_Text_Contents,    "B",
  936.                                         MUIA_Text_PreParse,    "\33c",
  937.                                         MUIA_Background,    MUII_ButtonBack,
  938.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  939.                                     End,
  940.  
  941.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  942.                                         MUIA_Text_Contents,    "C",
  943.                                         MUIA_Text_PreParse,    "\33c",
  944.                                         MUIA_Background,    MUII_ButtonBack,
  945.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  946.                                     End,
  947.  
  948.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  949.                                         MUIA_Text_Contents,    "D",
  950.                                         MUIA_Text_PreParse,    "\33c",
  951.                                         MUIA_Background,    MUII_ButtonBack,
  952.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  953.                                     End,
  954.  
  955.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  956.                                         MUIA_Text_Contents,    "E",
  957.                                         MUIA_Text_PreParse,    "\33c",
  958.                                         MUIA_Background,    MUII_ButtonBack,
  959.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  960.                                     End,
  961.  
  962.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  963.                                         MUIA_Text_Contents,    "$",
  964.                                         MUIA_Text_PreParse,    "\33c",
  965.                                         MUIA_Background,    MUII_ButtonBack,
  966.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  967.                                     End,
  968.  
  969.                         Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  970.                                             MUIA_Text_Contents,    "0x",
  971.                                             MUIA_Text_PreParse,    "\33c",
  972.                                             MUIA_Background,    MUII_ButtonBack,
  973.                                             MUIA_InputMode,        MUIV_InputMode_RelVerify,
  974.                                         End,
  975.  
  976.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  977.                                         MUIA_Text_Contents,    "7",
  978.                                         MUIA_Text_PreParse,    "\33c",
  979.                                         MUIA_Background,    MUII_ButtonBack,
  980.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  981.                                     End,
  982.  
  983.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  984.                                         MUIA_Text_Contents,    "8",
  985.                                         MUIA_Text_PreParse,    "\33c",
  986.                                         MUIA_Background,    MUII_ButtonBack,
  987.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  988.                                     End,
  989.  
  990.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  991.                                         MUIA_Text_Contents,    "9",
  992.                                         MUIA_Text_PreParse,    "\33c",
  993.                                         MUIA_Background,    MUII_ButtonBack,
  994.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  995.                                     End,
  996.  
  997.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  998.                                         MUIA_Text_Contents,    "/",
  999.                                         MUIA_Text_PreParse,    "\33c",
  1000.                                         MUIA_Background,    MUII_ButtonBack,
  1001.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1002.                                     End,
  1003.  
  1004.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1005.                                         MUIA_Text_Contents,    "F",
  1006.                                         MUIA_Text_PreParse,    "\33c",
  1007.                                         MUIA_Background,    MUII_ButtonBack,
  1008.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1009.                                     End,
  1010.  
  1011.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1012.                                         MUIA_Text_Contents,    "\\",
  1013.                                         MUIA_Text_PreParse,    "\33c",
  1014.                                         MUIA_Background,    MUII_ButtonBack,
  1015.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1016.                                     End,
  1017.  
  1018.                         Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1019.                                             MUIA_Text_Contents,    "!",
  1020.                                             MUIA_Text_PreParse,    "\33c",
  1021.                                             MUIA_Background,    MUII_ButtonBack,
  1022.                                             MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1023.                                         End,
  1024.  
  1025.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1026.                                         MUIA_Text_Contents,    "4",
  1027.                                         MUIA_Text_PreParse,    "\33c",
  1028.                                         MUIA_Background,    MUII_ButtonBack,
  1029.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1030.                                     End,
  1031.  
  1032.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1033.                                         MUIA_Text_Contents,    "5",
  1034.                                         MUIA_Text_PreParse,    "\33c",
  1035.                                         MUIA_Background,    MUII_ButtonBack,
  1036.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1037.                                     End,
  1038.  
  1039.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1040.                                         MUIA_Text_Contents,    "6",
  1041.                                         MUIA_Text_PreParse,    "\33c",
  1042.                                         MUIA_Background,    MUII_ButtonBack,
  1043.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1044.                                     End,
  1045.  
  1046.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1047.                                         MUIA_Text_Contents,    "*",
  1048.                                         MUIA_Text_PreParse,    "\33c",
  1049.                                         MUIA_Background,    MUII_ButtonBack,
  1050.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1051.                                     End,
  1052.  
  1053.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1054.                                         MUIA_Text_Contents,    "X",
  1055.                                         MUIA_Text_PreParse,    "\33c",
  1056.                                         MUIA_Background,    MUII_ButtonBack,
  1057.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1058.                                     End,
  1059.  
  1060.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1061.                                         MUIA_Text_Contents,    "&",
  1062.                                         MUIA_Text_PreParse,    "\33c",
  1063.                                         MUIA_Background,    MUII_ButtonBack,
  1064.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1065.                                     End,
  1066.  
  1067.                         Child, ClrObj        =    TextObject, ButtonFrame,
  1068.                                             MUIA_Text_Contents,    "CLR",
  1069.                                             MUIA_Text_PreParse,    "\33c",
  1070.                                             MUIA_Background,    MUII_ButtonBack,
  1071.                                             MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1072.                                         End,
  1073.  
  1074.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1075.                                         MUIA_Text_Contents,    "1",
  1076.                                         MUIA_Text_PreParse,    "\33c",
  1077.                                         MUIA_Background,    MUII_ButtonBack,
  1078.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1079.                                     End,
  1080.  
  1081.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1082.                                         MUIA_Text_Contents,    "2",
  1083.                                         MUIA_Text_PreParse,    "\33c",
  1084.                                         MUIA_Background,    MUII_ButtonBack,
  1085.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1086.                                     End,
  1087.  
  1088.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1089.                                         MUIA_Text_Contents,    "3",
  1090.                                         MUIA_Text_PreParse,    "\33c",
  1091.                                         MUIA_Background,    MUII_ButtonBack,
  1092.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1093.                                     End,
  1094.  
  1095.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1096.                                         MUIA_Text_Contents,    "-",
  1097.                                         MUIA_Text_PreParse,    "\33c",
  1098.                                         MUIA_Background,    MUII_ButtonBack,
  1099.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1100.                                     End,
  1101.  
  1102.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1103.                                         MUIA_Text_Contents,    "Y",
  1104.                                         MUIA_Text_PreParse,    "\33c",
  1105.                                         MUIA_Background,    MUII_ButtonBack,
  1106.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1107.                                     End,
  1108.  
  1109.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1110.                                         MUIA_Text_Contents,    "(",
  1111.                                         MUIA_Text_PreParse,    "\33c",
  1112.                                         MUIA_Background,    MUII_ButtonBack,
  1113.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1114.                                     End,
  1115.  
  1116.                         Child, AllClrObj    =    TextObject, ButtonFrame,
  1117.                                             MUIA_Text_Contents,    "ACLR",
  1118.                                             MUIA_Text_PreParse,    "\33c",
  1119.                                             MUIA_Background,    MUII_ButtonBack,
  1120.                                             MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1121.                                         End,
  1122.  
  1123.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1124.                                         MUIA_Text_Contents,    "0",
  1125.                                         MUIA_Text_PreParse,    "\33c",
  1126.                                         MUIA_Background,    MUII_ButtonBack,
  1127.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1128.                                     End,
  1129.  
  1130.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1131.                                         MUIA_Text_Contents,    ".",
  1132.                                         MUIA_Text_PreParse,    "\33c",
  1133.                                         MUIA_Background,    MUII_ButtonBack,
  1134.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1135.                                     End,
  1136.  
  1137.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1138.                                         MUIA_Text_Contents,    "=",
  1139.                                         MUIA_Text_PreParse,    "\33c",
  1140.                                         MUIA_Background,    MUII_ButtonBack,
  1141.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1142.                                     End,
  1143.  
  1144.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1145.                                         MUIA_Text_Contents,    "+",
  1146.                                         MUIA_Text_PreParse,    "\33c",
  1147.                                         MUIA_Background,    MUII_ButtonBack,
  1148.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1149.                                     End,
  1150.  
  1151.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1152.                                         MUIA_Text_Contents,    "Z",
  1153.                                         MUIA_Text_PreParse,    "\33c",
  1154.                                         MUIA_Background,    MUII_ButtonBack,
  1155.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1156.                                     End,
  1157.  
  1158.                         Child, InGads[GadNum++]=    TextObject, ButtonFrame,
  1159.                                         MUIA_Text_Contents,    ")",
  1160.                                         MUIA_Text_PreParse,    "\33c",
  1161.                                         MUIA_Background,    MUII_ButtonBack,
  1162.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1163.                                     End,
  1164.  
  1165.                         Child, ExeObj        =    TextObject, ButtonFrame,
  1166.                                             MUIA_Text_Contents,    "Exec",
  1167.                                             MUIA_Text_PreParse,    "\33c",
  1168.                                             MUIA_Background,    MUII_ButtonBack,
  1169.                                             MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1170.                                         End,
  1171.                     End, // Input gadgets
  1172.                 End, // Third input area
  1173.             End, // VGroup
  1174.         End, // Main window
  1175.  
  1176.             // Now generate the Prefs window
  1177.  
  1178.         SubWindow, PrefsWindow = WindowObject,
  1179.                         MUIA_Window_Title,    "MUIProCalc Preferences",
  1180.                         MUIA_Window_ID,        'MPCP',
  1181.                         MUIA_Window_SizeGadget,    TRUE,
  1182.                         MUIA_Window_NoMenus,    TRUE,
  1183.                         MUIA_HelpNode,        NODE_PREFS,
  1184.  
  1185.             WindowContents, VGroup,
  1186.  
  1187.                 Child, ColGroup(2),
  1188.                     Child, VGroup, GroupFrameT("Window layout"),
  1189.                         MUIA_HelpNode,    NODE_LAYOUT,
  1190.  
  1191.                         Child, VSpace(0),
  1192.                         Child, HGroup,
  1193.  
  1194.                                 // Display functions gadget
  1195.  
  1196.                             Child, HGroup,
  1197.                                 Child, TextObject,
  1198.                                     MUIA_Text_PreParse,    "\033r",
  1199.                                     MUIA_Text_Contents,    "No Functions",
  1200.                                     MUIA_Text_HiChar,    'f',
  1201.                                 End,
  1202.                                 Child, HSpace(1),
  1203.                                 Child, DFuncObj    =    ImageObject, ImageButtonFrame,
  1204.                                                 MUIA_InputMode,        MUIV_InputMode_Toggle,
  1205.                                                 MUIA_Image_Spec,    MUII_CheckMark,
  1206.                                                 MUIA_Image_FreeVert,    TRUE,
  1207.                                                 MUIA_Selected,        NoFuncs,
  1208.                                                 MUIA_Background,    MUII_ButtonBack,
  1209.                                                 MUIA_ShowSelState,    FALSE,
  1210.                                                 MUIA_ControlChar,    'f',
  1211.                                                 MUIA_ExportID,        'FUNC',
  1212.                                             End,
  1213.                             End,
  1214.  
  1215.                                 // Display Inputs gadget
  1216.  
  1217.                             Child, HGroup,
  1218.                                 Child, TextObject,
  1219.                                     MUIA_Text_PreParse,    "\033r",
  1220.                                     MUIA_Text_Contents,    "No Input",
  1221.                                     MUIA_Text_HiChar,    'n',
  1222.                                 End,
  1223.                                 Child, HSpace(1),
  1224.                                 Child, DInObj    =    ImageObject, ImageButtonFrame,
  1225.                                                 MUIA_InputMode,        MUIV_InputMode_Toggle,
  1226.                                                 MUIA_Image_Spec,    MUII_CheckMark,
  1227.                                                 MUIA_Image_FreeVert,    TRUE,
  1228.                                                 MUIA_Selected,        NoInput,
  1229.                                                 MUIA_Background,    MUII_ButtonBack,
  1230.                                                 MUIA_ShowSelState,    FALSE,
  1231.                                                 MUIA_ControlChar,    'n',
  1232.                                                 MUIA_ExportID,        'INPU',
  1233.                                             End,
  1234.                             End,
  1235.                         End,
  1236.  
  1237.                             // Cycle Gadget for default type
  1238.  
  1239.                         Child, ColGroup(2),
  1240.                             Child, KeyLabel1("In/Out Order", 'O'),
  1241.                             Child, InOutObj    =    CycleObject, ButtonFrame,
  1242.                                             MUIA_Cycle_Active,    InOutLook,
  1243.                                             MUIA_Cycle_Entries,    InOutLookEntries,
  1244.                                             MUIA_ControlChar,    'o',
  1245.                                             MUIA_ExportID,        'ORDR',
  1246.                                         End,
  1247.                         End,
  1248.  
  1249.                         Child, VSpace(0),
  1250.  
  1251.                     End, // Layout gadgets
  1252.  
  1253.                     Child, VGroup, GroupFrameT("Output settings"),
  1254.                         MUIA_HelpNode,    NODE_OUTPUT,
  1255.  
  1256.                         Child, VSpace(0),
  1257.  
  1258.                             // Cycle Gadget for default type
  1259.  
  1260.                         Child, ColGroup(2),
  1261.                             Child, KeyLabel1("Base:", 'B'),
  1262.                             Child, TypeObj    =    CycleObject, ButtonFrame,
  1263.                                             MUIA_Cycle_Active,    IntType - ID_DECIMAL,
  1264.                                             MUIA_Cycle_Entries,    TypeEntries,
  1265.                                             MUIA_ControlChar,    'b',
  1266.                                             MUIA_ExportID,        'TYPE',
  1267.                                         End,
  1268.  
  1269.                             Child, KeyLabel1("Size:", 'z'),
  1270.                             Child, SizeObj    =    CycleObject, ButtonFrame,
  1271.                                             MUIA_Cycle_Active,    IntBase - ID_8BIT,
  1272.                                             MUIA_Cycle_Entries,    SizeEntries,
  1273.                                             MUIA_ControlChar,    'z',
  1274.                                             MUIA_ExportID,        'SIZE',
  1275.                                         End,
  1276.  
  1277.                             Child, KeyLabel1("Sign:", 'i'),
  1278.                             Child, SignObj    =    CycleObject, ButtonFrame,
  1279.                                             MUIA_Cycle_Active,    IntSign - ID_SIGNED,
  1280.                                             MUIA_Cycle_Entries,    SignEntries,
  1281.                                             MUIA_ControlChar,    'i',
  1282.                                             MUIA_ExportID,        'SIGN',
  1283.                                         End,
  1284.  
  1285.                             Child, KeyLabel1("Angle:", 'a'),
  1286.                             Child, AngleObj    =    CycleObject, ButtonFrame,
  1287.                                             MUIA_Cycle_Active,    IntAngle - ID_RAD,
  1288.                                             MUIA_Cycle_Entries,    AngleEntries,
  1289.                                             MUIA_ControlChar,    'a',
  1290.                                             MUIA_ExportID,        'ANGL',
  1291.                                         End,
  1292.                         End, // Cycle gadgets
  1293.  
  1294.                         Child, VSpace(0),
  1295.  
  1296.                     End, // Output settings
  1297.  
  1298.  
  1299.  
  1300.                     Child, VGroup, GroupFrameT("History settings"),
  1301.                         MUIA_HelpNode,    NODE_HISTORY,
  1302.  
  1303.                         Child, VSpace(0),
  1304.  
  1305.                             // Number of lines to buffer
  1306.  
  1307.                         Child, ColGroup(2),
  1308.                             Child, KeyLabel1("Lines:", 'L'),
  1309.                             Child, LinesObj    =    SliderObject,
  1310.                                             MUIA_Slider_Level,    HistLines,
  1311.                                             MUIA_Slider_Min,    1,
  1312.                                             MUIA_Slider_Max,    512,
  1313.                                             MUIA_ControlChar,    'l',
  1314.                                             MUIA_ExportID,        'LINE',
  1315.                                         End,
  1316.  
  1317.  
  1318.                             Child, KeyLabel1("Entries:", 'E'),
  1319.                             Child, LookObj    =    CycleObject, ButtonFrame,
  1320.                                             MUIA_Cycle_Active,    ListLook,
  1321.                                             MUIA_Cycle_Entries,    LookEntries,
  1322.                                             MUIA_ControlChar,    'e',
  1323.                                             MUIA_ExportID,        'LOOK',
  1324.                                         End,
  1325.                         End, // History col group
  1326.  
  1327.                         Child, VSpace(0),
  1328.  
  1329.                     End, // History settings
  1330.  
  1331.  
  1332.                     Child, VGroup, GroupFrameT("Misc"),
  1333.                         MUIA_HelpNode,    NODE_MISC,
  1334.  
  1335.                         Child, VSpace(0),
  1336.  
  1337.                             // Clear input checkbox
  1338.  
  1339.                         Child, HGroup,
  1340.                             Child, TextObject,
  1341.                                 MUIA_Text_PreParse,    "\033r",
  1342.                                 MUIA_Text_Contents,    "Clear input on exec",
  1343.                                 MUIA_Text_HiChar,    'r',
  1344.                             End,
  1345.                             Child, HSpace(1),
  1346.                             Child, ClearInObj =    ImageObject, ImageButtonFrame,
  1347.                                             MUIA_InputMode,        MUIV_InputMode_Toggle,
  1348.                                             MUIA_Image_Spec,    MUII_CheckMark,
  1349.                                             MUIA_Image_FreeVert,    TRUE,
  1350.                                             MUIA_Selected,        ClearInput,
  1351.                                             MUIA_Background,    MUII_ButtonBack,
  1352.                                             MUIA_ShowSelState,    FALSE,
  1353.                                             MUIA_ControlChar,    'r',
  1354.                                             MUIA_ExportID,        'CLRI',
  1355.                                         End,
  1356.                         End, // Clear checkbox
  1357.  
  1358.                             // Flush memory gadget
  1359.  
  1360.                         Child, HGroup,
  1361.                             Child, TextObject,
  1362.                                 MUIA_Text_PreParse,    "\033r",
  1363.                                 MUIA_Text_Contents,    "Flush memory",
  1364.                                 MUIA_Text_HiChar,    'm',
  1365.                             End,
  1366.                             Child, HSpace(1),
  1367.                             Child, FlushObj    =    ImageObject, ImageButtonFrame,
  1368.                                             MUIA_InputMode,        MUIV_InputMode_Toggle,
  1369.                                             MUIA_Image_Spec,    MUII_CheckMark,
  1370.                                             MUIA_Image_FreeVert,    TRUE,
  1371.                                             MUIA_Selected,        FlushOnExit,
  1372.                                             MUIA_Background,    MUII_ButtonBack,
  1373.                                             MUIA_ShowSelState,    FALSE,
  1374.                                             MUIA_ControlChar,    'm',
  1375.                                             MUIA_ExportID,        'FLUS',
  1376.                                         End,
  1377.                         End, // Flush CheckBox
  1378.  
  1379.  
  1380.                             // Number of clipboard to use
  1381.  
  1382.                         Child, ColGroup(2),
  1383.                             Child, KeyLabel1("ClipUnit:", 'P'),
  1384.                             Child, ClipObj    =    SliderObject,
  1385.                                             MUIA_Slider_Level,    ClipUnit,
  1386.                                             MUIA_Slider_Min,    0,
  1387.                                             MUIA_Slider_Max,    255,
  1388.                                             MUIA_ControlChar,    'p',
  1389.                                             MUIA_ExportID,        'CLIP',
  1390.                                         End,
  1391.                         End, // Clipboard group
  1392.  
  1393.                         Child, VSpace(0),
  1394.  
  1395.                     End, // Misc Group
  1396.                 End, // Horizontal Groups
  1397.  
  1398.                     // Ok, Cancel, Save gadgets
  1399.  
  1400.                 Child, VGroup, GroupFrame,
  1401.                     Child, ColGroup(3), MUIA_Group_SameWidth, TRUE,
  1402.  
  1403.                             // Save Gadget
  1404.  
  1405.                         Child, SaveObj    =    TextObject, ButtonFrame,
  1406.                                         MUIA_Background,    MUII_ButtonBack,
  1407.                                         MUIA_Text_PreParse,    "\33c",
  1408.                                         MUIA_Text_Contents,    "Save",
  1409.                                         MUIA_Text_HiChar,    'S',
  1410.                                         MUIA_ControlChar,    's',
  1411.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1412.                                     End,
  1413.  
  1414.                             // Use Gadget
  1415.  
  1416.                         Child, OkObj    =    TextObject, ButtonFrame,
  1417.                                         MUIA_Background,    MUII_ButtonBack,
  1418.                                         MUIA_Text_PreParse,    "\33c",
  1419.                                         MUIA_Text_Contents,    "Use",
  1420.                                         MUIA_Text_HiChar,    'U',
  1421.                                         MUIA_ControlChar,    'u',
  1422.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1423.                                     End,
  1424.  
  1425.                             // Cancel Gadget
  1426.  
  1427.                         Child, CancelObj =    TextObject, ButtonFrame,
  1428.                                         MUIA_Background,    MUII_ButtonBack,
  1429.                                         MUIA_Text_PreParse,    "\33c",
  1430.                                         MUIA_Text_Contents,    "Cancel",
  1431.                                         MUIA_Text_HiChar,    'C',
  1432.                                         MUIA_ControlChar,    'c',
  1433.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1434.                                     End,
  1435.                     End, // ColGroup
  1436.                 End, // Use - Cancel gadgets
  1437.             End, // Prefs window contents
  1438.         End, // Prefs window
  1439.     End; // Application
  1440.  
  1441.     if(AppObject && InputGroup && OutputGroup)
  1442.     {
  1443.             // Set cycle chain for Prefs window
  1444.  
  1445.         DoMethod(PrefsWindow, MUIM_Window_SetCycleChain,
  1446.             DFuncObj,
  1447.             DInObj,
  1448.             InOutObj,
  1449.             TypeObj,
  1450.             SizeObj,
  1451.             SignObj,
  1452.             AngleObj,
  1453.             LinesObj,
  1454.             LookObj,
  1455.             ClearInObj,
  1456.             FlushObj,
  1457.             ClipObj,
  1458.             OkObj,
  1459.             SaveObj,
  1460.             CancelObj,
  1461.         NULL);
  1462.  
  1463.             // Set stuff for main window
  1464.  
  1465.         DoMethod(MainWindow, MUIM_Notify,
  1466.             MUIA_Window_CloseRequest,    TRUE,
  1467.             AppObject,            2,
  1468.             MUIM_Application_ReturnID,    ID_QUIT);
  1469.  
  1470.             // Set default object for window
  1471.  
  1472.         set(MainWindow, MUIA_Window_DefaultObject, InputString);
  1473.  
  1474.             //
  1475.             // Do the Gadgets
  1476.             //
  1477.  
  1478.             // Set ID for String-Input
  1479.  
  1480.         DoMethod(InputString, MUIM_Notify,
  1481.             MUIA_String_Acknowledge,    MUIV_EveryTime,
  1482.             AppObject,            2,
  1483.             MUIM_Application_ReturnID,    ID_INPUT);
  1484.  
  1485.             // Attach Output box to StringGadget
  1486.  
  1487.         set(InputString, MUIA_String_AttachedList, OutputBox);
  1488.  
  1489.             // Let the Cycle-Gadget talk to the Page-Group
  1490.  
  1491.         DoMethod(FunctionCycle, MUIM_Notify,
  1492.             MUIA_Cycle_Active, MUIV_EveryTime,
  1493.             PageObject, 3,
  1494.             MUIM_Set, MUIA_Group_ActivePage, MUIV_TriggerValue);
  1495.  
  1496.             // Reactivate input gadget
  1497.  
  1498.         DoMethod(FunctionCycle, MUIM_Notify,
  1499.             MUIA_Cycle_Active, MUIV_EveryTime,
  1500.             MainWindow, 3,
  1501.             MUIM_Set, MUIA_Window_ActiveObject, InputString);
  1502.  
  1503.  
  1504.             // Set up control gadgets to call Hook
  1505.  
  1506.         for(GadNum = 0; GadNum < 61; GadNum++)
  1507.         {
  1508.                 // First call the Hook when released
  1509.  
  1510.             DoMethod(InGads[GadNum], MUIM_Notify,
  1511.                 MUIA_Pressed,        FALSE,
  1512.                 AppObject,        3,
  1513.                 MUIM_CallHook,        &InsertHook, InGads[GadNum]);
  1514.  
  1515.                 // The reactivate the string gadget
  1516.  
  1517.             DoMethod(InGads[GadNum], MUIM_Notify,
  1518.                 MUIA_Pressed,        FALSE,
  1519.                 MainWindow,        3,
  1520.                 MUIM_Set,        MUIA_Window_ActiveObject, InputString);
  1521.         }
  1522.  
  1523.  
  1524.             // Return ID for Exe gadget
  1525.  
  1526.         DoMethod(ExeObj, MUIM_Notify,
  1527.             MUIA_Pressed,            FALSE,
  1528.             AppObject,            2,
  1529.             MUIM_Application_ReturnID,    ID_EXEC);
  1530.  
  1531.             // Return ID for CLR gadget
  1532.  
  1533.         DoMethod(ClrObj, MUIM_Notify,
  1534.             MUIA_Pressed,            FALSE,
  1535.             AppObject,            2,
  1536.             MUIM_Application_ReturnID,    ID_CLEAR);
  1537.  
  1538.             // Return ID for ACLR gadget
  1539.  
  1540.         DoMethod(AllClrObj, MUIM_Notify,
  1541.             MUIA_Pressed,            FALSE,
  1542.             AppObject,            2,
  1543.             MUIM_Application_ReturnID,    ID_ALLCLEAR);
  1544.  
  1545.  
  1546.  
  1547.  
  1548.             // Do the Prefs window
  1549.  
  1550.         DoMethod(PrefsWindow, MUIM_Notify,
  1551.             MUIA_Window_CloseRequest,    TRUE,
  1552.             AppObject,            2,
  1553.             MUIM_Application_ReturnID,    ID_PREFS_QUIT);
  1554.  
  1555.  
  1556.             // On OK, first save the prefs to env:
  1557.  
  1558.         DoMethod(OkObj, MUIM_Notify,
  1559.             MUIA_Pressed,            FALSE,
  1560.             AppObject,            2,
  1561.             MUIM_Application_Save,        MUIV_Application_Save_ENV);
  1562.  
  1563.             // Then signal the main program, that new prefs are available
  1564.  
  1565.         DoMethod(OkObj, MUIM_Notify,
  1566.             MUIA_Pressed,            FALSE,
  1567.             AppObject,            2,
  1568.             MUIM_Application_ReturnID,    ID_PREFS_NEW);
  1569.  
  1570.  
  1571.  
  1572.  
  1573.             // On SAVE, save both to env: and envarc:
  1574.  
  1575.         DoMethod(SaveObj, MUIM_Notify,
  1576.             MUIA_Pressed,            FALSE,
  1577.             AppObject,            2,
  1578.             MUIM_Application_Save, MUIV_Application_Save_ENV);
  1579.  
  1580.         DoMethod(SaveObj, MUIM_Notify,
  1581.             MUIA_Pressed,            FALSE,
  1582.             AppObject,            2,
  1583.             MUIM_Application_Save, MUIV_Application_Save_ENVARC);
  1584.  
  1585.             // New prefs available
  1586.  
  1587.         DoMethod(SaveObj, MUIM_Notify,
  1588.             MUIA_Pressed,            FALSE,
  1589.             AppObject,            2,
  1590.             MUIM_Application_ReturnID,    ID_PREFS_NEW);
  1591.  
  1592.  
  1593.  
  1594.             // On Cancel, simply close the window
  1595.  
  1596.         DoMethod(CancelObj, MUIM_Notify,
  1597.             MUIA_Pressed,            FALSE,
  1598.             AppObject,            2,
  1599.             MUIM_Application_ReturnID,    ID_PREFS_QUIT);
  1600.  
  1601.  
  1602.  
  1603.  
  1604.  
  1605.             // Load the settings
  1606.  
  1607.         DoMethod(AppObject, MUIM_Application_Load, MUIV_Application_Load_ENV);
  1608.  
  1609.  
  1610.             // Load defaults into variables
  1611.  
  1612.         get(DFuncObj, MUIA_Selected, &Dummy);
  1613.         NoFuncs = Dummy;
  1614.  
  1615.         get(DInObj, MUIA_Selected, &Dummy);
  1616.         NoInput = Dummy;
  1617.  
  1618.         get(InOutObj, MUIA_Cycle_Active, &Dummy);
  1619.         InOutLook = Dummy;
  1620.  
  1621.         get(TypeObj, MUIA_Cycle_Active, &Dummy);
  1622.         IntType    = RXIntType     = Dummy + ID_DECIMAL;
  1623.  
  1624.         get(SizeObj, MUIA_Cycle_Active, &Dummy);
  1625.         IntBase    = RXIntBase    = Dummy + ID_8BIT;
  1626.  
  1627.         get(SignObj, MUIA_Cycle_Active, &Dummy);
  1628.         IntSign    = RXIntSign    = Dummy + ID_SIGNED;
  1629.  
  1630.         get(AngleObj, MUIA_Cycle_Active, &Dummy);
  1631.         IntAngle = RXIntAngle    = Dummy + ID_RAD;
  1632.  
  1633.         get(LinesObj, MUIA_Slider_Level, &Dummy);
  1634.         HistLines = Dummy;
  1635.  
  1636.         get(LookObj, MUIA_Cycle_Active, &Dummy);
  1637.         ListLook = Dummy;
  1638.  
  1639.         get(ClearInObj, MUIA_Selected, &Dummy);
  1640.         ClearInput = Dummy;
  1641.  
  1642.         get(FlushObj, MUIA_Selected, &Dummy);
  1643.         FlushOnExit = Dummy;
  1644.  
  1645.         get(ClipObj, MUIA_Slider_Level, &Dummy);
  1646.         ClipUnit = Dummy;
  1647.  
  1648.             // Add in/out gadgets in correct order
  1649.  
  1650.         if(!InOutLook)
  1651.         {
  1652.             DoMethod(InOutGroup, OM_ADDMEMBER, InputGroup);
  1653.             DoMethod(InOutGroup, OM_ADDMEMBER, OutputGroup);
  1654.         }
  1655.         else
  1656.         {
  1657.             DoMethod(InOutGroup, OM_ADDMEMBER, OutputGroup);
  1658.             DoMethod(InOutGroup, OM_ADDMEMBER, InputGroup);
  1659.         }
  1660.  
  1661.             // Set cycle chain for main window _AFTER_ String and ListView have been added
  1662.  
  1663.         SetMainWinCycle();
  1664.  
  1665.             // Set listview look
  1666.  
  1667.         set(OutputBox, MUIA_List_Format, LookTemplates[ListLook]);
  1668.  
  1669.  
  1670.             // Add/Remove groups as requested
  1671.  
  1672.         if(NoFuncs)
  1673.             DoMethod(MainGroup, OM_REMMEMBER, FuncGroup, TAG_DONE);
  1674.  
  1675.         if(NoInput)
  1676.             DoMethod(MainGroup, OM_REMMEMBER, InGroup, TAG_DONE);
  1677.  
  1678.  
  1679.  
  1680.             // Set InputString to default object
  1681.  
  1682.         set(MainWindow, MUIA_Window_DefaultObject, InputString);
  1683.  
  1684.  
  1685.             // Open the main window
  1686.  
  1687.         set(MainWindow, MUIA_Window_Open, TRUE);
  1688.  
  1689.             // Now set Checkmarks
  1690.  
  1691.         DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntType, TRUE);
  1692.         DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntBase, TRUE);
  1693.         DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntSign, TRUE);
  1694.         DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntAngle, TRUE);
  1695.     }
  1696.     else
  1697.     {
  1698.         if(InputGroup)
  1699.             MUI_DisposeObject(InputGroup);
  1700.  
  1701.         if(OutputGroup)
  1702.             MUI_DisposeObject(OutputGroup);
  1703.     }
  1704.  
  1705.     return((BOOL)(AppObject && InputGroup && OutputGroup));
  1706. }
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713. /**********************************************************************/
  1714. /*                    Close the main window again                     */
  1715. /**********************************************************************/
  1716. static void CloseMainWin(void)
  1717. {
  1718.         // Dispose all Objects
  1719.  
  1720.     if(AppObject)
  1721.     {
  1722.         set(MainWindow, MUIA_Window_Open, FALSE);
  1723.         MUI_DisposeObject(AppObject);
  1724.     }
  1725.  
  1726.         // Dispose DiskObject
  1727.  
  1728.     if(DObject)
  1729.         FreeDiskObject(DObject);
  1730. }
  1731.  
  1732.  
  1733.  
  1734.  
  1735.  
  1736.  
  1737.  
  1738. /**********************************************************************/
  1739. /*                      Format the output string                      */
  1740. /**********************************************************************/
  1741. BOOL FormatOutput(BOOL ReFormat)
  1742. {
  1743.     struct    ListStruct    NewEntry,
  1744.                 *NewEntryPtr;
  1745.     ULONG    ULong;
  1746.     BOOL    RetVal        = FALSE;
  1747.  
  1748.         // Set title of window first
  1749.  
  1750.     sprintf(Title, "MUIProCalc "REVISION" - "REVDATE" - %c%s%c %s", TypeChar[IntType - ID_DECIMAL], BaseStr[IntBase - ID_8BIT], SignChar[IntSign - ID_SIGNED], AngleStr[IntAngle - ID_RAD]);
  1751.     set(MainWindow, MUIA_Window_Title, Title);
  1752.  
  1753.         // Reformat entry ???
  1754.     if(!ReFormat)
  1755.     {
  1756.             // Get the Gadgets buffer
  1757.  
  1758.         get(InputString, MUIA_String_Contents, &ParseInput);
  1759.         strcpy(NewEntry.Input, ParseInput);
  1760.     }
  1761.     else
  1762.     {
  1763.         ULONG    NumEntries;
  1764.  
  1765.             // Get input from bottom entry within History
  1766.  
  1767.         get(OutputBox, MUIA_List_Entries, &NumEntries);
  1768.         DoMethod(OutputBox, MUIM_List_GetEntry, NumEntries - 1, &NewEntryPtr);
  1769.         NewEntry    = *NewEntryPtr;
  1770.         ParseInput    = NewEntry.Input;
  1771.     }
  1772.  
  1773.     if(strlen(ParseInput))
  1774.     {
  1775.             // Allocate memory pool for parsing
  1776.  
  1777.         if((ParsePool = DoCreatePool(MEMF_CLEAR, 8192, 2048)))
  1778.         {
  1779.                 // Reset scanner
  1780.  
  1781.             yychar            = -2;
  1782.             yynerrs            = 0;
  1783.             yy_init            = 1;
  1784.             yy_start        = 0;
  1785.             yyin = yyout        = NULL;
  1786.             yy_current_buffer    = NULL;
  1787.             ContainsUnDec        = FALSE;
  1788.  
  1789.                 // Do the parse
  1790.  
  1791.             yyparse();
  1792.  
  1793.                 // Delete pool again
  1794.  
  1795.             DoDeletePool(ParsePool);
  1796.  
  1797.             if(!yynerrs && !PError)
  1798.             {
  1799.                 RetVal    = TRUE;
  1800.  
  1801.                 switch(IntType)
  1802.                 {
  1803.                     case ID_DECIMAL :
  1804.                     {
  1805.                         if(!ContainsUnDec)
  1806.                         {
  1807.                             if((Value > 4294967295.0) || (Value < -4294967295.0) || ((Value < 1.0) && (Value > -1.0)))
  1808.                                 sprintf(NewEntry.Output, "%g ", Value);
  1809.                             else
  1810.                                 sprintf(NewEntry.Output, "%f ", Value);
  1811.                         }
  1812.                         else
  1813.                             sprintf(NewEntry.Output, "%f ", Value);
  1814.                         break;
  1815.                     }
  1816.  
  1817.                     case ID_HEXDECIMAL :
  1818.                     {
  1819.                         if((Value > 4294967295.0) || (Value < -4294967295.0))
  1820.                             strcpy(NewEntry.Output, "\0338Hex overflow");
  1821.                         else
  1822.                         {
  1823.                             sprintf(NewEntry.Output, "%f ", Value);
  1824.  
  1825.                                 // Now convert that output to a Long
  1826.  
  1827.                             stcd_l(NewEntry.Output, (LONG *)&ULong);
  1828.  
  1829.                                 // And reconvert it to hex output ;)
  1830.  
  1831.                             sprintf(NewEntry.Output, "$%x ", ULong);
  1832.                         }
  1833.                         break;
  1834.                     }
  1835.                     case ID_OCTAL :
  1836.                     {
  1837.                         if((Value > 4294967295.0) || (Value < -4294967295.0))
  1838.                             strcpy(NewEntry.Output, "\0338Octal overflow");
  1839.                         else
  1840.                         {
  1841.                             sprintf(NewEntry.Output, "%f ", Value);
  1842.  
  1843.                                 // First convert to Long
  1844.  
  1845.                             stcd_l(NewEntry.Output, (LONG *)&ULong);
  1846.  
  1847.                                 // Now conbert to octal
  1848.  
  1849.                             sprintf(NewEntry.Output, "\\%o ", ULong);
  1850.                         }
  1851.                         break;
  1852.                     }
  1853.                     case ID_BINARY :
  1854.                     {
  1855.                         char    AddOn[2];
  1856.                         int    i,
  1857.                             NumBits;
  1858.  
  1859.                         if((Value > 4294967295.0) || (Value < -4294967295.0))
  1860.                             strcpy(NewEntry.Output, "\0338Binary overflow");
  1861.                         else
  1862.                         {
  1863.                             sprintf(NewEntry.Output, "%f ", Value);
  1864.  
  1865.                             switch(IntBase)
  1866.                             {
  1867.                                 case ID_8BIT :
  1868.                                 {
  1869.                                     NumBits = 8;
  1870.                                     break;
  1871.                                 }
  1872.                                 case ID_16BIT :
  1873.                                 {
  1874.                                     NumBits = 16;
  1875.                                     break;
  1876.                                 }
  1877.                                 case ID_32BIT :
  1878.                                 {
  1879.                                     NumBits = 32;
  1880.                                     break;
  1881.                                 }
  1882.                             }
  1883.                                 // First convert to Long
  1884.  
  1885.                             stcd_l(NewEntry.Output, (LONG *)&ULong);
  1886.  
  1887.                                 // Set type identifier
  1888.  
  1889.                             strcpy(NewEntry.Output, "%");
  1890.  
  1891.                                 // Now convert to binary output
  1892.  
  1893.                             AddOn[1] = '\0';
  1894.                             for(i = NumBits - 1; i >= 0; i--)
  1895.                             {
  1896.                                 AddOn[0] = ((ULong & (1L << i)) ? (ULong & (1L << i)) - (1L << i) + '1' : '0');
  1897.                                 strcat(NewEntry.Output, AddOn);
  1898.  
  1899.                                     // 4 Bits done -> insert a space ;)
  1900.  
  1901.                                 if(!(i % 4))
  1902.                                     strcat(NewEntry.Output, " ");
  1903.                             }
  1904.                         }
  1905.                         break;
  1906.                     }
  1907.                 }
  1908.             }
  1909.             else
  1910.             {
  1911.                 if(PError == ERR_PARSE)
  1912.                     sprintf(NewEntry.Output, "\0338Syntax error in column %d", PColumn);
  1913.                 else if(PError == ERR_UNKNOWN_CHR)
  1914.                     sprintf(NewEntry.Output, "\0338Unknown char in column %d", PColumn);
  1915.                 else if(PError == ERR_DIVBY0)
  1916.                     sprintf(NewEntry.Output, "\0338Division by Zero in column %d", PColumn);
  1917.                 else
  1918.                     sprintf(NewEntry.Output, "\0338Overflow error in column %d", PColumn);
  1919.             }
  1920.  
  1921.                 // On "History-Overflow" remove top entry
  1922.  
  1923.             get(OutputBox, MUIA_List_Entries, &ULong);
  1924.             if(ULong > HistLines)
  1925.                 DoMethod(OutputBox, MUIM_List_Remove, MUIV_List_Remove_First);
  1926.  
  1927.             NewEntryPtr    = &NewEntry;
  1928.             DoMethod(OutputBox, MUIM_List_Insert, &NewEntryPtr, 1, MUIV_List_Insert_Bottom);
  1929.             set(OutputBox, MUIA_List_Active, MUIV_List_Active_Bottom);
  1930.  
  1931.             if(ClearInput)
  1932.                 set(InputString, MUIA_String_Contents, "");
  1933.         }
  1934.         else
  1935.             MUI_Request(AppObject, MainWindow, NULL, NULL, "*Ok", "Sorry, no memory for parsing");
  1936.     }
  1937.  
  1938.     set(MainWindow, MUIA_Window_ActiveObject, InputString);
  1939.  
  1940.     return(RetVal);
  1941. }
  1942.  
  1943.  
  1944.  
  1945.  
  1946.  
  1947.  
  1948.  
  1949. /**********************************************************************/
  1950. /*                  Insert Hook for function gadgets                  */
  1951. /**********************************************************************/
  1952. static ULONG    __saveds __asm InsertFunc(register __a0 struct Hook *MyHook, register __a2 APTR Obj, register __a1 APTR *Data)
  1953. {
  1954.     char    *Text;
  1955.  
  1956.         // Get Text of selected gadget
  1957.  
  1958.     get(*Data, MUIA_Text_Contents, &Text);
  1959.  
  1960.         // Insert text at cursor position
  1961.  
  1962.     InsertText(Text);
  1963.     return(0);
  1964. }
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971. /**********************************************************************/
  1972. /*        Hook-Function for generating a new entry for the LV         */
  1973. /**********************************************************************/
  1974. static ULONG    __saveds __asm DispConstructFunc(register __a0 struct Hook *MyHook, register __a2 APTR MemPool, register __a1 struct ListStruct *Data)
  1975. {
  1976.     struct    ListStruct    *New;
  1977.  
  1978.     if((New = AllocVec(sizeof(struct ListStruct), MEMF_CLEAR)))
  1979.     {
  1980.         *New    =    *Data;
  1981.         return((ULONG)New);
  1982.     }
  1983.  
  1984.     return(NULL);
  1985. }
  1986.  
  1987.  
  1988.  
  1989.  
  1990.  
  1991. /**********************************************************************/
  1992. /*         Hook-Function for removing a new entry from the LV         */
  1993. /**********************************************************************/
  1994. static ULONG    __saveds __asm DispDestructFunc(register __a0 struct Hook *MyHook, register __a2 APTR MemPool, register __a1 struct ListStruct *Data)
  1995. {
  1996.     FreeVec(Data);
  1997.     return(0);
  1998. }
  1999.  
  2000.  
  2001.  
  2002.  
  2003.  
  2004.  
  2005. /**********************************************************************/
  2006. /*                      Put pointers into array                       */
  2007. /**********************************************************************/
  2008. static ULONG    __saveds __asm DispViewFunc(register __a0 struct Hook *MyHook, register __a2 char **array, register __a1 struct ListStruct *Data)
  2009. {
  2010.     *array++    = Data->Input;
  2011.     *array        = Data->Output;
  2012.  
  2013.     return(NULL);
  2014. }
  2015.  
  2016.  
  2017.  
  2018.  
  2019.  
  2020.  
  2021. /**********************************************************************/
  2022. /*        Insert a text-string at the current cursor-position         */
  2023. /**********************************************************************/
  2024. static void InsertText(char *NewText)
  2025. {
  2026.     char    NewBuff[258],
  2027.         *Text;
  2028.     ULONG    CursorPos;
  2029.  
  2030.         // No Error ?!?
  2031.  
  2032.     if(strncmp(NewText, "\0338", 2))
  2033.     {
  2034.             // Get current cursor Position within Input-String
  2035.  
  2036.         get(InputString, MUIA_String_BufferPos, &CursorPos);
  2037.         get(InputString, MUIA_String_Contents, &Text);
  2038.  
  2039.             // Copy to buffer, because the string`s contents may not be
  2040.             // directly altered
  2041.  
  2042.         strcpy(NewBuff, Text);
  2043.  
  2044.  
  2045.             // insert to cursor position
  2046.  
  2047.         if((strlen(NewBuff) + strlen(NewText)) < 256)
  2048.             strins(&NewBuff[CursorPos], NewText);
  2049.         else
  2050.             DisplayBeep(NULL);
  2051.  
  2052.             // Set new string for String-Gadget
  2053.  
  2054.         set(InputString, MUIA_String_Contents, NewBuff);
  2055.     }
  2056.  
  2057.     set(MainWindow, MUIA_Window_ActiveObject, InputString);
  2058. }
  2059.  
  2060.  
  2061.  
  2062.  
  2063.  
  2064. /**********************************************************************/
  2065. /*          Write the given entry to the specified clipboard          */
  2066. /**********************************************************************/
  2067. static void WriteClip(char *Entry)
  2068. {
  2069.     struct    IFFHandle    *Handle;
  2070.     BOOL    Ok = FALSE;
  2071.  
  2072.         // Length > 0 ???
  2073.  
  2074.     if(strlen(Entry) && strncmp(Entry, "\0338", 2))
  2075.     {
  2076.             // Try to obtain an IFF Handle
  2077.  
  2078.         if((Handle = AllocIFF()))
  2079.         {
  2080.                 // Open needed clipboard unit
  2081.  
  2082.             if((Handle->iff_Stream = (ULONG)OpenClipboard(ClipUnit)))
  2083.             {
  2084.                 InitIFFasClip(Handle);
  2085.  
  2086.                     // Open Handle for write access
  2087.  
  2088.                 if(!OpenIFF(Handle, IFFF_WRITE))
  2089.                 {
  2090.                         // Push first chunk (FORM)
  2091.  
  2092.                     if(!PushChunk(Handle, ID_FTXT, ID_FORM, IFFSIZE_UNKNOWN))
  2093.                     {
  2094.                             // Push chars chunk
  2095.  
  2096.                         if(!PushChunk(Handle, 0, ID_CHRS, IFFSIZE_UNKNOWN))
  2097.                         {
  2098.                                 // Write data to clipboard
  2099.  
  2100.                             if(WriteChunkBytes(Handle, Entry, strlen(Entry)) == strlen(Entry))
  2101.                             {
  2102.                                     // Pop contents chunk
  2103.  
  2104.                                 if(!PopChunk(Handle))
  2105.                                     Ok = TRUE;
  2106.                             }
  2107.                         }
  2108.  
  2109.                             // Pop FORM chunk
  2110.  
  2111.                         if(Ok)
  2112.                             PopChunk(Handle);
  2113.                     }
  2114.  
  2115.                         // Close IFF Handle
  2116.  
  2117.                     CloseIFF(Handle);
  2118.                 }
  2119.  
  2120.                     // Close Clipboard again
  2121.  
  2122.                 CloseClipboard((struct ClipboardHandle *)Handle->iff_Stream);
  2123.             }
  2124.  
  2125.                 // Free IFF Handle
  2126.  
  2127.             FreeIFF(Handle);
  2128.         }
  2129.     }
  2130.  
  2131.     set(MainWindow, MUIA_Window_ActiveObject, InputString);
  2132. }
  2133.  
  2134.  
  2135.  
  2136.  
  2137.  
  2138.  
  2139. /**********************************************************************/
  2140. /*                This is the main controlling routine                */
  2141. /**********************************************************************/
  2142. static void HandleInputs(void)
  2143. {
  2144.     ULONG    MySig, ReturnID;
  2145.     BOOL    GoOn    = TRUE;
  2146.  
  2147.     while(GoOn)
  2148.     {
  2149.         switch(ReturnID = DoMethod(AppObject, MUIM_Application_Input, &MySig))
  2150.         {
  2151.                 // Input done ;)
  2152.  
  2153.             case ID_INPUT :
  2154.             {
  2155.                 FormatOutput(FALSE);
  2156.                 break;
  2157.             }
  2158.  
  2159.                 // Translate input
  2160.  
  2161.             case ID_EXEC :
  2162.             {
  2163.                 FormatOutput(FALSE);
  2164.                 break;
  2165.             }
  2166.  
  2167.                 // Clear input
  2168.  
  2169.             case ID_CLEAR :
  2170.             {
  2171.                 set(InputString, MUIA_String_Contents, "");
  2172.                 FormatOutput(FALSE);
  2173.                 break;
  2174.             }
  2175.  
  2176.                 // Clear input AND Memory
  2177.  
  2178.             case ID_ALLCLEAR :
  2179.             {
  2180.                 XMem = YMem = ZMem = 0.0;
  2181.                 set(InputString, MUIA_String_Contents, "");
  2182.                 FormatOutput(FALSE);
  2183.                 break;
  2184.             }
  2185.  
  2186.                 // Open Prefs window
  2187.  
  2188.             case ID_PREFS :
  2189.             {
  2190.                 set(PrefsWindow, MUIA_Window_Open, TRUE);
  2191.                 break;
  2192.             }
  2193.  
  2194.                 // Display About
  2195.  
  2196.             case ID_ABOUT :
  2197.             {
  2198.                 MUI_Request(AppObject, MainWindow, 0, NULL, "*Okay",
  2199.                     "\033cMUIProCalc v%ld.%ld, written by Kai Iske, GiftWare\n\n"
  2200.                     "\0338Powerful calculator, also suited for programmers\n\n"
  2201.                     "\033l\0332To contact me, write to:\n\033c"
  2202.                     "Kai Iske, Brucknerstrasse 18, 63452 Hanau, Germany\n"
  2203.                     "Tel.: +49-(0)6181-850181\n\n"
  2204.                     "\033lor use electronical mail\n\033c"
  2205.                     "kai@iske.adsp.sub.org\n"
  2206.                     "iske@informatik.uni-frankfurt.de\n"
  2207.                     "Kai Iske, 2:244/6302.11\n"
  2208.                     "KAI@SWEET.RHEIN.MAIN.DE\n\n"
  2209.                     "\033c\0332MUIProCalc is a MUI-Application\n"
  2210.                     "MUI is © Stefan Stuntz",
  2211.                     VERNUM, REVNUM, TAG_DONE);
  2212.                 set(MainWindow, MUIA_Window_ActiveObject, InputString);
  2213.                 break;
  2214.             }
  2215.                 // Quit the program
  2216.  
  2217.             case ID_QUIT :
  2218.             case MUIV_Application_ReturnID_Quit :
  2219.             {
  2220.                 set(PrefsWindow, MUIA_Window_Open, FALSE);
  2221.                 GoOn = FALSE;
  2222.                 break;
  2223.             }
  2224.  
  2225.                 // Pick left entry from History ???
  2226.  
  2227.             case ID_PICKLEFT :
  2228.             {
  2229.                 struct    ListStruct    *LSV;
  2230.                 ULONG    ClickCol;
  2231.  
  2232.                 DoMethod(OutputBox, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &LSV);
  2233.  
  2234.                 if(LSV)
  2235.                 {
  2236.                     if(ListLook == 0 || ListLook == 2)
  2237.                         ClickCol = 0;
  2238.                     else if(ListLook == 1 || ListLook == 3)
  2239.                         ClickCol = 1;
  2240.  
  2241.                     if(!ClickCol)
  2242.                         InsertText(LSV->Input);
  2243.                     else
  2244.                         InsertText(LSV->Output);
  2245.                 }
  2246.                 break;
  2247.             }
  2248.  
  2249.                 // Pick right entry from History ???
  2250.  
  2251.             case ID_PICKRIGHT :
  2252.             {
  2253.                 struct    ListStruct    *LSV;
  2254.                 ULONG    ClickCol;
  2255.  
  2256.                 DoMethod(OutputBox, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &LSV);
  2257.  
  2258.                 if(LSV)
  2259.                 {
  2260.                     if(ListLook == 0 || ListLook == 3)
  2261.                         ClickCol = 1;
  2262.                     else if(ListLook == 1 || ListLook == 2)
  2263.                         ClickCol = 0;
  2264.  
  2265.                     if(!ClickCol)
  2266.                         InsertText(LSV->Input);
  2267.                     else
  2268.                         InsertText(LSV->Output);
  2269.                 }
  2270.                 break;
  2271.             }
  2272.  
  2273.                 // Copy left history entry to clipboard
  2274.  
  2275.             case ID_CLIPCUTLEFT :
  2276.             {
  2277.                 struct    ListStruct    *LSV;
  2278.                 ULONG    ClickCol;
  2279.  
  2280.                 DoMethod(OutputBox, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &LSV);
  2281.  
  2282.                 if(LSV)
  2283.                 {
  2284.                     if(ListLook == 0 || ListLook == 2)
  2285.                         ClickCol = 0;
  2286.                     else if(ListLook == 1 || ListLook == 3)
  2287.                         ClickCol = 1;
  2288.  
  2289.                     if(!ClickCol)
  2290.                         WriteClip(LSV->Input);
  2291.                     else
  2292.                         WriteClip(LSV->Output);
  2293.                 }
  2294.  
  2295.                 break;
  2296.             }
  2297.  
  2298.                 // Copy left history entry to clipboard
  2299.  
  2300.             case ID_CLIPCUTRIGHT :
  2301.             {
  2302.                 struct    ListStruct    *LSV;
  2303.                 ULONG    ClickCol;
  2304.  
  2305.                 DoMethod(OutputBox, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &LSV);
  2306.  
  2307.                 if(LSV)
  2308.                 {
  2309.                     if(ListLook == 0 || ListLook == 3)
  2310.                         ClickCol = 1;
  2311.                     else if(ListLook == 1 || ListLook == 2)
  2312.                         ClickCol = 0;
  2313.  
  2314.                     if(!ClickCol)
  2315.                         WriteClip(LSV->Input);
  2316.                     else
  2317.                         WriteClip(LSV->Output);
  2318.                 }
  2319.  
  2320.                 break;
  2321.             }
  2322.  
  2323.                 // Check Output Type
  2324.  
  2325.             case ID_DECIMAL :
  2326.             case ID_HEXDECIMAL :
  2327.             case ID_OCTAL :
  2328.             case ID_BINARY :
  2329.             {
  2330.                 DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntType, FALSE);
  2331.                 IntType    = ReturnID;
  2332.                 DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntType, TRUE);
  2333.                 FormatOutput(TRUE);
  2334.                 break;
  2335.             }
  2336.  
  2337.                 // Check for Bases
  2338.  
  2339.             case ID_8BIT :
  2340.             case ID_16BIT :
  2341.             case ID_32BIT :
  2342.             {
  2343.                 DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntBase, FALSE);
  2344.                 IntBase    = ReturnID;
  2345.                 DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntBase, TRUE);
  2346.                 FormatOutput(TRUE);
  2347.                 break;
  2348.             }
  2349.  
  2350.                 // Check for Signs
  2351.  
  2352.             case ID_SIGNED :
  2353.             case ID_UNSIGNED :
  2354.             {
  2355.                 DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntSign, FALSE);
  2356.                 IntSign    = ReturnID;
  2357.                 DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntSign, TRUE);
  2358.                 FormatOutput(TRUE);
  2359.                 break;
  2360.             }
  2361.  
  2362.                 // Check angle
  2363.  
  2364.             case ID_RAD :
  2365.             case ID_DEG :
  2366.             {
  2367.                 DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntAngle, FALSE);
  2368.                 IntAngle    = ReturnID;
  2369.                 DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntAngle, TRUE);
  2370.                 FormatOutput(TRUE);
  2371.                 break;
  2372.             }
  2373.  
  2374.  
  2375.  
  2376.  
  2377.                 //
  2378.                 // This is for the Prefs window
  2379.                 //
  2380.  
  2381.                 // Close prefs window
  2382.  
  2383.             case ID_PREFS_QUIT :
  2384.             {
  2385.                 set(PrefsWindow, MUIA_Window_Open, FALSE);
  2386.                 set(MainWindow, MUIA_Window_ActiveObject, InputString);
  2387.  
  2388.                     // Reset preferences
  2389.  
  2390.                 set(InOutObj, MUIA_Cycle_Active, InOutLook);
  2391.                 set(DFuncObj, MUIA_Selected, NoFuncs);
  2392.                 set(DInObj, MUIA_Selected, NoInput);
  2393.                 set(TypeObj, MUIA_Cycle_Active, (ULONG)IntType);
  2394.                 set(SizeObj, MUIA_Cycle_Active, (ULONG)IntBase);
  2395.                 set(SignObj, MUIA_Cycle_Active, (ULONG)IntSign);
  2396.                 set(AngleObj, MUIA_Cycle_Active, (ULONG)IntAngle);
  2397.                 set(LinesObj, MUIA_Slider_Level, (ULONG)HistLines);
  2398.                 set(LookObj, MUIA_Cycle_Active, (ULONG)ListLook);
  2399.                 set(ClearInObj, MUIA_Selected, (ULONG)ClearInput);
  2400.                 set(FlushObj, MUIA_Selected, (ULONG)FlushOnExit);
  2401.                 set(ClipObj, MUIA_Slider_Level, (ULONG)ClipUnit);
  2402.                 break;
  2403.             }
  2404.  
  2405.             case ID_PREFS_NEW :
  2406.             {
  2407.                 ULONG    NewInOut, NewFunc, NewInput, NewLook;
  2408.  
  2409.                     // Get clear flag
  2410.  
  2411.                 get(ClearInObj, MUIA_Selected, &NewFunc);
  2412.                 ClearInput = NewFunc;
  2413.  
  2414.                     // Get flush flag
  2415.  
  2416.                 get(FlushObj, MUIA_Selected, &NewFunc);
  2417.                 FlushOnExit = NewFunc;
  2418.  
  2419.                     // Get ClipBoard unit
  2420.  
  2421.                 get(ClipObj, MUIA_Slider_Level, &NewFunc);
  2422.                 ClipUnit = NewFunc;
  2423.  
  2424.                 set(PrefsWindow, MUIA_Window_Open, FALSE);
  2425.                 get(LinesObj, MUIA_Slider_Level, &NewFunc);
  2426.                 HistLines = NewFunc;
  2427.  
  2428.                     // Rebuild History
  2429.  
  2430.                 get(OutputBox, MUIA_List_Entries, &NewInput);
  2431.                 while(NewInput > HistLines)
  2432.                 {
  2433.                     DoMethod(OutputBox, MUIM_List_Remove, MUIV_List_Remove_First);
  2434.                     NewInput--;
  2435.                 }
  2436.  
  2437.                     // Check for changes on layout
  2438.  
  2439.                 get(InOutObj, MUIA_Cycle_Active, &NewInOut);
  2440.                 get(DFuncObj, MUIA_Selected, &NewFunc);
  2441.                 get(DInObj, MUIA_Selected, &NewInput);
  2442.                 get(LookObj, MUIA_Cycle_Active, &NewLook);
  2443.  
  2444.                 if((NewInOut != InOutLook) || (NewFunc != NoFuncs) || (NewInput != NoInput))
  2445.                 {
  2446.                         // Close main window first
  2447.  
  2448.                     set(MainWindow, MUIA_Window_Open, FALSE);
  2449.  
  2450.                         // Rearrange input output order
  2451.  
  2452.                     if(NewInOut != InOutLook)
  2453.                     {
  2454.                         InOutLook = NewInOut;
  2455.  
  2456.                             // Remove groups first
  2457.  
  2458.                         DoMethod(InOutGroup, OM_REMMEMBER, InputGroup);
  2459.                         DoMethod(InOutGroup, OM_REMMEMBER, OutputGroup);
  2460.  
  2461.                             // Readd groups
  2462.  
  2463.                         if(!InOutLook)
  2464.                         {
  2465.                             DoMethod(InOutGroup, OM_ADDMEMBER, InputGroup);
  2466.                             DoMethod(InOutGroup, OM_ADDMEMBER, OutputGroup);
  2467.                         }
  2468.                         else
  2469.                         {
  2470.                             DoMethod(InOutGroup, OM_ADDMEMBER, OutputGroup);
  2471.                             DoMethod(InOutGroup, OM_ADDMEMBER, InputGroup);
  2472.                         }
  2473.  
  2474.                             // Reset cycle order
  2475.  
  2476.                         SetMainWinCycle();
  2477.                     }
  2478.  
  2479.                         // First remove existent groups from main group
  2480.  
  2481.                     if(!NoFuncs)
  2482.                         DoMethod(MainGroup, OM_REMMEMBER, FuncGroup);
  2483.  
  2484.                     if(!NoInput)
  2485.                         DoMethod(MainGroup, OM_REMMEMBER, InGroup);
  2486.  
  2487.                         // Add Function group when needed
  2488.  
  2489.                     NoFuncs = NewFunc;
  2490.                     if(!NoFuncs)
  2491.                         DoMethod(MainGroup, OM_ADDMEMBER, FuncGroup);
  2492.  
  2493.                         // Add Input group when needed
  2494.  
  2495.                     NoInput = NewInput;
  2496.                     if(!NoInput)
  2497.                         DoMethod(MainGroup, OM_ADDMEMBER, InGroup);
  2498.  
  2499.  
  2500.                         // Reopen window
  2501.  
  2502.                     set(MainWindow, MUIA_Window_Open, TRUE);
  2503.                 }
  2504.  
  2505.                 if(NewLook != ListLook)
  2506.                 {
  2507.                             // Set listview look
  2508.  
  2509.                     ListLook = NewLook;
  2510.                     set(OutputBox, MUIA_List_Format, LookTemplates[ListLook]);
  2511.                 }
  2512.  
  2513.                 set(MainWindow, MUIA_Window_Activate, TRUE);
  2514.                 set(MainWindow, MUIA_Window_ActiveObject, InputString);
  2515.                 break;
  2516.             }
  2517.         }
  2518.  
  2519.         if(GoOn && MySig)
  2520.             Wait(MySig);
  2521.     }
  2522. }
  2523.