home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / util / misc / mcalc / source / mcalc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-21  |  93.3 KB  |  3,603 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 StdDestructFunc(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 ULONG    __saveds __asm HistoryConstructFunc(register __a0 struct Hook *MyHook, register __a2 char **array, register __a1 struct DoubleNode *Data);
  80. static ULONG    __saveds __asm DeviationDispFunc(register __a0 struct Hook *MyHook, register __a2 char **array, register __a1 struct DoubleNode *Data);
  81. static ULONG    __saveds __asm RegressionDispFunc(register __a0 struct Hook *MyHook, register __a2 char **array, register __a1 struct DoubleNode *Data);
  82. static ULONG    __saveds __asm ConstConstructFunc(register __a0 struct Hook *MyHook, register __a2 char **array, register __a1 struct ConstNode *Data);
  83. static ULONG    __saveds __asm ConstDispFunc(register __a0 struct Hook *MyHook, register __a2 char **array, register __a1 struct ConstNode *Data);
  84. static LONG    __saveds __asm ConstCompFunc(register __a1 struct ConstNode *Data1, register __a2 struct ConstNode *Data2);
  85. static void InsertText(char *NewText);
  86. static void WriteClip(char *Entry);
  87. static void HandleInputs(void);
  88.  
  89.  
  90.  
  91.  
  92. /**********************************************************************/
  93. /*                           Library-Bases                            */
  94. /**********************************************************************/
  95. extern    struct ExecBase    *SysBase;
  96.  
  97. struct    IntuitionBase    *IntuitionBase        = NULL;
  98. struct    GfxBase        *GfxBase        = NULL;
  99. struct    Library        *UtilityBase        = NULL;
  100. struct    Library        *IconBase        = NULL;
  101. struct    Library        *MUIMasterBase        = NULL;
  102. struct    Library        *MathIeeeDoubBasBase    = NULL;
  103. struct    Library        *MathIeeeDoubTransBase    = NULL;
  104. struct    Library        *IFFParseBase        = NULL;
  105.  
  106.  
  107.  
  108.  
  109. /**********************************************************************/
  110. /*                            The Objects                             */
  111. /**********************************************************************/
  112. static    struct    DiskObject    *DObject    = NULL;
  113. APTR        AppObject            = NULL;        // Is referenced through ARexx module
  114. static    APTR    MainWindow;
  115. static    APTR    InOutGroup;
  116. static    APTR    InputGroup;
  117. APTR        InputString;                    // Is referenced through ARexx module
  118. static    APTR    OutputGroup;
  119. APTR        OutputBox;                    // Is referenced through ARexx module
  120. static    APTR    InGads[116];
  121. static    APTR    ExeObj;
  122. static    APTR    ClrObj;
  123. static    APTR    AllClrObj;
  124.  
  125. static    APTR    MainGroup;
  126. static    APTR    FuncGroup;
  127. static    APTR    InGroup;
  128.  
  129. static    APTR    PrefsWindow;
  130. static    APTR    InOutObj;
  131. static    APTR    DFuncObj;
  132. static    APTR    DInObj;
  133. static    APTR    TypeObj;
  134. static    APTR    SizeObj;
  135. static    APTR    SignObj;
  136. static    APTR    AngleObj;
  137. static    APTR    LinesObj;
  138. static    APTR    LookObj;
  139. static    APTR    ClearInObj;
  140. static    APTR    FlushObj;
  141. static    APTR    StdWinObj;
  142. static    APTR    LinWinObj;
  143. static    APTR    ConstWinObj;
  144. static    APTR    ClipObj;
  145. static    APTR    OkObj;
  146. static    APTR    SaveObj;
  147. static    APTR    CancelObj;
  148.  
  149. static    APTR    StdHistoryWindow;
  150. static    APTR    StdHistoryObj;
  151.  
  152. static    APTR    LinHistoryWindow;
  153. static    APTR    LinHistoryObj;
  154.  
  155. static    APTR    ConstantsWindow;
  156. static    APTR    ConstantsObj;
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163. /**********************************************************************/
  164. /*                 Strings for Functions Cycle-Gadget                 */
  165. /**********************************************************************/
  166. static const char *FunctionEntries[] =
  167. {
  168.     "Math",
  169.     "Programmer",
  170.     "Memory",
  171.     "Std. deviation",
  172.     "Lin. regression",
  173.     NULL
  174. };
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181. /**********************************************************************/
  182. /*                      Strings for Prefs-Cycles                      */
  183. /**********************************************************************/
  184. static const char *InOutLookEntries[] =
  185. {
  186.     "Input then Output",
  187.     "Output then Input",
  188.     NULL
  189. };
  190.  
  191. static const char *TypeEntries[] =
  192. {
  193.     "Decimal",
  194.     "HexDecimal",
  195.     "Octal",
  196.     "Binary",
  197.     NULL
  198. };
  199.  
  200. static const char *SizeEntries[] =
  201. {
  202.     "8-Bit",
  203.     "16-Bit",
  204.     "32-Bit",
  205.     NULL
  206. };
  207.  
  208. static const char *SignEntries[] =
  209. {
  210.     "Signed",
  211.     "Unsigned",
  212.     NULL
  213. };
  214.  
  215. static const char *AngleEntries[] =
  216. {
  217.     "Radians",
  218.     "Degree",
  219.     "Grads",
  220.     NULL
  221. };
  222.  
  223. static const char *LookEntries[] =
  224. {
  225.     "Input & Output",
  226.     "Output & Input",
  227.     "Input",
  228.     "Output",
  229.     NULL
  230. };
  231.  
  232.  
  233. static const char *LookTemplates[] =
  234. {
  235.     "COL=0 DELTA=12 P=\033r MAW=100 MIW=0, COL=1 DELTA=12 P=\033r MAW=-1 MIW=-1",
  236.     "COL=1 DELTA=12 P=\033r MAW=-1 MIW=-1, COL=0 DELTA=12 P=\033r MAW=100 MIW=0",
  237.     "COL=0 DELTA=12 P=\033r MIW=100",
  238.     "COL=1 DELTA=12 P=\033r MIW=100"
  239. };
  240.  
  241.  
  242.  
  243. /**********************************************************************/
  244. /*                   Chars/String for window title                    */
  245. /**********************************************************************/
  246. static const char TypeChar[] =
  247. {
  248.     'D',
  249.     'H',
  250.     'O',
  251.     'B'
  252. };
  253.  
  254. static const char *BaseStr[] =
  255. {
  256.     "8",
  257.     "16",
  258.     "32"
  259. };
  260.  
  261.  
  262. static const char SignChar[] =
  263. {
  264.     'S',
  265.     'U',
  266. };
  267.  
  268.  
  269. static const char *AngleStr[] =
  270. {
  271.     "RAD",
  272.     "DEG",
  273.     "GRA"
  274. };
  275.  
  276.  
  277.  
  278.  
  279. /**********************************************************************/
  280. /*                          Menu-Definition                           */
  281. /**********************************************************************/
  282. static struct    NewMenu MainMenuDef[] =
  283. {
  284.     NM_TITLE, "Project", NULL, 0, NULL, NULL,
  285.     NM_ITEM, "Preferences...", "P", 0, NULL, (APTR)ID_PREFS,
  286.     NM_ITEM, NM_BARLABEL, NULL, 0, NULL, NULL,
  287.     NM_ITEM, "About...", "?", 0, NULL, (APTR)ID_ABOUT,
  288.     NM_ITEM, NM_BARLABEL, NULL, 0, NULL, NULL,
  289.     NM_ITEM, "Quit", "Q", 0, NULL, (APTR)ID_QUIT,
  290.  
  291.     NM_TITLE, "Edit", NULL, 0, NULL, NULL,
  292.     NM_ITEM, "Clear", "X", 0, NULL, (APTR)ID_CLEAR,
  293.     NM_ITEM, "All Clear", "Y", 0, NULL, (APTR)ID_ALLCLEAR,
  294.  
  295.     NM_TITLE, "History", NULL, 0, NULL, NULL,
  296.     NM_ITEM, "Pick left entry", "L", 0, NULL, (APTR)ID_PICKLEFT,
  297.     NM_ITEM, "Pick right entry", "R", 0, NULL, (APTR)ID_PICKRIGHT,
  298.     NM_ITEM, NM_BARLABEL, NULL, 0, NULL, NULL,
  299.     NM_ITEM, "Copy left entry", "F", 0, NULL, (APTR)ID_CLIPCUTLEFT,
  300.     NM_ITEM, "Copy right entry", "C", 0, NULL, (APTR)ID_CLIPCUTRIGHT,
  301.     NM_ITEM, NM_BARLABEL, NULL, 0, NULL, NULL,
  302.     NM_ITEM, "Delete entry", "K", 0, NULL, (APTR)ID_DELHISTORY,
  303.  
  304.     NM_TITLE, "Display Bases", NULL, 0, NULL, NULL,
  305.     NM_ITEM, "Decimal", "D", CHECKIT|MENUTOGGLE, 14, (APTR)ID_DECIMAL,
  306.     NM_ITEM, "Hexadecimal", "H", CHECKIT|MENUTOGGLE, 13, (APTR)ID_HEXDECIMAL,
  307.     NM_ITEM, "Octal", "O", CHECKIT|MENUTOGGLE, 11, (APTR)ID_OCTAL,
  308.     NM_ITEM, "Binary", "B", CHECKIT|MENUTOGGLE, 7, (APTR)ID_BINARY,
  309.  
  310.     NM_TITLE, "Size", NULL, 0, NULL, NULL,
  311.     NM_ITEM, "8 Bit", "8", CHECKIT|MENUTOGGLE, 6, (APTR)ID_8BIT,
  312.     NM_ITEM, "16 Bit", "16", CHECKIT|MENUTOGGLE, 5, (APTR)ID_16BIT,
  313.     NM_ITEM, "32 Bit", "32", CHECKIT|MENUTOGGLE, 3, (APTR)ID_32BIT,
  314.  
  315.     NM_TITLE, "Sign", NULL, 0, NULL, NULL,
  316.     NM_ITEM, "Signed", "S", CHECKIT|MENUTOGGLE, 2, (APTR)ID_SIGNED,
  317.     NM_ITEM, "Unsigned", "U", CHECKIT|MENUTOGGLE, 1, (APTR)ID_UNSIGNED,
  318.  
  319.     NM_TITLE, "Angle", NULL, 0, NULL, NULL,
  320.     NM_ITEM, "Radians", "A", CHECKIT|MENUTOGGLE, 6, (APTR)ID_RAD,
  321.     NM_ITEM, "Degree", "E", CHECKIT|MENUTOGGLE, 5, (APTR)ID_DEG,
  322.     NM_ITEM, "Grads", "G", CHECKIT|MENUTOGGLE, 3, (APTR)ID_GRAD,
  323.  
  324.     NM_TITLE, "Windows", NULL, 0, NULL, NULL,
  325.     NM_ITEM, "Std.Deviation", "T", 0, 0, (APTR)ID_STDHISTORY,
  326.     NM_ITEM, "Lin.Regression", "I", 0, 0, (APTR)ID_LINHISTORY,
  327.     NM_ITEM, "Constants", "N", 0, 0, (APTR)ID_CONSTANTS,
  328.  
  329.     NM_END, NULL, NULL, 0, NULL, NULL
  330. };
  331.  
  332.  
  333.  
  334.  
  335.  
  336. /**********************************************************************/
  337. /*                       Some global Variables                        */
  338. /**********************************************************************/
  339. static struct    Hook    InsertHook =             // This is our hook for the InputGadgets
  340. {
  341.     {NULL},
  342.     (APTR)InsertFunc,
  343.     NULL,
  344.     NULL
  345. };
  346.  
  347.  
  348. static struct    Hook    DispConstructHook =        // Hooks for multi-column display
  349. {
  350.     {NULL},
  351.     (APTR)DispConstructFunc,
  352.     NULL,
  353.     NULL
  354. };
  355.  
  356. static struct Hook    StdDestructHook =
  357. {
  358.     {NULL},
  359.     (APTR)StdDestructFunc,
  360.     NULL,
  361.     NULL
  362. };
  363.  
  364. static struct Hook    DispViewHook =
  365. {
  366.     {NULL},
  367.     (APTR)DispViewFunc,
  368.     NULL,
  369.     NULL
  370. };
  371.  
  372. static struct    Hook    HistoryConstructHook =
  373. {
  374.     {NULL},
  375.     (APTR)HistoryConstructFunc,
  376.     NULL,
  377.     NULL
  378. };
  379.  
  380. static struct Hook    DeviationDispHook =
  381. {
  382.     {NULL},
  383.     (APTR)DeviationDispFunc,
  384.     NULL,
  385.     NULL
  386. };
  387.  
  388. static struct Hook    RegressionDispHook =
  389. {
  390.     {NULL},
  391.     (APTR)RegressionDispFunc,
  392.     NULL,
  393.     NULL
  394. };
  395.  
  396. static struct    Hook    ConstConstructHook =
  397. {
  398.     {NULL},
  399.     (APTR)ConstConstructFunc,
  400.     NULL,
  401.     NULL
  402. };
  403.  
  404. static struct Hook    ConstDispHook =
  405. {
  406.     {NULL},
  407.     (APTR)ConstDispFunc,
  408.     NULL,
  409.     NULL
  410. };
  411.  
  412. static struct Hook    ConstCompHook =
  413. {
  414.     {NULL},
  415.     (APTR)ConstCompFunc,
  416.     NULL,
  417.     NULL
  418. };
  419.  
  420.  
  421.  
  422.  
  423. /**********************************************************************/
  424. /*                        Constant definitions                        */
  425. /**********************************************************************/
  426. static    char    *ConstNames[] =
  427. {
  428.     "rest mass of proton",
  429.     "Faraday constant",
  430.     "Bohr radius",
  431.     "speed of light",
  432.     "Planck constant",
  433.     "gravitational constant",
  434.     "elementary charge",
  435.     "rest mass of electron",
  436.     "atomic mass unit",
  437.     "Avogadro constant",
  438.     "Boltzmann constant",
  439.     "molar volume",
  440.     "acceleration of free fall",
  441.     "molar gas constant",
  442.     "permittivity of vacuum",
  443.     "permeability of vacuum",
  444.     "m. moment of proton",
  445.     "m. moment of electron",
  446.     "nuclear magneton",
  447.     "Bohr magneton",
  448.     "h/2 pi",
  449.     "fine-structure constant",
  450.     "electron radius",
  451.     "rest mass of neutron",
  452.     "gyromagnetic coefficient p",
  453.     "Compton wavelenght p",
  454.     "Compton wavelength n",
  455.     "Rydberg constant",
  456.     "first radiation constant",
  457.     "second radiation constant",
  458.     "Stefan Boltzmann constant",
  459.     "fluxoid quantum"
  460. };
  461.  
  462. static    char    *ConstValues[] =
  463. {
  464.     "1.6726485e-27",
  465.     "9.648456e4",
  466.     "5.2917706e-11",
  467.     "299792458",
  468.     "6.626176e-34",
  469.     "6.672e-11",
  470.     "1.6021892e-19",
  471.     "9.109534e-31",
  472.     "1.6605655e-27",
  473.     "6.022045e23",
  474.     "1.380662e-23",
  475.     "0.02241383",
  476.     "9.80665",
  477.     "8.31441",
  478.     "8.854187818e-12",
  479.     "1.256637061e-6",
  480.     "1.41060761e-26",
  481.     "9.2847701e-24",
  482.     "5.050824e-27",
  483.     "9.274078e-24",
  484.     "1.0545887e-34",
  485.     "7.2973506e-3",
  486.     "2.817938e-15",
  487.     "1.6749543e-27",
  488.     "2.6751987e8",
  489.     "1.3214099e-15",
  490.     "1.3195909e-15",
  491.     "1.097373177e7",
  492.     "3.741832e-16",
  493.     "1.438786e-2",
  494.     "5.67032e-8",
  495.     "2.0678506e-15"
  496. };
  497.  
  498. static char    *ConstNotation[] =
  499. {
  500.     "kg",
  501.     "C/mol",
  502.     "m",
  503.     "m/s",
  504.     "J*s",
  505.     "Nm²/kg²",
  506.     "C",
  507.     "kg",
  508.     "kg",
  509.     "1/mol",
  510.     "J/K",
  511.     "m³/mol",
  512.     "m/s²",
  513.     "J/(mol*K)",
  514.     "F/m",
  515.     "H/m",
  516.     "A*m²",
  517.     "A*m²",
  518.     "A*m²",
  519.     "A*m²",
  520.     "J*s",
  521.     "-",
  522.     "m",
  523.     "kg",
  524.     "A*m²/(J*s)",
  525.     "m",
  526.     "m",
  527.     "1/m",
  528.     "W*m²",
  529.     "m*K",
  530.     "W*(K^4)/m²",
  531.     "Wb",
  532. };
  533.  
  534.  
  535.  
  536.  
  537. /**********************************************************************/
  538. /*                      Parser related variables                      */
  539. /**********************************************************************/
  540. char    *ParseInput;                // This has to be global, so that the scanner my find it ;)
  541. APTR    ParsePool;                // Pointer to parser`s memory pool
  542. char    Title[80];                // Title of main window
  543.  
  544.  
  545. double    Value,                    // Value being displayed and memories
  546.     IMem,
  547.     JMem,
  548.     KMem,
  549.     LMem,
  550.     MMem,
  551.     NMem,
  552.     OMem,
  553.     PMem,
  554.     QMem,
  555.     RMem,
  556.     SMem,
  557.     TMem,
  558.     UMem,
  559.     VMem,
  560.     WMem,
  561.     XMem,
  562.     YMem,
  563.     ZMem;
  564.  
  565. struct    List        StandardList;
  566. struct    List        LinearList;
  567.  
  568. UWORD    InOutLook    = 0;                // How to order the String and ListView gadgets
  569. UWORD    NoFuncs        = FALSE;            // Display function gadgets ???
  570. UWORD    NoInput        = FALSE;            // Display input gadgets ???
  571. UWORD    IntType        = ID_DECIMAL;            // Current output format
  572. UWORD    IntBase        = ID_32BIT;            // Current conversion base
  573. UWORD    IntSign        = ID_SIGNED;            // Current ouput sign-format
  574. UWORD    IntAngle    = ID_RAD;            // Current angle format
  575. UWORD    HistLines    = 32;                // Default number of history lines
  576. UWORD    ListLook    = 0;                // Look of ListView
  577. UWORD    FlushOnExit    = FALSE;            // Flush memory on exit ???
  578. UWORD    ClearInput    = FALSE;            // Clear input string after RETURN/EXEC ???
  579. UWORD    OpenStdWin    = FALSE;            // Open the standard deviation window?
  580. UWORD    OpenLinWin    = FALSE;            // Open the linear regression window?
  581. UWORD    OpenConstWin    = FALSE;            // Open the constants window?
  582. UWORD    ClipUnit    = 0;                // Number of clipboard to use
  583. UWORD    ContainsUnDec;                    // This is to signal the main program,
  584.                             // that non-decimal digits have been used
  585.  
  586.  
  587.  
  588.  
  589.  
  590. /**********************************************************************/
  591. /*                        Do the wild thing ;)                        */
  592. /**********************************************************************/
  593. void main(void)
  594. {
  595.     APTR    FlushPtr;
  596.     int    i;
  597.  
  598.         // Try to open libs
  599.  
  600.     if(OpenLibs())
  601.     {
  602.             // Init lists for standard and linear regression
  603.  
  604.         NewList(&StandardList);
  605.         NewList(&LinearList);
  606.  
  607.             // Try to open the main window
  608.  
  609.         if(OpenMainWin())
  610.         {
  611.                 // Display "0" in desired format
  612.  
  613.             FormatOutput(FALSE);
  614.  
  615.                 // Handle incoming inputs
  616.  
  617.             HandleInputs();
  618.         }
  619.         CloseMainWin();
  620.  
  621.             // Free lists
  622.  
  623.         FreeList(&StandardList);
  624.         FreeList(&LinearList);
  625.     }
  626.     CloseLibs();
  627.  
  628.  
  629.         // Should memory be flushed ???
  630.  
  631.     if(FlushOnExit)
  632.     {
  633.         for(i = 0; i < 10; i++)
  634.         {
  635.             if((FlushPtr = AllocMem(0x1DCD6500, MEMF_PUBLIC)))
  636.                 FreeMem(FlushPtr, 0x1DCD6500);
  637.         }
  638.     }
  639.  
  640.     exit(0);
  641. }
  642.  
  643.  
  644.  
  645.  
  646. /**********************************************************************/
  647. /*                      Open-Up needed libraries                      */
  648. /**********************************************************************/
  649. static BOOL OpenLibs(void)
  650. {
  651.     if(!(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 37)))
  652.         return(FALSE);
  653.  
  654.     if(!(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 37)))
  655.         return(FALSE);
  656.  
  657.     if(!(UtilityBase = OpenLibrary("utility.library", 37)))
  658.         return(FALSE);
  659.  
  660.     if(!(IconBase = OpenLibrary("icon.library", 37)))
  661.         return(FALSE);
  662.  
  663.     if(!(MathIeeeDoubBasBase = OpenLibrary("mathieeedoubbas.library", 37)))
  664.         return(FALSE);
  665.  
  666.     if(!(MathIeeeDoubTransBase = OpenLibrary("mathieeedoubtrans.library", 37)))
  667.         return(FALSE);
  668.  
  669.     if(!(IFFParseBase = OpenLibrary("iffparse.library", 37)))
  670.         return(FALSE);
  671.  
  672.     if(!(MUIMasterBase = OpenLibrary("muimaster.library", 7)))
  673.         return(FALSE);
  674.  
  675.     return(TRUE);
  676. }
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683.  
  684. /**********************************************************************/
  685. /*                          Close used libs                           */
  686. /**********************************************************************/
  687. static void CloseLibs(void)
  688. {
  689.     if(MUIMasterBase)
  690.         CloseLibrary(MUIMasterBase);
  691.  
  692.     if(IFFParseBase)
  693.         CloseLibrary(IFFParseBase);
  694.  
  695.     if(MathIeeeDoubTransBase)
  696.         CloseLibrary(MathIeeeDoubTransBase);
  697.  
  698.     if(MathIeeeDoubBasBase)
  699.         CloseLibrary(MathIeeeDoubBasBase);
  700.  
  701.     if(IconBase)
  702.         CloseLibrary(IconBase);
  703.  
  704.     if(UtilityBase)
  705.         CloseLibrary(UtilityBase);
  706.  
  707.     if(GfxBase)
  708.         CloseLibrary((struct Library *)GfxBase);
  709.  
  710.     if(IntuitionBase)
  711.         CloseLibrary((struct Library *)IntuitionBase);
  712. }
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719. /**********************************************************************/
  720. /*                  Set Cycle Chain for main window                   */
  721. /**********************************************************************/
  722. static void SetMainWinCycle(void)
  723. {
  724.     APTR    FirstCycle,
  725.         LastCycle;
  726.     int    GadNum;
  727.  
  728.     if(!InOutLook)
  729.     {
  730.         FirstCycle    = InputString;
  731.         LastCycle    = OutputBox;
  732.     }
  733.     else
  734.     {
  735.         FirstCycle    = OutputBox;
  736.         LastCycle    = InputString;
  737.     }
  738.         // Set Cycle chanin
  739.  
  740.     GadNum    = 0;
  741.     DoMethod(MainWindow, MUIM_Window_SetCycleChain,
  742.         FirstCycle,
  743.         LastCycle,
  744.         InGads[GadNum++],
  745.         InGads[GadNum++],
  746.         InGads[GadNum++],
  747.         InGads[GadNum++],
  748.         InGads[GadNum++],
  749.         InGads[GadNum++],
  750.         InGads[GadNum++],
  751.         InGads[GadNum++],
  752.         InGads[GadNum++],
  753.         InGads[GadNum++],
  754.         InGads[GadNum++],
  755.         InGads[GadNum++],
  756.         InGads[GadNum++],
  757.         InGads[GadNum++],
  758.         InGads[GadNum++],
  759.         InGads[GadNum++],
  760.         InGads[GadNum++],
  761.         InGads[GadNum++],
  762.         InGads[GadNum++],
  763.         InGads[GadNum++],
  764.         InGads[GadNum++],
  765.         InGads[GadNum++],
  766.         InGads[GadNum++],
  767.         InGads[GadNum++],
  768.         InGads[GadNum++],
  769.         InGads[GadNum++],
  770.         InGads[GadNum++],
  771.         InGads[GadNum++],
  772.         InGads[GadNum++],
  773.         InGads[GadNum++],
  774.         InGads[GadNum++],
  775.         InGads[GadNum++],
  776.         InGads[GadNum++],
  777.         InGads[GadNum++],
  778.         InGads[GadNum++],
  779.         InGads[GadNum++],
  780.         InGads[GadNum++],
  781.         InGads[GadNum++],
  782.         InGads[GadNum++],
  783.         InGads[GadNum++],
  784.         InGads[GadNum++],
  785.         InGads[GadNum++],
  786.         InGads[GadNum++],
  787.         InGads[GadNum++],
  788.         InGads[GadNum++],
  789.         InGads[GadNum++],
  790.         InGads[GadNum++],
  791.         InGads[GadNum++],
  792.         InGads[GadNum++],
  793.         InGads[GadNum++],
  794.         InGads[GadNum++],
  795.         InGads[GadNum++],
  796.         InGads[GadNum++],
  797.         InGads[GadNum++],
  798.         InGads[GadNum++],
  799.         InGads[GadNum++],
  800.         InGads[GadNum++],
  801.         InGads[GadNum++],
  802.         InGads[GadNum++],
  803.         InGads[GadNum++],
  804.         InGads[GadNum++],
  805.         InGads[GadNum++],
  806.         InGads[GadNum++],
  807.         InGads[GadNum++],
  808.         InGads[GadNum++],
  809.         InGads[GadNum++],
  810.         InGads[GadNum++],
  811.         InGads[GadNum++],
  812.         InGads[GadNum++],
  813.         InGads[GadNum++],
  814.         InGads[GadNum++],
  815.         InGads[GadNum++],
  816.         InGads[GadNum++],
  817.         InGads[GadNum++],
  818.         InGads[GadNum++],
  819.         InGads[GadNum++],
  820.         InGads[GadNum++],
  821.         InGads[GadNum++],
  822.         InGads[GadNum++],
  823.         InGads[GadNum++],
  824.         InGads[GadNum++],
  825.         InGads[GadNum++],
  826.         InGads[GadNum++],
  827.         InGads[GadNum++],
  828.         InGads[GadNum++],
  829.         InGads[GadNum++],
  830.         InGads[GadNum++],
  831.         InGads[GadNum++],
  832.         InGads[GadNum++],
  833.         InGads[GadNum++],
  834.         InGads[GadNum++],
  835.         InGads[GadNum++],
  836.         InGads[GadNum++],
  837.         InGads[GadNum++],
  838.         InGads[GadNum++],
  839.         InGads[GadNum++],
  840.         InGads[GadNum++],
  841.         InGads[GadNum++],
  842.         InGads[GadNum++],
  843.         InGads[GadNum++],
  844.         InGads[GadNum++],
  845.         InGads[GadNum++],
  846.         InGads[GadNum++],
  847.         InGads[GadNum++],
  848.         InGads[GadNum++],
  849.         InGads[GadNum++],
  850.         InGads[GadNum++],
  851.         InGads[GadNum++],
  852.         InGads[GadNum++],
  853.         InGads[GadNum++],
  854.         InGads[GadNum++],
  855.         ClrObj,
  856.         AllClrObj,
  857.         ExeObj,
  858.     NULL);
  859. }
  860.  
  861.  
  862.  
  863.  
  864. /**********************************************************************/
  865. /*                    Open the Calculator`s Window                    */
  866. /**********************************************************************/
  867. static BOOL OpenMainWin(void)
  868. {
  869.     ULONG    Dummy, GadNum = 0;
  870.  
  871.  
  872.         // The input String Requester
  873.  
  874.     InputGroup    = VGroup, Child,
  875.         InputString    =    StringObject, StringFrame,
  876.                         MUIA_String_Contents,    "0",
  877.                         MUIA_String_MaxLen,    256,
  878.                         MUIA_String_Format,    MUIV_String_Format_Right,
  879.                         MUIA_String_BufferPos,    1,
  880.                     End,
  881.     End;
  882.  
  883.  
  884.         // The Output Box
  885.  
  886.     OutputGroup    = VGroup, Child,
  887.         OutputBox    =    ListviewObject,
  888.                         MUIA_Listview_Input,        TRUE,
  889.                         MUIA_Listview_List,    ListObject, InputListFrame,
  890.                             MUIA_Background,        MUII_ListBack,
  891.                             MUIA_List_Format,        "COL=0 DELTA=8 P=\033r MAW=50 MIW=10, COL=1 DELTA=8 P=\033r MAW=50 MIW=10",
  892.                             MUIA_List_ConstructHook,    &DispConstructHook,
  893.                             MUIA_List_DestructHook,        &StdDestructHook,
  894.                             MUIA_List_DisplayHook,        &DispViewHook,
  895.                         End,
  896.                     End,
  897.     End;
  898.  
  899.  
  900.         // Create the Application window
  901.  
  902.     AppObject    = ApplicationObject,
  903.                 MUIA_Application_Title,        "MCalc",
  904.                 MUIA_Application_Version,    MUIVERS,
  905.                 MUIA_Application_Copyright,    "©1993/94 Kai Iske",
  906.                 MUIA_Application_Author,    "Kai Iske",
  907.                 MUIA_Application_Description,    "Quite powerful calculator, GiftWare",
  908.                 MUIA_Application_Base,        "MCalc",
  909.                 MUIA_Application_SingleTask,    TRUE,
  910.                 MUIA_Application_DiskObject,    DObject = GetDiskObjectNew("PROGDIR:MCalc"),
  911.                 MUIA_Application_Commands,    &RXCommands[0],
  912.                 MUIA_HelpFile,            "MCalc.guide",
  913.  
  914.             // Now head for the main window
  915.  
  916.         SubWindow, MainWindow =    WindowObject,
  917.                         MUIA_Window_Title,    "MUIProCalc "REVISION" - "REVDATE,
  918.                         MUIA_Window_ID,        'MPCM',
  919.                         MUIA_Window_SizeGadget,    TRUE,
  920.                         MUIA_Window_Menu,    &MainMenuDef,
  921.                         MUIA_HelpNode,        NODE_MAIN,
  922.  
  923.                 // Do the gadgets
  924.  
  925.             WindowContents,
  926.             MainGroup = VGroup,
  927.  
  928.                     // First of all the Input and Output Group
  929.  
  930.                 Child,
  931.                 InOutGroup = VGroup, GroupFrame,
  932.                     MUIA_HelpNode,    NODE_INOUTPUT,
  933.                 End, // Input Area
  934.  
  935.                     // Now check for the Function Gadgets
  936.  
  937.                 Child,
  938.  
  939.                 FuncGroup = VGroup, GroupFrame,
  940.                     MUIA_HelpNode, NODE_FUNCTIONS,
  941.  
  942.  
  943.                         // Function Buttons
  944.  
  945.                     Child, RegisterObject,
  946.                             MUIA_Register_Frame,    TRUE,
  947.                             MUIA_Register_Titles,    FunctionEntries,
  948.  
  949.                         Child, ColGroup(8), MUIA_Group_SameWidth, TRUE,
  950.  
  951.                                 // First row of Functions
  952.  
  953.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  954.                                                 MUIA_Text_Contents,    "Sin",
  955.                                                 MUIA_Text_PreParse,    "\33c",
  956.                                                 MUIA_Background,    MUII_ButtonBack,
  957.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  958.                                             End,
  959.  
  960.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  961.                                                 MUIA_Text_Contents,    "Cos",
  962.                                                 MUIA_Text_PreParse,    "\33c",
  963.                                                 MUIA_Background,    MUII_ButtonBack,
  964.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  965.                                             End,
  966.  
  967.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  968.                                                 MUIA_Text_Contents,    "Tan",
  969.                                                 MUIA_Text_PreParse,    "\33c",
  970.                                                 MUIA_Background,    MUII_ButtonBack,
  971.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  972.                                             End,
  973.  
  974.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  975.                                                 MUIA_Text_Contents,    "ASin",
  976.                                                 MUIA_Text_PreParse,    "\33c",
  977.                                                 MUIA_Background,    MUII_ButtonBack,
  978.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  979.                                             End,
  980.  
  981.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  982.                                                 MUIA_Text_Contents,    "ACos",
  983.                                                 MUIA_Text_PreParse,    "\33c",
  984.                                                 MUIA_Background,    MUII_ButtonBack,
  985.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  986.                                             End,
  987.  
  988.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  989.                                                 MUIA_Text_Contents,    "ATan",
  990.                                                 MUIA_Text_PreParse,    "\33c",
  991.                                                 MUIA_Background,    MUII_ButtonBack,
  992.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  993.                                             End,
  994.  
  995.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  996.                                                 MUIA_Text_Contents,    "SinH",
  997.                                                 MUIA_Text_PreParse,    "\33c",
  998.                                                 MUIA_Background,    MUII_ButtonBack,
  999.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1000.                                             End,
  1001.  
  1002.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1003.                                                 MUIA_Text_Contents,    "CosH",
  1004.                                                 MUIA_Text_PreParse,    "\33c",
  1005.                                                 MUIA_Background,    MUII_ButtonBack,
  1006.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1007.                                             End,
  1008.  
  1009.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1010.                                                 MUIA_Text_Contents,    "TanH",
  1011.                                                 MUIA_Text_PreParse,    "\33c",
  1012.                                                 MUIA_Background,    MUII_ButtonBack,
  1013.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1014.                                             End,
  1015.  
  1016.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1017.                                                 MUIA_Text_Contents,    "Log",
  1018.                                                 MUIA_Text_PreParse,    "\33c",
  1019.                                                 MUIA_Background,    MUII_ButtonBack,
  1020.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1021.                                             End,
  1022.  
  1023.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1024.                                                 MUIA_Text_Contents,    "Log10",
  1025.                                                 MUIA_Text_PreParse,    "\33c",
  1026.                                                 MUIA_Background,    MUII_ButtonBack,
  1027.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1028.                                             End,
  1029.  
  1030.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1031.                                                 MUIA_Text_Contents,    "Exp",
  1032.                                                 MUIA_Text_PreParse,    "\33c",
  1033.                                                 MUIA_Background,    MUII_ButtonBack,
  1034.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1035.                                             End,
  1036.  
  1037.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1038.                                                 MUIA_Text_Contents,    "^",
  1039.                                                 MUIA_Text_PreParse,    "\33c",
  1040.                                                 MUIA_Background,    MUII_ButtonBack,
  1041.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1042.                                             End,
  1043.  
  1044.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1045.                                                 MUIA_Text_Contents,    "Pi",
  1046.                                                 MUIA_Text_PreParse,    "\33c",
  1047.                                                 MUIA_Background,    MUII_ButtonBack,
  1048.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1049.                                             End,
  1050.  
  1051.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1052.                                                 MUIA_Text_Contents,    "Sqrt",
  1053.                                                 MUIA_Text_PreParse,    "\33c",
  1054.                                                 MUIA_Background,    MUII_ButtonBack,
  1055.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1056.                                             End,
  1057.  
  1058.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1059.                                                 MUIA_Text_Contents,    "Abs",
  1060.                                                 MUIA_Text_PreParse,    "\33c",
  1061.                                                 MUIA_Background,    MUII_ButtonBack,
  1062.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1063.                                             End,
  1064.  
  1065.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1066.                                                 MUIA_Text_Contents,    "Cot",
  1067.                                                 MUIA_Text_PreParse,    "\33c",
  1068.                                                 MUIA_Background,    MUII_ButtonBack,
  1069.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1070.                                             End,
  1071.  
  1072.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1073.                                                 MUIA_Text_Contents,    "e",
  1074.                                                 MUIA_Text_PreParse,    "\33c",
  1075.                                                 MUIA_Background,    MUII_ButtonBack,
  1076.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1077.                                             End,
  1078.  
  1079.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1080.                                                 MUIA_Text_Contents,    "%",
  1081.                                                 MUIA_Text_PreParse,    "\33c",
  1082.                                                 MUIA_Background,    MUII_ButtonBack,
  1083.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1084.                                             End,
  1085.  
  1086.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1087.                                                 MUIA_Text_Contents,    "%ch",
  1088.                                                 MUIA_Text_PreParse,    "\33c",
  1089.                                                 MUIA_Background,    MUII_ButtonBack,
  1090.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1091.                                             End,
  1092.  
  1093.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1094.                                                 MUIA_Text_Contents,    "%t",
  1095.                                                 MUIA_Text_PreParse,    "\33c",
  1096.                                                 MUIA_Background,    MUII_ButtonBack,
  1097.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1098.                                             End,
  1099.  
  1100.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1101.                                                 MUIA_Text_Contents,    "(n k)",
  1102.                                                 MUIA_Text_PreParse,    "\33c",
  1103.                                                 MUIA_Background,    MUII_ButtonBack,
  1104.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1105.                                             End,
  1106.  
  1107.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1108.                                                 MUIA_Text_Contents,    "YRoot",
  1109.                                                 MUIA_Text_PreParse,    "\33c",
  1110.                                                 MUIA_Background,    MUII_ButtonBack,
  1111.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1112.                                             End,
  1113.  
  1114.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1115.                                                 MUIA_Text_Contents,    "Rez",
  1116.                                                 MUIA_Text_PreParse,    "\33c",
  1117.                                                 MUIA_Background,    MUII_ButtonBack,
  1118.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1119.                                             End,
  1120.                         End, // First Button Bank
  1121.  
  1122.                             // Second Button-Bank
  1123.  
  1124.                         Child, ColGroup(6), MUIA_Group_SameWidth, TRUE,
  1125.  
  1126.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1127.                                                 MUIA_Text_Contents,    "Mod",
  1128.                                                 MUIA_Text_PreParse,    "\33c",
  1129.                                                 MUIA_Background,    MUII_ButtonBack,
  1130.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1131.                                             End,
  1132.  
  1133.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1134.                                                 MUIA_Text_Contents,    "And",
  1135.                                                 MUIA_Text_PreParse,    "\33c",
  1136.                                                 MUIA_Background,    MUII_ButtonBack,
  1137.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1138.                                             End,
  1139.  
  1140.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1141.                                                 MUIA_Text_Contents,    "Or",
  1142.                                                 MUIA_Text_PreParse,    "\33c",
  1143.                                                 MUIA_Background,    MUII_ButtonBack,
  1144.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1145.                                             End,
  1146.  
  1147.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1148.                                                 MUIA_Text_Contents,    "XOr",
  1149.                                                 MUIA_Text_PreParse,    "\33c",
  1150.                                                 MUIA_Background,    MUII_ButtonBack,
  1151.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1152.                                             End,
  1153.  
  1154.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1155.                                                 MUIA_Text_Contents,    "Not",
  1156.                                                 MUIA_Text_PreParse,    "\33c",
  1157.                                                 MUIA_Background,    MUII_ButtonBack,
  1158.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1159.                                             End,
  1160.  
  1161.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1162.                                                 MUIA_Text_Contents,    "Asl",
  1163.                                                 MUIA_Text_PreParse,    "\33c",
  1164.                                                 MUIA_Background,    MUII_ButtonBack,
  1165.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1166.                                             End,
  1167.  
  1168.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1169.                                                 MUIA_Text_Contents,    "Asr",
  1170.                                                 MUIA_Text_PreParse,    "\33c",
  1171.                                                 MUIA_Background,    MUII_ButtonBack,
  1172.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1173.                                             End,
  1174.  
  1175.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1176.                                                 MUIA_Text_Contents,    "Lsl",
  1177.                                                 MUIA_Text_PreParse,    "\33c",
  1178.                                                 MUIA_Background,    MUII_ButtonBack,
  1179.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1180.                                             End,
  1181.  
  1182.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1183.                                                 MUIA_Text_Contents,    "Lsr",
  1184.                                                 MUIA_Text_PreParse,    "\33c",
  1185.                                                 MUIA_Background,    MUII_ButtonBack,
  1186.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1187.                                             End,
  1188.  
  1189.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1190.                                                 MUIA_Text_Contents,    "Rol",
  1191.                                                 MUIA_Text_PreParse,    "\33c",
  1192.                                                 MUIA_Background,    MUII_ButtonBack,
  1193.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1194.                                             End,
  1195.  
  1196.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1197.                                                 MUIA_Text_Contents,    "Ror",
  1198.                                                 MUIA_Text_PreParse,    "\33c",
  1199.                                                 MUIA_Background,    MUII_ButtonBack,
  1200.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1201.                                             End,
  1202.                             Child, HSpace(0),
  1203.                         End, // Second Button Bank
  1204.  
  1205.  
  1206.                             // Third Button-Bank
  1207.  
  1208.                         Child, ColGroup(6), MUIA_Group_SameWidth, TRUE,
  1209.  
  1210.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1211.                                                 MUIA_Text_Contents,    "I",
  1212.                                                 MUIA_Text_PreParse,    "\33c",
  1213.                                                 MUIA_Background,    MUII_ButtonBack,
  1214.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1215.                                             End,
  1216.  
  1217.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1218.                                                 MUIA_Text_Contents,    "J",
  1219.                                                 MUIA_Text_PreParse,    "\33c",
  1220.                                                 MUIA_Background,    MUII_ButtonBack,
  1221.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1222.                                             End,
  1223.  
  1224.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1225.                                                 MUIA_Text_Contents,    "K",
  1226.                                                 MUIA_Text_PreParse,    "\33c",
  1227.                                                 MUIA_Background,    MUII_ButtonBack,
  1228.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1229.                                             End,
  1230.  
  1231.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1232.                                                 MUIA_Text_Contents,    "L",
  1233.                                                 MUIA_Text_PreParse,    "\33c",
  1234.                                                 MUIA_Background,    MUII_ButtonBack,
  1235.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1236.                                             End,
  1237.  
  1238.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1239.                                                 MUIA_Text_Contents,    "M",
  1240.                                                 MUIA_Text_PreParse,    "\33c",
  1241.                                                 MUIA_Background,    MUII_ButtonBack,
  1242.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1243.                                             End,
  1244.  
  1245.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1246.                                                 MUIA_Text_Contents,    "N",
  1247.                                                 MUIA_Text_PreParse,    "\33c",
  1248.                                                 MUIA_Background,    MUII_ButtonBack,
  1249.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1250.                                             End,
  1251.  
  1252.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1253.                                                 MUIA_Text_Contents,    "O",
  1254.                                                 MUIA_Text_PreParse,    "\33c",
  1255.                                                 MUIA_Background,    MUII_ButtonBack,
  1256.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1257.                                             End,
  1258.  
  1259.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1260.                                                 MUIA_Text_Contents,    "P",
  1261.                                                 MUIA_Text_PreParse,    "\33c",
  1262.                                                 MUIA_Background,    MUII_ButtonBack,
  1263.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1264.                                             End,
  1265.  
  1266.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1267.                                                 MUIA_Text_Contents,    "Q",
  1268.                                                 MUIA_Text_PreParse,    "\33c",
  1269.                                                 MUIA_Background,    MUII_ButtonBack,
  1270.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1271.                                             End,
  1272.  
  1273.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1274.                                                 MUIA_Text_Contents,    "R",
  1275.                                                 MUIA_Text_PreParse,    "\33c",
  1276.                                                 MUIA_Background,    MUII_ButtonBack,
  1277.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1278.                                             End,
  1279.  
  1280.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1281.                                                 MUIA_Text_Contents,    "S",
  1282.                                                 MUIA_Text_PreParse,    "\33c",
  1283.                                                 MUIA_Background,    MUII_ButtonBack,
  1284.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1285.                                             End,
  1286.  
  1287.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1288.                                                 MUIA_Text_Contents,    "T",
  1289.                                                 MUIA_Text_PreParse,    "\33c",
  1290.                                                 MUIA_Background,    MUII_ButtonBack,
  1291.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1292.                                             End,
  1293.  
  1294.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1295.                                                 MUIA_Text_Contents,    "U",
  1296.                                                 MUIA_Text_PreParse,    "\33c",
  1297.                                                 MUIA_Background,    MUII_ButtonBack,
  1298.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1299.                                             End,
  1300.  
  1301.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1302.                                                 MUIA_Text_Contents,    "V",
  1303.                                                 MUIA_Text_PreParse,    "\33c",
  1304.                                                 MUIA_Background,    MUII_ButtonBack,
  1305.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1306.                                             End,
  1307.  
  1308.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1309.                                                 MUIA_Text_Contents,    "W",
  1310.                                                 MUIA_Text_PreParse,    "\33c",
  1311.                                                 MUIA_Background,    MUII_ButtonBack,
  1312.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1313.                                             End,
  1314.  
  1315.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1316.                                                 MUIA_Text_Contents,    "X",
  1317.                                                 MUIA_Text_PreParse,    "\33c",
  1318.                                                 MUIA_Background,    MUII_ButtonBack,
  1319.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1320.                                             End,
  1321.  
  1322.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1323.                                                 MUIA_Text_Contents,    "Y",
  1324.                                                 MUIA_Text_PreParse,    "\33c",
  1325.                                                 MUIA_Background,    MUII_ButtonBack,
  1326.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1327.                                             End,
  1328.  
  1329.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1330.                                                 MUIA_Text_Contents,    "Z",
  1331.                                                 MUIA_Text_PreParse,    "\33c",
  1332.                                                 MUIA_Background,    MUII_ButtonBack,
  1333.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1334.                                             End,
  1335.                         End, // Third Button Bank
  1336.  
  1337.  
  1338.                             // Fourth Button-Bank
  1339.  
  1340.                         Child, ColGroup(7), MUIA_Group_SameWidth, TRUE, MUIA_HelpNode, NODE_STDDEVIATION,
  1341.  
  1342.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1343.                                                 MUIA_Text_Contents,    "SD",
  1344.                                                 MUIA_Text_PreParse,    "\33c",
  1345.                                                 MUIA_Background,    MUII_ButtonBack,
  1346.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1347.                                             End,
  1348.  
  1349.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1350.                                                 MUIA_Text_Contents,    "SD_AVE",
  1351.                                                 MUIA_Text_PreParse,    "\33c",
  1352.                                                 MUIA_Background,    MUII_ButtonBack,
  1353.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1354.                                             End,
  1355.  
  1356.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1357.                                                 MUIA_Text_Contents,    "SD_PDEV",
  1358.                                                 MUIA_Text_PreParse,    "\33c",
  1359.                                                 MUIA_Background,    MUII_ButtonBack,
  1360.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1361.                                             End,
  1362.  
  1363.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1364.                                                 MUIA_Text_Contents,    "SD_SDEV",
  1365.                                                 MUIA_Text_PreParse,    "\33c",
  1366.                                                 MUIA_Background,    MUII_ButtonBack,
  1367.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1368.                                             End,
  1369.  
  1370.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1371.                                                 MUIA_Text_Contents,    "SD_NUM",
  1372.                                                 MUIA_Text_PreParse,    "\33c",
  1373.                                                 MUIA_Background,    MUII_ButtonBack,
  1374.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1375.                                             End,
  1376.  
  1377.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1378.                                                 MUIA_Text_Contents,    "SD_QSUM",
  1379.                                                 MUIA_Text_PreParse,    "\33c",
  1380.                                                 MUIA_Background,    MUII_ButtonBack,
  1381.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1382.                                             End,
  1383.  
  1384.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1385.                                                 MUIA_Text_Contents,    "SD_SUM",
  1386.                                                 MUIA_Text_PreParse,    "\33c",
  1387.                                                 MUIA_Background,    MUII_ButtonBack,
  1388.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1389.                                             End,
  1390.                         End, // Fourth Button bank
  1391.  
  1392.  
  1393.                             // Fith Button-Bank
  1394.  
  1395.                         Child, ColGroup(7), MUIA_Group_SameWidth, TRUE, MUIA_HelpNode, NODE_LINREGRESSION,
  1396.  
  1397.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1398.                                                 MUIA_Text_Contents,    "LR",
  1399.                                                 MUIA_Text_PreParse,    "\33c",
  1400.                                                 MUIA_Background,    MUII_ButtonBack,
  1401.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1402.                                             End,
  1403.  
  1404.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1405.                                                 MUIA_Text_Contents,    "LR_XAVE",
  1406.                                                 MUIA_Text_PreParse,    "\33c",
  1407.                                                 MUIA_Background,    MUII_ButtonBack,
  1408.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1409.                                             End,
  1410.  
  1411.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1412.                                                 MUIA_Text_Contents,    "LR_YAVE",
  1413.                                                 MUIA_Text_PreParse,    "\33c",
  1414.                                                 MUIA_Background,    MUII_ButtonBack,
  1415.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1416.                                             End,
  1417.  
  1418.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1419.                                                 MUIA_Text_Contents,    "LR_XPDEV",
  1420.                                                 MUIA_Text_PreParse,    "\33c",
  1421.                                                 MUIA_Background,    MUII_ButtonBack,
  1422.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1423.                                             End,
  1424.  
  1425.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1426.                                                 MUIA_Text_Contents,    "LR_YPDEV",
  1427.                                                 MUIA_Text_PreParse,    "\33c",
  1428.                                                 MUIA_Background,    MUII_ButtonBack,
  1429.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1430.                                             End,
  1431.  
  1432.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1433.                                                 MUIA_Text_Contents,    "LR_XSDEV",
  1434.                                                 MUIA_Text_PreParse,    "\33c",
  1435.                                                 MUIA_Background,    MUII_ButtonBack,
  1436.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1437.                                             End,
  1438.  
  1439.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1440.                                                 MUIA_Text_Contents,    "LR_YSDEV",
  1441.                                                 MUIA_Text_PreParse,    "\33c",
  1442.                                                 MUIA_Background,    MUII_ButtonBack,
  1443.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1444.                                             End,
  1445.  
  1446.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1447.                                                 MUIA_Text_Contents,    "LR_XNUM",
  1448.                                                 MUIA_Text_PreParse,    "\33c",
  1449.                                                 MUIA_Background,    MUII_ButtonBack,
  1450.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1451.                                             End,
  1452.  
  1453.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1454.                                                 MUIA_Text_Contents,    "LR_YNUM",
  1455.                                                 MUIA_Text_PreParse,    "\33c",
  1456.                                                 MUIA_Background,    MUII_ButtonBack,
  1457.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1458.                                             End,
  1459.  
  1460.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1461.                                                 MUIA_Text_Contents,    "LR_XQSUM",
  1462.                                                 MUIA_Text_PreParse,    "\33c",
  1463.                                                 MUIA_Background,    MUII_ButtonBack,
  1464.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1465.                                             End,
  1466.  
  1467.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1468.                                                 MUIA_Text_Contents,    "LR_YQSUM",
  1469.                                                 MUIA_Text_PreParse,    "\33c",
  1470.                                                 MUIA_Background,    MUII_ButtonBack,
  1471.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1472.                                             End,
  1473.  
  1474.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1475.                                                 MUIA_Text_Contents,    "LR_XSUM",
  1476.                                                 MUIA_Text_PreParse,    "\33c",
  1477.                                                 MUIA_Background,    MUII_ButtonBack,
  1478.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1479.                                             End,
  1480.  
  1481.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1482.                                                 MUIA_Text_Contents,    "LR_YSUM",
  1483.                                                 MUIA_Text_PreParse,    "\33c",
  1484.                                                 MUIA_Background,    MUII_ButtonBack,
  1485.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1486.                                             End,
  1487.  
  1488.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1489.                                                 MUIA_Text_Contents,    "LR_XYSUM",
  1490.                                                 MUIA_Text_PreParse,    "\33c",
  1491.                                                 MUIA_Background,    MUII_ButtonBack,
  1492.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1493.                                             End,
  1494.  
  1495.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1496.                                                 MUIA_Text_Contents,    "LR_ALPHA",
  1497.                                                 MUIA_Text_PreParse,    "\33c",
  1498.                                                 MUIA_Background,    MUII_ButtonBack,
  1499.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1500.                                             End,
  1501.  
  1502.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1503.                                                 MUIA_Text_Contents,    "LR_BETA",
  1504.                                                 MUIA_Text_PreParse,    "\33c",
  1505.                                                 MUIA_Background,    MUII_ButtonBack,
  1506.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1507.                                             End,
  1508.  
  1509.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1510.                                                 MUIA_Text_Contents,    "LR_ASSX",
  1511.                                                 MUIA_Text_PreParse,    "\33c",
  1512.                                                 MUIA_Background,    MUII_ButtonBack,
  1513.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1514.                                             End,
  1515.  
  1516.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1517.                                                 MUIA_Text_Contents,    "LR_ASSY",
  1518.                                                 MUIA_Text_PreParse,    "\33c",
  1519.                                                 MUIA_Background,    MUII_ButtonBack,
  1520.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1521.                                             End,
  1522.  
  1523.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1524.                                                 MUIA_Text_Contents,    "LR_CORR",
  1525.                                                 MUIA_Text_PreParse,    "\33c",
  1526.                                                 MUIA_Background,    MUII_ButtonBack,
  1527.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1528.                                             End,
  1529.  
  1530.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1531.                                                 MUIA_Text_Contents,    "LR_CCORR",
  1532.                                                 MUIA_Text_PreParse,    "\33c",
  1533.                                                 MUIA_Background,    MUII_ButtonBack,
  1534.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1535.                                             End,
  1536.  
  1537.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1538.                                                 MUIA_Text_Contents,    "LR_COVAR",
  1539.                                                 MUIA_Text_PreParse,    "\33c",
  1540.                                                 MUIA_Background,    MUII_ButtonBack,
  1541.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1542.                                             End,
  1543.                         End, // Fourth Button bank
  1544.                     End, // Page-Group
  1545.                 End, // Second Area
  1546.  
  1547.                 Child,
  1548.                 InGroup = VGroup, GroupFrame,
  1549.                     MUIA_HelpNode,    NODE_INPUTS,
  1550.  
  1551.                     Child, ColGroup(7), MUIA_Group_SameWidth, TRUE,
  1552.  
  1553.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1554.                                         MUIA_Text_Contents,    "A",
  1555.                                         MUIA_Text_PreParse,    "\33c",
  1556.                                         MUIA_Background,    MUII_ButtonBack,
  1557.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1558.                                     End,
  1559.  
  1560.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1561.                                         MUIA_Text_Contents,    "B",
  1562.                                         MUIA_Text_PreParse,    "\33c",
  1563.                                         MUIA_Background,    MUII_ButtonBack,
  1564.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1565.                                     End,
  1566.  
  1567.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1568.                                         MUIA_Text_Contents,    "C",
  1569.                                         MUIA_Text_PreParse,    "\33c",
  1570.                                         MUIA_Background,    MUII_ButtonBack,
  1571.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1572.                                     End,
  1573.  
  1574.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1575.                                         MUIA_Text_Contents,    "D",
  1576.                                         MUIA_Text_PreParse,    "\33c",
  1577.                                         MUIA_Background,    MUII_ButtonBack,
  1578.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1579.                                     End,
  1580.  
  1581.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1582.                                         MUIA_Text_Contents,    "E",
  1583.                                         MUIA_Text_PreParse,    "\33c",
  1584.                                         MUIA_Background,    MUII_ButtonBack,
  1585.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1586.                                     End,
  1587.  
  1588.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1589.                                         MUIA_Text_Contents,    "$",
  1590.                                         MUIA_Text_PreParse,    "\33c",
  1591.                                         MUIA_Background,    MUII_ButtonBack,
  1592.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1593.                                     End,
  1594.  
  1595.                         Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1596.                                             MUIA_Text_Contents,    "0x",
  1597.                                             MUIA_Text_PreParse,    "\33c",
  1598.                                             MUIA_Background,    MUII_ButtonBack,
  1599.                                             MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1600.                                         End,
  1601.  
  1602.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1603.                                         MUIA_Text_Contents,    "7",
  1604.                                         MUIA_Text_PreParse,    "\33c",
  1605.                                         MUIA_Background,    MUII_ButtonBack,
  1606.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1607.                                     End,
  1608.  
  1609.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1610.                                         MUIA_Text_Contents,    "8",
  1611.                                         MUIA_Text_PreParse,    "\33c",
  1612.                                         MUIA_Background,    MUII_ButtonBack,
  1613.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1614.                                     End,
  1615.  
  1616.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1617.                                         MUIA_Text_Contents,    "9",
  1618.                                         MUIA_Text_PreParse,    "\33c",
  1619.                                         MUIA_Background,    MUII_ButtonBack,
  1620.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1621.                                     End,
  1622.  
  1623.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1624.                                         MUIA_Text_Contents,    "/",
  1625.                                         MUIA_Text_PreParse,    "\33c",
  1626.                                         MUIA_Background,    MUII_ButtonBack,
  1627.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1628.                                     End,
  1629.  
  1630.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1631.                                         MUIA_Text_Contents,    "F",
  1632.                                         MUIA_Text_PreParse,    "\33c",
  1633.                                         MUIA_Background,    MUII_ButtonBack,
  1634.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1635.                                     End,
  1636.  
  1637.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1638.                                         MUIA_Text_Contents,    "\\",
  1639.                                         MUIA_Text_PreParse,    "\33c",
  1640.                                         MUIA_Background,    MUII_ButtonBack,
  1641.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1642.                                     End,
  1643.  
  1644.                         Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  1645.                                             MUIA_Text_Contents,    "!",
  1646.                                             MUIA_Text_PreParse,    "\33c",
  1647.                                             MUIA_Background,    MUII_ButtonBack,
  1648.                                             MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1649.                                         End,
  1650.  
  1651.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1652.                                         MUIA_Text_Contents,    "4",
  1653.                                         MUIA_Text_PreParse,    "\33c",
  1654.                                         MUIA_Background,    MUII_ButtonBack,
  1655.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1656.                                     End,
  1657.  
  1658.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1659.                                         MUIA_Text_Contents,    "5",
  1660.                                         MUIA_Text_PreParse,    "\33c",
  1661.                                         MUIA_Background,    MUII_ButtonBack,
  1662.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1663.                                     End,
  1664.  
  1665.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1666.                                         MUIA_Text_Contents,    "6",
  1667.                                         MUIA_Text_PreParse,    "\33c",
  1668.                                         MUIA_Background,    MUII_ButtonBack,
  1669.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1670.                                     End,
  1671.  
  1672.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1673.                                         MUIA_Text_Contents,    "*",
  1674.                                         MUIA_Text_PreParse,    "\33c",
  1675.                                         MUIA_Background,    MUII_ButtonBack,
  1676.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1677.                                     End,
  1678.  
  1679.                         Child, HSpace(0),
  1680.  
  1681.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1682.                                         MUIA_Text_Contents,    "&",
  1683.                                         MUIA_Text_PreParse,    "\33c",
  1684.                                         MUIA_Background,    MUII_ButtonBack,
  1685.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1686.                                     End,
  1687.  
  1688.                         Child, ClrObj        =    TextObject, ButtonFrame,
  1689.                                             MUIA_Text_Contents,    "CLR",
  1690.                                             MUIA_Text_PreParse,    "\33c",
  1691.                                             MUIA_Background,    MUII_ButtonBack,
  1692.                                             MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1693.                                         End,
  1694.  
  1695.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1696.                                         MUIA_Text_Contents,    "1",
  1697.                                         MUIA_Text_PreParse,    "\33c",
  1698.                                         MUIA_Background,    MUII_ButtonBack,
  1699.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1700.                                     End,
  1701.  
  1702.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1703.                                         MUIA_Text_Contents,    "2",
  1704.                                         MUIA_Text_PreParse,    "\33c",
  1705.                                         MUIA_Background,    MUII_ButtonBack,
  1706.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1707.                                     End,
  1708.  
  1709.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1710.                                         MUIA_Text_Contents,    "3",
  1711.                                         MUIA_Text_PreParse,    "\33c",
  1712.                                         MUIA_Background,    MUII_ButtonBack,
  1713.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1714.                                     End,
  1715.  
  1716.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1717.                                         MUIA_Text_Contents,    "-",
  1718.                                         MUIA_Text_PreParse,    "\33c",
  1719.                                         MUIA_Background,    MUII_ButtonBack,
  1720.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1721.                                     End,
  1722.  
  1723.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1724.                                         MUIA_Text_Contents,    "EXG",
  1725.                                         MUIA_Text_PreParse,    "\33c",
  1726.                                         MUIA_Background,    MUII_ButtonBack,
  1727.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1728.                                     End,
  1729.  
  1730.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1731.                                         MUIA_Text_Contents,    "(",
  1732.                                         MUIA_Text_PreParse,    "\33c",
  1733.                                         MUIA_Background,    MUII_ButtonBack,
  1734.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1735.                                     End,
  1736.  
  1737.                         Child, AllClrObj    =    TextObject, ButtonFrame,
  1738.                                             MUIA_Text_Contents,    "ACLR",
  1739.                                             MUIA_Text_PreParse,    "\33c",
  1740.                                             MUIA_Background,    MUII_ButtonBack,
  1741.                                             MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1742.                                         End,
  1743.  
  1744.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1745.                                         MUIA_Text_Contents,    "0",
  1746.                                         MUIA_Text_PreParse,    "\33c",
  1747.                                         MUIA_Background,    MUII_ButtonBack,
  1748.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1749.                                     End,
  1750.  
  1751.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1752.                                         MUIA_Text_Contents,    ".",
  1753.                                         MUIA_Text_PreParse,    "\33c",
  1754.                                         MUIA_Background,    MUII_ButtonBack,
  1755.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1756.                                     End,
  1757.  
  1758.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1759.                                         MUIA_Text_Contents,    "=",
  1760.                                         MUIA_Text_PreParse,    "\33c",
  1761.                                         MUIA_Background,    MUII_ButtonBack,
  1762.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1763.                                     End,
  1764.  
  1765.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1766.                                         MUIA_Text_Contents,    "+",
  1767.                                         MUIA_Text_PreParse,    "\33c",
  1768.                                         MUIA_Background,    MUII_ButtonBack,
  1769.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1770.                                     End,
  1771.  
  1772.                         Child, HSpace(0),
  1773.  
  1774.                         Child, InGads[GadNum++]=    TextObject, ButtonFrame,
  1775.                                         MUIA_Text_Contents,    ")",
  1776.                                         MUIA_Text_PreParse,    "\33c",
  1777.                                         MUIA_Background,    MUII_ButtonBack,
  1778.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1779.                                     End,
  1780.  
  1781.                         Child, ExeObj        =    TextObject, ButtonFrame,
  1782.                                             MUIA_Text_Contents,    "Exec",
  1783.                                             MUIA_Text_PreParse,    "\33c",
  1784.                                             MUIA_Background,    MUII_ButtonBack,
  1785.                                             MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1786.                                         End,
  1787.                     End, // Input gadgets
  1788.                 End, // Third input area
  1789.             End, // VGroup
  1790.         End, // Main window
  1791.  
  1792.  
  1793.             // Now generate the Prefs window
  1794.  
  1795.         SubWindow, PrefsWindow = WindowObject,
  1796.                         MUIA_Window_Title,    "MUIProCalc Preferences",
  1797.                         MUIA_Window_ID,        'MPCP',
  1798.                         MUIA_Window_SizeGadget,    TRUE,
  1799.                         MUIA_Window_NoMenus,    TRUE,
  1800.                         MUIA_HelpNode,        NODE_PREFS,
  1801.  
  1802.             WindowContents, VGroup,
  1803.  
  1804.                 Child, ColGroup(2),
  1805.                     Child, VGroup, GroupFrameT("Window layout"),
  1806.                         MUIA_HelpNode,    NODE_LAYOUT,
  1807.  
  1808.                         Child, VSpace(0),
  1809.                         Child, HGroup,
  1810.  
  1811.                                 // Display functions gadget
  1812.  
  1813.                             Child, HGroup,
  1814.                                 Child, TextObject,
  1815.                                     MUIA_Text_PreParse,    "\033r",
  1816.                                     MUIA_Text_Contents,    "No Functions",
  1817.                                     MUIA_Text_HiChar,    'f',
  1818.                                 End,
  1819.                                 Child, HSpace(1),
  1820.                                 Child, DFuncObj    =    ImageObject, ImageButtonFrame,
  1821.                                                 MUIA_InputMode,        MUIV_InputMode_Toggle,
  1822.                                                 MUIA_Image_Spec,    MUII_CheckMark,
  1823.                                                 MUIA_Image_FreeVert,    TRUE,
  1824.                                                 MUIA_Selected,        NoFuncs,
  1825.                                                 MUIA_Background,    MUII_ButtonBack,
  1826.                                                 MUIA_ShowSelState,    FALSE,
  1827.                                                 MUIA_ControlChar,    'f',
  1828.                                                 MUIA_ExportID,        'FUNC',
  1829.                                             End,
  1830.                             End,
  1831.  
  1832.                                 // Display Inputs gadget
  1833.  
  1834.                             Child, HGroup,
  1835.                                 Child, TextObject,
  1836.                                     MUIA_Text_PreParse,    "\033r",
  1837.                                     MUIA_Text_Contents,    "No Input",
  1838.                                     MUIA_Text_HiChar,    'n',
  1839.                                 End,
  1840.                                 Child, HSpace(1),
  1841.                                 Child, DInObj    =    ImageObject, ImageButtonFrame,
  1842.                                                 MUIA_InputMode,        MUIV_InputMode_Toggle,
  1843.                                                 MUIA_Image_Spec,    MUII_CheckMark,
  1844.                                                 MUIA_Image_FreeVert,    TRUE,
  1845.                                                 MUIA_Selected,        NoInput,
  1846.                                                 MUIA_Background,    MUII_ButtonBack,
  1847.                                                 MUIA_ShowSelState,    FALSE,
  1848.                                                 MUIA_ControlChar,    'n',
  1849.                                                 MUIA_ExportID,        'INPU',
  1850.                                             End,
  1851.                             End,
  1852.                         End,
  1853.  
  1854.                             // Cycle Gadget for default type
  1855.  
  1856.                         Child, ColGroup(2),
  1857.                             Child, KeyLabel1("In/Out Order", 'O'),
  1858.                             Child, InOutObj    =    CycleObject, ButtonFrame,
  1859.                                             MUIA_Cycle_Active,    InOutLook,
  1860.                                             MUIA_Cycle_Entries,    InOutLookEntries,
  1861.                                             MUIA_ControlChar,    'o',
  1862.                                             MUIA_ExportID,        'ORDR',
  1863.                                         End,
  1864.                         End,
  1865.  
  1866.                         Child, VSpace(0),
  1867.  
  1868.                     End, // Layout gadgets
  1869.  
  1870.                     Child, VGroup, GroupFrameT("Output settings"),
  1871.                         MUIA_HelpNode,    NODE_OUTPUT,
  1872.  
  1873.                         Child, VSpace(0),
  1874.  
  1875.                             // Cycle Gadget for default type
  1876.  
  1877.                         Child, ColGroup(2),
  1878.                             Child, KeyLabel1("Base:", 'B'),
  1879.                             Child, TypeObj    =    CycleObject, ButtonFrame,
  1880.                                             MUIA_Cycle_Active,    IntType - ID_DECIMAL,
  1881.                                             MUIA_Cycle_Entries,    TypeEntries,
  1882.                                             MUIA_ControlChar,    'b',
  1883.                                             MUIA_ExportID,        'TYPE',
  1884.                                         End,
  1885.  
  1886.                             Child, KeyLabel1("Size:", 'z'),
  1887.                             Child, SizeObj    =    CycleObject, ButtonFrame,
  1888.                                             MUIA_Cycle_Active,    IntBase - ID_8BIT,
  1889.                                             MUIA_Cycle_Entries,    SizeEntries,
  1890.                                             MUIA_ControlChar,    'z',
  1891.                                             MUIA_ExportID,        'SIZE',
  1892.                                         End,
  1893.  
  1894.                             Child, KeyLabel1("Sign:", 'i'),
  1895.                             Child, SignObj    =    CycleObject, ButtonFrame,
  1896.                                             MUIA_Cycle_Active,    IntSign - ID_SIGNED,
  1897.                                             MUIA_Cycle_Entries,    SignEntries,
  1898.                                             MUIA_ControlChar,    'i',
  1899.                                             MUIA_ExportID,        'SIGN',
  1900.                                         End,
  1901.  
  1902.                             Child, KeyLabel1("Angle:", 'a'),
  1903.                             Child, AngleObj    =    CycleObject, ButtonFrame,
  1904.                                             MUIA_Cycle_Active,    IntAngle - ID_RAD,
  1905.                                             MUIA_Cycle_Entries,    AngleEntries,
  1906.                                             MUIA_ControlChar,    'a',
  1907.                                             MUIA_ExportID,        'ANGL',
  1908.                                         End,
  1909.                         End, // Cycle gadgets
  1910.  
  1911.                         Child, VSpace(0),
  1912.  
  1913.                     End, // Output settings
  1914.  
  1915.  
  1916.  
  1917.                     Child, VGroup, GroupFrameT("History settings"),
  1918.                         MUIA_HelpNode,    NODE_HISTORY,
  1919.  
  1920.                         Child, VSpace(0),
  1921.  
  1922.                             // Number of lines to buffer
  1923.  
  1924.                         Child, ColGroup(2),
  1925.                             Child, KeyLabel1("Lines:", 'L'),
  1926.                             Child, LinesObj    =    SliderObject,
  1927.                                             MUIA_Slider_Level,    HistLines,
  1928.                                             MUIA_Slider_Min,    1,
  1929.                                             MUIA_Slider_Max,    512,
  1930.                                             MUIA_ControlChar,    'l',
  1931.                                             MUIA_ExportID,        'LINE',
  1932.                                         End,
  1933.  
  1934.  
  1935.                             Child, KeyLabel1("Entries:", 'E'),
  1936.                             Child, LookObj    =    CycleObject, ButtonFrame,
  1937.                                             MUIA_Cycle_Active,    ListLook,
  1938.                                             MUIA_Cycle_Entries,    LookEntries,
  1939.                                             MUIA_ControlChar,    'e',
  1940.                                             MUIA_ExportID,        'LOOK',
  1941.                                         End,
  1942.                         End, // History col group
  1943.  
  1944.                             // Number of clipboard to use
  1945.  
  1946.                         Child, ColGroup(2),
  1947.                             Child, KeyLabel1("ClipUnit:", 'P'),
  1948.                             Child, ClipObj    =    SliderObject,
  1949.                                             MUIA_Slider_Level,    ClipUnit,
  1950.                                             MUIA_Slider_Min,    0,
  1951.                                             MUIA_Slider_Max,    255,
  1952.                                             MUIA_ControlChar,    'p',
  1953.                                             MUIA_ExportID,        'CLIP',
  1954.                                         End,
  1955.                         End, // Clipboard group
  1956.  
  1957.                         Child, VSpace(0),
  1958.  
  1959.                     End, // History settings
  1960.  
  1961.  
  1962.                     Child, VGroup, GroupFrameT("Misc"),
  1963.                         MUIA_HelpNode,    NODE_MISC,
  1964.  
  1965.                         Child, VSpace(0),
  1966.  
  1967.                             // Clear input checkbox
  1968.  
  1969.                         Child, HGroup,
  1970.                             Child, TextObject,
  1971.                                 MUIA_Text_PreParse,    "\033r",
  1972.                                 MUIA_Text_Contents,    "Clear input on exec",
  1973.                                 MUIA_Text_HiChar,    'r',
  1974.                             End,
  1975.                             Child, HSpace(1),
  1976.                             Child, ClearInObj =    ImageObject, ImageButtonFrame,
  1977.                                             MUIA_InputMode,        MUIV_InputMode_Toggle,
  1978.                                             MUIA_Image_Spec,    MUII_CheckMark,
  1979.                                             MUIA_Image_FreeVert,    TRUE,
  1980.                                             MUIA_Selected,        ClearInput,
  1981.                                             MUIA_Background,    MUII_ButtonBack,
  1982.                                             MUIA_ShowSelState,    FALSE,
  1983.                                             MUIA_ControlChar,    'r',
  1984.                                             MUIA_ExportID,        'CLRI',
  1985.                                         End,
  1986.                         End, // Clear checkbox
  1987.  
  1988.                             // Flush memory gadget
  1989.  
  1990.                         Child, HGroup,
  1991.                             Child, TextObject,
  1992.                                 MUIA_Text_PreParse,    "\033r",
  1993.                                 MUIA_Text_Contents,    "Flush memory",
  1994.                                 MUIA_Text_HiChar,    'm',
  1995.                             End,
  1996.                             Child, HSpace(1),
  1997.                             Child, FlushObj    =    ImageObject, ImageButtonFrame,
  1998.                                             MUIA_InputMode,        MUIV_InputMode_Toggle,
  1999.                                             MUIA_Image_Spec,    MUII_CheckMark,
  2000.                                             MUIA_Image_FreeVert,    TRUE,
  2001.                                             MUIA_Selected,        FlushOnExit,
  2002.                                             MUIA_Background,    MUII_ButtonBack,
  2003.                                             MUIA_ShowSelState,    FALSE,
  2004.                                             MUIA_ControlChar,    'm',
  2005.                                             MUIA_ExportID,        'FLUS',
  2006.                                         End,
  2007.                         End, // Flush CheckBox
  2008.  
  2009.                             // Open std. deviation window
  2010.  
  2011.                         Child, HGroup,
  2012.                             Child, TextObject,
  2013.                                 MUIA_Text_PreParse,    "\033r",
  2014.                                 MUIA_Text_Contents,    "Deviation window",
  2015.                                 MUIA_Text_HiChar,    'D',
  2016.                             End,
  2017.                             Child, HSpace(1),
  2018.                             Child, StdWinObj =    ImageObject, ImageButtonFrame,
  2019.                                             MUIA_InputMode,        MUIV_InputMode_Toggle,
  2020.                                             MUIA_Image_Spec,    MUII_CheckMark,
  2021.                                             MUIA_Image_FreeVert,    TRUE,
  2022.                                             MUIA_Selected,        OpenStdWin,
  2023.                                             MUIA_Background,    MUII_ButtonBack,
  2024.                                             MUIA_ShowSelState,    FALSE,
  2025.                                             MUIA_ControlChar,    'd',
  2026.                                             MUIA_ExportID,        'DEVI',
  2027.                                         End,
  2028.                         End, // Open std. deviation window
  2029.  
  2030.                             // Open lin. regression window
  2031.  
  2032.                         Child, HGroup,
  2033.                             Child, TextObject,
  2034.                                 MUIA_Text_PreParse,    "\033r",
  2035.                                 MUIA_Text_Contents,    "Regression window",
  2036.                                 MUIA_Text_HiChar,    'g',
  2037.                             End,
  2038.                             Child, HSpace(1),
  2039.                             Child, LinWinObj =    ImageObject, ImageButtonFrame,
  2040.                                             MUIA_InputMode,        MUIV_InputMode_Toggle,
  2041.                                             MUIA_Image_Spec,    MUII_CheckMark,
  2042.                                             MUIA_Image_FreeVert,    TRUE,
  2043.                                             MUIA_Selected,        OpenLinWin,
  2044.                                             MUIA_Background,    MUII_ButtonBack,
  2045.                                             MUIA_ShowSelState,    FALSE,
  2046.                                             MUIA_ControlChar,    'g',
  2047.                                             MUIA_ExportID,        'REGR',
  2048.                                         End,
  2049.                         End, // Open lin. regression window
  2050.  
  2051.                             // Open constants window
  2052.  
  2053.                         Child, HGroup,
  2054.                             Child, TextObject,
  2055.                                 MUIA_Text_PreParse,    "\033r",
  2056.                                 MUIA_Text_Contents,    "Constants window",
  2057.                                 MUIA_Text_HiChar,    't',
  2058.                             End,
  2059.                             Child, HSpace(1),
  2060.                             Child, ConstWinObj =    ImageObject, ImageButtonFrame,
  2061.                                             MUIA_InputMode,        MUIV_InputMode_Toggle,
  2062.                                             MUIA_Image_Spec,    MUII_CheckMark,
  2063.                                             MUIA_Image_FreeVert,    TRUE,
  2064.                                             MUIA_Selected,        OpenConstWin,
  2065.                                             MUIA_Background,    MUII_ButtonBack,
  2066.                                             MUIA_ShowSelState,    FALSE,
  2067.                                             MUIA_ControlChar,    't',
  2068.                                             MUIA_ExportID,        'CONS',
  2069.                                         End,
  2070.                         End, // Open constants window
  2071.  
  2072.  
  2073.                         Child, VSpace(0),
  2074.  
  2075.                     End, // Misc Group
  2076.                 End, // Horizontal Groups
  2077.  
  2078.                     // Ok, Cancel, Save gadgets
  2079.  
  2080.                 Child, VGroup, GroupFrame,
  2081.                     Child, ColGroup(3), MUIA_Group_SameWidth, TRUE,
  2082.  
  2083.                             // Save Gadget
  2084.  
  2085.                         Child, SaveObj    =    TextObject, ButtonFrame,
  2086.                                         MUIA_Background,    MUII_ButtonBack,
  2087.                                         MUIA_Text_PreParse,    "\33c",
  2088.                                         MUIA_Text_Contents,    "Save",
  2089.                                         MUIA_Text_HiChar,    'S',
  2090.                                         MUIA_ControlChar,    's',
  2091.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  2092.                                     End,
  2093.  
  2094.                             // Use Gadget
  2095.  
  2096.                         Child, OkObj    =    TextObject, ButtonFrame,
  2097.                                         MUIA_Background,    MUII_ButtonBack,
  2098.                                         MUIA_Text_PreParse,    "\33c",
  2099.                                         MUIA_Text_Contents,    "Use",
  2100.                                         MUIA_Text_HiChar,    'U',
  2101.                                         MUIA_ControlChar,    'u',
  2102.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  2103.                                     End,
  2104.  
  2105.                             // Cancel Gadget
  2106.  
  2107.                         Child, CancelObj =    TextObject, ButtonFrame,
  2108.                                         MUIA_Background,    MUII_ButtonBack,
  2109.                                         MUIA_Text_PreParse,    "\33c",
  2110.                                         MUIA_Text_Contents,    "Cancel",
  2111.                                         MUIA_Text_HiChar,    'C',
  2112.                                         MUIA_ControlChar,    'c',
  2113.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  2114.                                     End,
  2115.                     End, // ColGroup
  2116.                 End, // Use - Cancel gadgets
  2117.             End, // Prefs window contents
  2118.         End, // Prefs window
  2119.  
  2120.  
  2121.             // Now generate the Standard deviation history window
  2122.  
  2123.         SubWindow, StdHistoryWindow = WindowObject,
  2124.                         MUIA_Window_Title,    "MUIProCalc Std.Deviation",
  2125.                         MUIA_Window_ID,        'MPCS',
  2126.                         MUIA_Window_SizeGadget,    TRUE,
  2127.                         MUIA_Window_Menu,    &MainMenuDef,
  2128.                         MUIA_Window_Activate,    FALSE,
  2129.                         MUIA_HelpNode,        NODE_WINDOWS,
  2130.  
  2131.             WindowContents, VGroup,
  2132.  
  2133.                 Child,    StdHistoryObj    =    ListviewObject,
  2134.                         MUIA_Listview_Input,        TRUE,
  2135.                         MUIA_Listview_List,    ListObject, InputListFrame,
  2136.                             MUIA_Background,        MUII_ListBack,
  2137.                             MUIA_List_Title,        TRUE,
  2138.                             MUIA_List_Format,        "COL=0 DELTA=12,COL=1 P=\033r",
  2139.                             MUIA_List_ConstructHook,    &HistoryConstructHook,
  2140.                             MUIA_List_DestructHook,        &StdDestructHook,
  2141.                             MUIA_List_DisplayHook,        &DeviationDispHook,
  2142.                         End,
  2143.                     End,
  2144.  
  2145.             End, // Standard deviation window
  2146.         End, // Standard deviation window
  2147.  
  2148.             // Now generate the Linear Regression history window
  2149.  
  2150.         SubWindow, LinHistoryWindow = WindowObject,
  2151.                         MUIA_Window_Title,    "MUIProCalc Lin.Regression",
  2152.                         MUIA_Window_ID,        'MPCL',
  2153.                         MUIA_Window_SizeGadget,    TRUE,
  2154.                         MUIA_Window_Menu,    &MainMenuDef,
  2155.                         MUIA_Window_Activate,    FALSE,
  2156.                         MUIA_HelpNode,        NODE_WINDOWS,
  2157.  
  2158.             WindowContents, VGroup,
  2159.  
  2160.                 Child,    LinHistoryObj    =    ListviewObject,
  2161.                         MUIA_Listview_Input,        TRUE,
  2162.                         MUIA_Listview_List,    ListObject, InputListFrame,
  2163.                             MUIA_Background,        MUII_ListBack,
  2164.                             MUIA_List_Title,        TRUE,
  2165.                             MUIA_List_Format,        "COL=0 DELTA=12,COL=1 P=\033r DELTA=12,COL=2 P=\033r",
  2166.                             MUIA_List_ConstructHook,    &HistoryConstructHook,
  2167.                             MUIA_List_DestructHook,        &StdDestructHook,
  2168.                             MUIA_List_DisplayHook,        &RegressionDispHook,
  2169.                         End,
  2170.                     End,
  2171.  
  2172.             End, // Linear Regression window
  2173.         End, // Linear Regression window
  2174.  
  2175.  
  2176.             // Now generate the Constants window
  2177.  
  2178.         SubWindow, ConstantsWindow = WindowObject,
  2179.                         MUIA_Window_Title,    "MUIProCalc Constants",
  2180.                         MUIA_Window_ID,        'MPCC',
  2181.                         MUIA_Window_SizeGadget,    TRUE,
  2182.                         MUIA_Window_Menu,    &MainMenuDef,
  2183.                         MUIA_Window_Activate,    FALSE,
  2184.                         MUIA_HelpNode,        NODE_WINDOWS,
  2185.  
  2186.             WindowContents, VGroup,
  2187.  
  2188.                 Child,    ConstantsObj =    ListviewObject,
  2189.                         MUIA_Listview_Input,        TRUE,
  2190.                         MUIA_Listview_List,    ListObject, InputListFrame,
  2191.                             MUIA_Background,        MUII_ListBack,
  2192.                             MUIA_List_Title,        TRUE,
  2193.                             MUIA_List_Format,        "COL=0,COL=1,COL=2",
  2194.                             MUIA_List_ConstructHook,    &ConstConstructHook,
  2195.                             MUIA_List_DestructHook,        &StdDestructHook,
  2196.                             MUIA_List_DisplayHook,        &ConstDispHook,
  2197.                             MUIA_List_CompareHook,        &ConstCompHook,
  2198.                         End,
  2199.                     End,
  2200.  
  2201.             End, // Constants group
  2202.         End, // Constants window
  2203.     End; // Application
  2204.  
  2205.     if(AppObject && InputGroup && OutputGroup)
  2206.     {
  2207.         int    i;
  2208.  
  2209.  
  2210.             // Set cycle chain for Prefs window
  2211.  
  2212.         DoMethod(PrefsWindow, MUIM_Window_SetCycleChain,
  2213.             DFuncObj,
  2214.             DInObj,
  2215.             InOutObj,
  2216.             TypeObj,
  2217.             SizeObj,
  2218.             SignObj,
  2219.             AngleObj,
  2220.             LinesObj,
  2221.             ClipObj,
  2222.             LookObj,
  2223.             ClearInObj,
  2224.             FlushObj,
  2225.             StdWinObj,
  2226.             LinWinObj,
  2227.             ConstWinObj,
  2228.             OkObj,
  2229.             SaveObj,
  2230.             CancelObj,
  2231.         NULL);
  2232.  
  2233.             // Set stuff for main window
  2234.  
  2235.         DoMethod(MainWindow, MUIM_Notify,
  2236.             MUIA_Window_CloseRequest,    TRUE,
  2237.             AppObject,            2,
  2238.             MUIM_Application_ReturnID,    ID_QUIT);
  2239.  
  2240.             // Set default object for window
  2241.  
  2242.         set(MainWindow, MUIA_Window_DefaultObject, InputString);
  2243.  
  2244.             //
  2245.             // Do the Gadgets
  2246.             //
  2247.  
  2248.             // Set ID for String-Input
  2249.  
  2250.         DoMethod(InputString, MUIM_Notify,
  2251.             MUIA_String_Acknowledge,    MUIV_EveryTime,
  2252.             AppObject,            2,
  2253.             MUIM_Application_ReturnID,    ID_INPUT);
  2254.  
  2255.             // Attach Output box to StringGadget
  2256.  
  2257.         set(InputString, MUIA_String_AttachedList, OutputBox);
  2258.  
  2259.             // Set up control gadgets to call Hook
  2260.  
  2261.         for(i = 0; i < GadNum; i++)
  2262.         {
  2263.                 // First call the Hook when released
  2264.  
  2265.             DoMethod(InGads[i], MUIM_Notify,
  2266.                 MUIA_Pressed,        FALSE,
  2267.                 AppObject,        3,
  2268.                 MUIM_CallHook,        &InsertHook, InGads[i]);
  2269.  
  2270.                 // The reactivate the string gadget
  2271.  
  2272.             DoMethod(InGads[i], MUIM_Notify,
  2273.                 MUIA_Pressed,        FALSE,
  2274.                 MainWindow,        3,
  2275.                 MUIM_Set,        MUIA_Window_ActiveObject, InputString);
  2276.         }
  2277.  
  2278.  
  2279.             // Return ID for Exe gadget
  2280.  
  2281.         DoMethod(ExeObj, MUIM_Notify,
  2282.             MUIA_Pressed,            FALSE,
  2283.             AppObject,            2,
  2284.             MUIM_Application_ReturnID,    ID_EXEC);
  2285.  
  2286.             // Return ID for CLR gadget
  2287.  
  2288.         DoMethod(ClrObj, MUIM_Notify,
  2289.             MUIA_Pressed,            FALSE,
  2290.             AppObject,            2,
  2291.             MUIM_Application_ReturnID,    ID_CLEAR);
  2292.  
  2293.             // Return ID for ACLR gadget
  2294.  
  2295.         DoMethod(AllClrObj, MUIM_Notify,
  2296.             MUIA_Pressed,            FALSE,
  2297.             AppObject,            2,
  2298.             MUIM_Application_ReturnID,    ID_ALLCLEAR);
  2299.  
  2300.  
  2301.  
  2302.  
  2303.             // Do the Prefs window
  2304.  
  2305.         DoMethod(PrefsWindow, MUIM_Notify,
  2306.             MUIA_Window_CloseRequest,    TRUE,
  2307.             AppObject,            2,
  2308.             MUIM_Application_ReturnID,    ID_PREFS_QUIT);
  2309.  
  2310.  
  2311.             // On OK, first save the prefs to env:
  2312.  
  2313.         DoMethod(OkObj, MUIM_Notify,
  2314.             MUIA_Pressed,            FALSE,
  2315.             AppObject,            2,
  2316.             MUIM_Application_Save,        MUIV_Application_Save_ENV);
  2317.  
  2318.             // Then signal the main program, that new prefs are available
  2319.  
  2320.         DoMethod(OkObj, MUIM_Notify,
  2321.             MUIA_Pressed,            FALSE,
  2322.             AppObject,            2,
  2323.             MUIM_Application_ReturnID,    ID_PREFS_NEW);
  2324.  
  2325.  
  2326.  
  2327.  
  2328.             // On SAVE, save both to env: and envarc:
  2329.  
  2330.         DoMethod(SaveObj, MUIM_Notify,
  2331.             MUIA_Pressed,            FALSE,
  2332.             AppObject,            2,
  2333.             MUIM_Application_Save, MUIV_Application_Save_ENV);
  2334.  
  2335.         DoMethod(SaveObj, MUIM_Notify,
  2336.             MUIA_Pressed,            FALSE,
  2337.             AppObject,            2,
  2338.             MUIM_Application_Save, MUIV_Application_Save_ENVARC);
  2339.  
  2340.             // New prefs available
  2341.  
  2342.         DoMethod(SaveObj, MUIM_Notify,
  2343.             MUIA_Pressed,            FALSE,
  2344.             AppObject,            2,
  2345.             MUIM_Application_ReturnID,    ID_PREFS_NEW);
  2346.  
  2347.  
  2348.  
  2349.             // On Cancel, simply close the window
  2350.  
  2351.         DoMethod(CancelObj, MUIM_Notify,
  2352.             MUIA_Pressed,            FALSE,
  2353.             AppObject,            2,
  2354.             MUIM_Application_ReturnID,    ID_PREFS_QUIT);
  2355.  
  2356.  
  2357.             // Do the Std.Deviation window
  2358.  
  2359.         DoMethod(StdHistoryWindow, MUIM_Notify,
  2360.             MUIA_Window_CloseRequest,    TRUE,
  2361.             AppObject,            2,
  2362.             MUIM_Application_ReturnID,    ID_CLOSESTD);
  2363.  
  2364.  
  2365.             // Do the Lin.Regression window
  2366.  
  2367.         DoMethod(LinHistoryWindow, MUIM_Notify,
  2368.             MUIA_Window_CloseRequest,    TRUE,
  2369.             AppObject,            2,
  2370.             MUIM_Application_ReturnID,    ID_CLOSELIN);
  2371.  
  2372.  
  2373.             // Do the Constants window
  2374.  
  2375.         DoMethod(ConstantsWindow, MUIM_Notify,
  2376.             MUIA_Window_CloseRequest,    TRUE,
  2377.             AppObject,            2,
  2378.             MUIM_Application_ReturnID,    ID_CLOSECONST);
  2379.  
  2380.         DoMethod(ConstantsObj, MUIM_Notify,
  2381.             MUIA_Listview_DoubleClick,    TRUE,
  2382.             AppObject,            2,
  2383.             MUIM_Application_ReturnID,    ID_SELECTCONST);
  2384.  
  2385.  
  2386.  
  2387.             // Load the settings
  2388.  
  2389.         DoMethod(AppObject, MUIM_Application_Load, MUIV_Application_Load_ENV);
  2390.  
  2391.  
  2392.             // Load defaults into variables
  2393.  
  2394.         get(DFuncObj, MUIA_Selected, &Dummy);
  2395.         NoFuncs = Dummy;
  2396.  
  2397.         get(DInObj, MUIA_Selected, &Dummy);
  2398.         NoInput = Dummy;
  2399.  
  2400.         get(InOutObj, MUIA_Cycle_Active, &Dummy);
  2401.         InOutLook = Dummy;
  2402.  
  2403.         get(TypeObj, MUIA_Cycle_Active, &Dummy);
  2404.         IntType    = RXIntType     = Dummy + ID_DECIMAL;
  2405.  
  2406.         get(SizeObj, MUIA_Cycle_Active, &Dummy);
  2407.         IntBase    = RXIntBase    = Dummy + ID_8BIT;
  2408.  
  2409.         get(SignObj, MUIA_Cycle_Active, &Dummy);
  2410.         IntSign    = RXIntSign    = Dummy + ID_SIGNED;
  2411.  
  2412.         get(AngleObj, MUIA_Cycle_Active, &Dummy);
  2413.         IntAngle = RXIntAngle    = Dummy + ID_RAD;
  2414.  
  2415.         get(LinesObj, MUIA_Slider_Level, &Dummy);
  2416.         HistLines = Dummy;
  2417.  
  2418.         get(ClipObj, MUIA_Slider_Level, &Dummy);
  2419.         ClipUnit = Dummy;
  2420.  
  2421.         get(LookObj, MUIA_Cycle_Active, &Dummy);
  2422.         ListLook = Dummy;
  2423.  
  2424.         get(ClearInObj, MUIA_Selected, &Dummy);
  2425.         ClearInput = Dummy;
  2426.  
  2427.         get(FlushObj, MUIA_Selected, &Dummy);
  2428.         FlushOnExit = Dummy;
  2429.  
  2430.         get(StdWinObj, MUIA_Selected, &Dummy);
  2431.         OpenStdWin = Dummy;
  2432.  
  2433.         get(LinWinObj, MUIA_Selected, &Dummy);
  2434.         OpenLinWin = Dummy;
  2435.  
  2436.         get(ConstWinObj, MUIA_Selected, &Dummy);
  2437.         OpenConstWin = Dummy;
  2438.  
  2439.  
  2440.             // Add in/out gadgets in correct order
  2441.  
  2442.         if(!InOutLook)
  2443.         {
  2444.             DoMethod(InOutGroup, OM_ADDMEMBER, InputGroup);
  2445.             DoMethod(InOutGroup, OM_ADDMEMBER, OutputGroup);
  2446.         }
  2447.         else
  2448.         {
  2449.             DoMethod(InOutGroup, OM_ADDMEMBER, OutputGroup);
  2450.             DoMethod(InOutGroup, OM_ADDMEMBER, InputGroup);
  2451.         }
  2452.  
  2453.             // Set cycle chain for main window _AFTER_ String and ListView have been added
  2454.  
  2455.         SetMainWinCycle();
  2456.  
  2457.             // Set listview look
  2458.  
  2459.         set(OutputBox, MUIA_List_Format, LookTemplates[ListLook]);
  2460.  
  2461.  
  2462.             // Add/Remove groups as requested
  2463.  
  2464.         if(NoFuncs)
  2465.             DoMethod(MainGroup, OM_REMMEMBER, FuncGroup, TAG_DONE);
  2466.  
  2467.         if(NoInput)
  2468.             DoMethod(MainGroup, OM_REMMEMBER, InGroup, TAG_DONE);
  2469.  
  2470.  
  2471.             // Add constants to constants window
  2472.  
  2473.         for(i = 0; i < sizeof(ConstNames) / sizeof(char *); i++)
  2474.         {
  2475.             struct    ConstNode    New;
  2476.  
  2477.             New.Constant    = ConstNames[i];
  2478.             New.Value    = ConstValues[i];
  2479.             New.Notation    = ConstNotation[i];
  2480.  
  2481.             DoMethod(ConstantsObj, MUIM_List_InsertSingle, (APTR)&New, MUIV_List_Insert_Sorted);
  2482.         }
  2483.  
  2484.             // Set InputString to default object
  2485.  
  2486.         set(MainWindow, MUIA_Window_DefaultObject, InputString);
  2487.  
  2488.             // Open the main window
  2489.  
  2490.         set(MainWindow, MUIA_Window_Open, TRUE);
  2491.  
  2492.             // Now set Checkmarks
  2493.  
  2494.         DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntType, TRUE);
  2495.         DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntBase, TRUE);
  2496.         DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntSign, TRUE);
  2497.         DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntAngle, TRUE);
  2498.  
  2499.             // Which support window to open?
  2500.  
  2501.         if(OpenStdWin)
  2502.             set(StdHistoryWindow, MUIA_Window_Open, TRUE);
  2503.  
  2504.         if(OpenLinWin)
  2505.             set(LinHistoryWindow, MUIA_Window_Open, TRUE);
  2506.  
  2507.         if(OpenConstWin)
  2508.             set(ConstantsWindow, MUIA_Window_Open, TRUE);
  2509.     }
  2510.     else
  2511.     {
  2512.         if(InputGroup)
  2513.             MUI_DisposeObject(InputGroup);
  2514.  
  2515.         if(OutputGroup)
  2516.             MUI_DisposeObject(OutputGroup);
  2517.     }
  2518.  
  2519.     return((BOOL)(AppObject && InputGroup && OutputGroup));
  2520. }
  2521.  
  2522.  
  2523.  
  2524.  
  2525.  
  2526.  
  2527. /**********************************************************************/
  2528. /*                    Close the main window again                     */
  2529. /**********************************************************************/
  2530. static void CloseMainWin(void)
  2531. {
  2532.         // Dispose all Objects
  2533.  
  2534.     if(AppObject)
  2535.     {
  2536.         set(MainWindow, MUIA_Window_Open, FALSE);
  2537.         MUI_DisposeObject(AppObject);
  2538.     }
  2539.  
  2540.         // Dispose DiskObject
  2541.  
  2542.     if(DObject)
  2543.         FreeDiskObject(DObject);
  2544. }
  2545.  
  2546.  
  2547.  
  2548.  
  2549.  
  2550.  
  2551.  
  2552. /**********************************************************************/
  2553. /*                      Format the output string                      */
  2554. /**********************************************************************/
  2555. BOOL FormatOutput(BOOL ReFormat)
  2556. {
  2557.     struct    ListStruct    NewEntry,
  2558.                 *NewEntryPtr;
  2559.     ULONG    ULong;
  2560.     BOOL    RetVal        = FALSE;
  2561.  
  2562.         // Set title of window first
  2563.  
  2564.     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]);
  2565.     set(MainWindow, MUIA_Window_Title, Title);
  2566.  
  2567.         // Reformat entry ???
  2568.     if(!ReFormat)
  2569.     {
  2570.             // Get the Gadgets buffer
  2571.  
  2572.         get(InputString, MUIA_String_Contents, &ParseInput);
  2573.         strcpy(NewEntry.Input, ParseInput);
  2574.     }
  2575.     else
  2576.     {
  2577.         ULONG    NumEntries;
  2578.  
  2579.             // Get input from bottom entry within History
  2580.  
  2581.         get(OutputBox, MUIA_List_Entries, &NumEntries);
  2582.         DoMethod(OutputBox, MUIM_List_GetEntry, NumEntries - 1, &NewEntryPtr);
  2583.         NewEntry    = *NewEntryPtr;
  2584.         ParseInput    = NewEntry.Input;
  2585.     }
  2586.  
  2587.     if(strlen(ParseInput))
  2588.     {
  2589.             // Allocate memory pool for parsing
  2590.  
  2591.         if((ParsePool = DoCreatePool(MEMF_CLEAR, 8192, 2048)))
  2592.         {
  2593.                 // Reset scanner
  2594.  
  2595.             yychar            = -2;
  2596.             yynerrs            = 0;
  2597.             yy_init            = 1;
  2598.             yy_start        = 0;
  2599.             yyin = yyout        = NULL;
  2600.             yy_current_buffer    = NULL;
  2601.             ContainsUnDec        = FALSE;
  2602.  
  2603.                 // Do the parse
  2604.  
  2605.             yyparse();
  2606.  
  2607.                 // Delete pool again
  2608.  
  2609.             DoDeletePool(ParsePool);
  2610.  
  2611.             if(!yynerrs && !PError)
  2612.             {
  2613.                 RetVal    = TRUE;
  2614.  
  2615.                 switch(IntType)
  2616.                 {
  2617.                     case ID_DECIMAL :
  2618.                     {
  2619.                         if(!ContainsUnDec)
  2620.                         {
  2621.                             if((Value > 4294967295.0) || (Value < -4294967295.0) || ((Value < 1.0) && (Value > -1.0)))
  2622.                                 sprintf(NewEntry.Output, "%g ", Value);
  2623.                             else
  2624.                                 sprintf(NewEntry.Output, "%f ", Value);
  2625.                         }
  2626.                         else
  2627.                             sprintf(NewEntry.Output, "%f ", Value);
  2628.                         break;
  2629.                     }
  2630.  
  2631.                     case ID_HEXDECIMAL :
  2632.                     {
  2633.                         if((Value > 4294967295.0) || (Value < -4294967295.0))
  2634.                             strcpy(NewEntry.Output, "\0338Hex overflow");
  2635.                         else
  2636.                         {
  2637.                             sprintf(NewEntry.Output, "%f ", Value);
  2638.  
  2639.                                 // Now convert that output to a Long
  2640.  
  2641.                             stcd_l(NewEntry.Output, (LONG *)&ULong);
  2642.  
  2643.                                 // And reconvert it to hex output ;)
  2644.  
  2645.                             sprintf(NewEntry.Output, "$%x ", ULong);
  2646.                         }
  2647.                         break;
  2648.                     }
  2649.                     case ID_OCTAL :
  2650.                     {
  2651.                         if((Value > 4294967295.0) || (Value < -4294967295.0))
  2652.                             strcpy(NewEntry.Output, "\0338Octal overflow");
  2653.                         else
  2654.                         {
  2655.                             sprintf(NewEntry.Output, "%f ", Value);
  2656.  
  2657.                                 // First convert to Long
  2658.  
  2659.                             stcd_l(NewEntry.Output, (LONG *)&ULong);
  2660.  
  2661.                                 // Now conbert to octal
  2662.  
  2663.                             sprintf(NewEntry.Output, "\\%o ", ULong);
  2664.                         }
  2665.                         break;
  2666.                     }
  2667.                     case ID_BINARY :
  2668.                     {
  2669.                         char    AddOn[2];
  2670.                         int    i,
  2671.                             NumBits;
  2672.  
  2673.                         if((Value > 4294967295.0) || (Value < -4294967295.0))
  2674.                             strcpy(NewEntry.Output, "\0338Binary overflow");
  2675.                         else
  2676.                         {
  2677.                             sprintf(NewEntry.Output, "%f ", Value);
  2678.  
  2679.                             switch(IntBase)
  2680.                             {
  2681.                                 case ID_8BIT :
  2682.                                 {
  2683.                                     NumBits = 8;
  2684.                                     break;
  2685.                                 }
  2686.                                 case ID_16BIT :
  2687.                                 {
  2688.                                     NumBits = 16;
  2689.                                     break;
  2690.                                 }
  2691.                                 case ID_32BIT :
  2692.                                 {
  2693.                                     NumBits = 32;
  2694.                                     break;
  2695.                                 }
  2696.                             }
  2697.                                 // First convert to Long
  2698.  
  2699.                             stcd_l(NewEntry.Output, (LONG *)&ULong);
  2700.  
  2701.                                 // Set type identifier
  2702.  
  2703.                             strcpy(NewEntry.Output, "&");
  2704.  
  2705.                                 // Now convert to binary output
  2706.  
  2707.                             AddOn[1] = '\0';
  2708.                             for(i = NumBits - 1; i >= 0; i--)
  2709.                             {
  2710.                                 AddOn[0] = ((ULong & (1L << i)) ? (ULong & (1L << i)) - (1L << i) + '1' : '0');
  2711.                                 strcat(NewEntry.Output, AddOn);
  2712.  
  2713.                                     // 4 Bits done -> insert a space ;)
  2714.  
  2715.                                 if(!(i % 4))
  2716.                                     strcat(NewEntry.Output, " ");
  2717.                             }
  2718.                         }
  2719.                         break;
  2720.                     }
  2721.                 }
  2722.             }
  2723.             else
  2724.             {
  2725.                 if(PError == ERR_UNKNOWN_CHR)
  2726.                     sprintf(NewEntry.Output, "\0338Unknown char in column %d", PColumn);
  2727.                 else if(PError == ERR_DIVBY0)
  2728.                     sprintf(NewEntry.Output, "\0338Division by Zero in column %d", PColumn);
  2729.                 else if(PError == ERR_OVERFLOW)
  2730.                     sprintf(NewEntry.Output, "\0338Overflow error in column %d", PColumn);
  2731.                 else if(PError == ERR_UNDERFLOW)
  2732.                     sprintf(NewEntry.Output, "\0338Underflow error in column %d", PColumn);
  2733.                 else if(PError == ERR_NOMEM)
  2734.                     strcpy(NewEntry.Output, "\0338Insufficient memory");
  2735.                 else
  2736.                     sprintf(NewEntry.Output, "\0338Syntax error in column %d", PColumn);
  2737.             }
  2738.  
  2739.                 // On "History-Overflow" remove top entry
  2740.  
  2741.             get(OutputBox, MUIA_List_Entries, &ULong);
  2742.             if(ULong > HistLines)
  2743.                 DoMethod(OutputBox, MUIM_List_Remove, MUIV_List_Remove_First);
  2744.  
  2745.             NewEntryPtr    = &NewEntry;
  2746.             DoMethod(OutputBox, MUIM_List_Insert, &NewEntryPtr, 1, MUIV_List_Insert_Bottom);
  2747.             set(OutputBox, MUIA_List_Active, MUIV_List_Active_Bottom);
  2748.  
  2749.             if(ClearInput)
  2750.                 set(InputString, MUIA_String_Contents, "");
  2751.         }
  2752.         else
  2753.             MUI_Request(AppObject, MainWindow, NULL, NULL, "*Ok", "Sorry, no memory for parsing");
  2754.     }
  2755.  
  2756.     set(MainWindow, MUIA_Window_ActiveObject, InputString);
  2757.  
  2758.     return(RetVal);
  2759. }
  2760.  
  2761.  
  2762.  
  2763.  
  2764.  
  2765.  
  2766.  
  2767. /**********************************************************************/
  2768. /*                  Insert Hook for function gadgets                  */
  2769. /**********************************************************************/
  2770. static ULONG    __saveds __asm InsertFunc(register __a0 struct Hook *MyHook, register __a2 APTR Obj, register __a1 APTR *Data)
  2771. {
  2772.     char    *Text;
  2773.  
  2774.         // Get Text of selected gadget
  2775.  
  2776.     get(*Data, MUIA_Text_Contents, &Text);
  2777.  
  2778.         // Insert text at cursor position
  2779.  
  2780.     InsertText(Text);
  2781.     return(0);
  2782. }
  2783.  
  2784.  
  2785.  
  2786.  
  2787.  
  2788.  
  2789. /**********************************************************************/
  2790. /*        Hook-Function for generating a new entry for the LV         */
  2791. /**********************************************************************/
  2792. static ULONG    __saveds __asm DispConstructFunc(register __a0 struct Hook *MyHook, register __a2 APTR MemPool, register __a1 struct ListStruct *Data)
  2793. {
  2794.     struct    ListStruct    *New;
  2795.  
  2796.     if((New = AllocVec(sizeof(struct ListStruct), MEMF_CLEAR)))
  2797.     {
  2798.         *New    =    *Data;
  2799.         return((ULONG)New);
  2800.     }
  2801.  
  2802.     return(NULL);
  2803. }
  2804.  
  2805.  
  2806.  
  2807.  
  2808.  
  2809. /**********************************************************************/
  2810. /*         Hook-Function for removing a new entry from the LV         */
  2811. /**********************************************************************/
  2812. static ULONG    __saveds __asm StdDestructFunc(register __a0 struct Hook *MyHook, register __a2 APTR MemPool, register __a1 struct ListStruct *Data)
  2813. {
  2814.     FreeVec(Data);
  2815.     return(0);
  2816. }
  2817.  
  2818.  
  2819.  
  2820.  
  2821.  
  2822.  
  2823. /**********************************************************************/
  2824. /*                      Put pointers into array                       */
  2825. /**********************************************************************/
  2826. static ULONG    __saveds __asm DispViewFunc(register __a0 struct Hook *MyHook, register __a2 char **array, register __a1 struct ListStruct *Data)
  2827. {
  2828.     *array++    = Data->Input;
  2829.     *array        = Data->Output;
  2830.  
  2831.     return(NULL);
  2832. }
  2833.  
  2834.  
  2835.  
  2836.  
  2837. /**********************************************************************/
  2838. /*                Construct history entry for std/lin                 */
  2839. /**********************************************************************/
  2840. static ULONG    __saveds __asm HistoryConstructFunc(register __a0 struct Hook *MyHook, register __a2 APTR MemPool, register __a1 struct DoubleNode *Data)
  2841. {
  2842.     struct    DoubleNode    *New;
  2843.  
  2844.     if((New = AllocVec(sizeof(struct DoubleNode), MEMF_CLEAR)))
  2845.     {
  2846.         *New    =    *Data;
  2847.         return((ULONG)New);
  2848.     }
  2849.  
  2850.     return(NULL);
  2851. }
  2852.  
  2853.  
  2854.  
  2855.  
  2856. /**********************************************************************/
  2857. /*                       Display std deviation                        */
  2858. /**********************************************************************/
  2859. static ULONG    __saveds __asm DeviationDispFunc(register __a0 struct Hook *MyHook, register __a2 char **array, register __a1 struct DoubleNode *Data)
  2860. {
  2861.     static    char    Buffer1[32], Buffer2[64];
  2862.  
  2863.     if(Data)
  2864.     {
  2865.         sprintf(Buffer1, "Value %ld:", array[-1] + 1);
  2866.         sprintf(Buffer2, "%g", Data->ValueX);
  2867.  
  2868.         *array++    = Buffer1;
  2869.         *array        = Buffer2;
  2870.     }
  2871.     else
  2872.     {
  2873.         *array++    = "Element";
  2874.         *array        = "X-Value";
  2875.     };
  2876.  
  2877.     return(0);
  2878. }
  2879.  
  2880.  
  2881.  
  2882.  
  2883. /**********************************************************************/
  2884. /*                       Display lin regression                       */
  2885. /**********************************************************************/
  2886. static ULONG    __saveds __asm RegressionDispFunc(register __a0 struct Hook *MyHook, register __a2 char **array, register __a1 struct DoubleNode *Data)
  2887. {
  2888.     static    char    Buffer1[32], Buffer2[64], Buffer3[64];
  2889.  
  2890.     if(Data)
  2891.     {
  2892.         sprintf(Buffer1, "Pair %ld:", array[-1] + 1);
  2893.         sprintf(Buffer2, "%g", Data->ValueX);
  2894.         sprintf(Buffer3, "%g", Data->ValueY);
  2895.  
  2896.         *array++    = Buffer1;
  2897.         *array++    = Buffer2;
  2898.         *array        = Buffer3;
  2899.     }
  2900.     else
  2901.     {
  2902.         *array++    = "Element";
  2903.         *array++    = "X-Value";
  2904.         *array        = "Y-Value";
  2905.     }
  2906.     return(0);
  2907. }
  2908.  
  2909.  
  2910.  
  2911. /**********************************************************************/
  2912. /*                      Construct constant entry                      */
  2913. /**********************************************************************/
  2914. static ULONG    __saveds __asm ConstConstructFunc(register __a0 struct Hook *MyHook, register __a2 APTR MemPool, register __a1 struct ConstNode *Data)
  2915. {
  2916.     struct    ConstNode    *New;
  2917.  
  2918.     if((New = AllocVec(sizeof(struct ConstNode), MEMF_CLEAR)))
  2919.     {
  2920.         *New    =    *Data;
  2921.         return((ULONG)New);
  2922.     }
  2923.  
  2924.     return(NULL);
  2925. }
  2926.  
  2927.  
  2928. /**********************************************************************/
  2929. /*                       Display constant entry                       */
  2930. /**********************************************************************/
  2931. static ULONG    __saveds __asm ConstDispFunc(register __a0 struct Hook *MyHook, register __a2 char **array, register __a1 struct ConstNode *Data)
  2932. {
  2933.     if(Data)
  2934.     {
  2935.         *array++    = Data->Constant;
  2936.         *array++    = Data->Value;
  2937.         *array        = Data->Notation;
  2938.     }
  2939.     else
  2940.     {
  2941.         *array++    = "Name";
  2942.         *array++    = "Value";
  2943.         *array        = "Notation";
  2944.     }
  2945.  
  2946.     return(0);
  2947. }
  2948.  
  2949.  
  2950.  
  2951.  
  2952. /**********************************************************************/
  2953. /*            Compare two constants entries (for sorting)             */
  2954. /**********************************************************************/
  2955. static LONG    __saveds __asm ConstCompFunc(register __a1 struct ConstNode *Data1, register __a2 struct ConstNode *Data2)
  2956. {
  2957.     return(Stricmp(Data1->Constant, Data2->Constant));
  2958. }
  2959.  
  2960.  
  2961.  
  2962. /**********************************************************************/
  2963. /*        Insert a text-string at the current cursor-position         */
  2964. /**********************************************************************/
  2965. static void InsertText(char *NewText)
  2966. {
  2967.     char    NewBuff[258],
  2968.         *Text;
  2969.     ULONG    CursorPos;
  2970.  
  2971.         // No Error ?!?
  2972.  
  2973.     if(strncmp(NewText, "\0338", 2))
  2974.     {
  2975.             // Get current cursor Position within Input-String
  2976.  
  2977.         get(InputString, MUIA_String_BufferPos, &CursorPos);
  2978.         get(InputString, MUIA_String_Contents, &Text);
  2979.  
  2980.             // Copy to buffer, because the string`s contents may not be
  2981.             // directly altered
  2982.  
  2983.         strcpy(NewBuff, Text);
  2984.  
  2985.  
  2986.             // insert to cursor position
  2987.  
  2988.         if((strlen(NewBuff) + strlen(NewText)) < 256)
  2989.             strins(&NewBuff[CursorPos], NewText);
  2990.         else
  2991.             DisplayBeep(NULL);
  2992.  
  2993.             // Set new string for String-Gadget
  2994.  
  2995.         set(InputString, MUIA_String_Contents, NewBuff);
  2996.     }
  2997.  
  2998.     set(MainWindow, MUIA_Window_ActiveObject, InputString);
  2999. }
  3000.  
  3001.  
  3002.  
  3003.  
  3004.  
  3005. /**********************************************************************/
  3006. /*          Write the given entry to the specified clipboard          */
  3007. /**********************************************************************/
  3008. static void WriteClip(char *Entry)
  3009. {
  3010.     struct    IFFHandle    *Handle;
  3011.     BOOL    Ok = FALSE;
  3012.  
  3013.         // Length > 0 ???
  3014.  
  3015.     if(strlen(Entry) && strncmp(Entry, "\0338", 2))
  3016.     {
  3017.             // Try to obtain an IFF Handle
  3018.  
  3019.         if((Handle = AllocIFF()))
  3020.         {
  3021.                 // Open needed clipboard unit
  3022.  
  3023.             if((Handle->iff_Stream = (ULONG)OpenClipboard(ClipUnit)))
  3024.             {
  3025.                 InitIFFasClip(Handle);
  3026.  
  3027.                     // Open Handle for write access
  3028.  
  3029.                 if(!OpenIFF(Handle, IFFF_WRITE))
  3030.                 {
  3031.                         // Push first chunk (FORM)
  3032.  
  3033.                     if(!PushChunk(Handle, ID_FTXT, ID_FORM, IFFSIZE_UNKNOWN))
  3034.                     {
  3035.                             // Push chars chunk
  3036.  
  3037.                         if(!PushChunk(Handle, 0, ID_CHRS, IFFSIZE_UNKNOWN))
  3038.                         {
  3039.                                 // Write data to clipboard
  3040.  
  3041.                             if(WriteChunkBytes(Handle, Entry, strlen(Entry)) == strlen(Entry))
  3042.                             {
  3043.                                     // Pop contents chunk
  3044.  
  3045.                                 if(!PopChunk(Handle))
  3046.                                     Ok = TRUE;
  3047.                             }
  3048.                         }
  3049.  
  3050.                             // Pop FORM chunk
  3051.  
  3052.                         if(Ok)
  3053.                             PopChunk(Handle);
  3054.                     }
  3055.  
  3056.                         // Close IFF Handle
  3057.  
  3058.                     CloseIFF(Handle);
  3059.                 }
  3060.  
  3061.                     // Close Clipboard again
  3062.  
  3063.                 CloseClipboard((struct ClipboardHandle *)Handle->iff_Stream);
  3064.             }
  3065.  
  3066.                 // Free IFF Handle
  3067.  
  3068.             FreeIFF(Handle);
  3069.         }
  3070.     }
  3071.  
  3072.     set(MainWindow, MUIA_Window_ActiveObject, InputString);
  3073. }
  3074.  
  3075.  
  3076.  
  3077.  
  3078.  
  3079.  
  3080. /**********************************************************************/
  3081. /*                    Delete an entry from history                    */
  3082. /**********************************************************************/
  3083. void DeleteHistory(LONG Entry)
  3084. {
  3085.         // No entry specified, delete active entry
  3086.  
  3087.     if(Entry == -1)
  3088.         DoMethod(OutputBox, MUIM_List_Remove, MUIV_List_Remove_Active);
  3089.     else if(Entry == -2)
  3090.         DoMethod(OutputBox, MUIM_List_Remove, MUIV_List_Remove_First);
  3091.     else if(Entry == -3)
  3092.         DoMethod(OutputBox, MUIM_List_Remove, MUIV_List_Remove_Last);
  3093.     else
  3094.         DoMethod(OutputBox, MUIM_List_Remove, Entry);
  3095. }
  3096.  
  3097.  
  3098.  
  3099.  
  3100. /**********************************************************************/
  3101. /*                This is the main controlling routine                */
  3102. /**********************************************************************/
  3103. static void HandleInputs(void)
  3104. {
  3105.     ULONG    MySig, ReturnID;
  3106.     BOOL    GoOn    = TRUE;
  3107.  
  3108.     while(GoOn)
  3109.     {
  3110.         switch(ReturnID = DoMethod(AppObject, MUIM_Application_Input, &MySig))
  3111.         {
  3112.                 // Input done ;)
  3113.  
  3114.             case ID_INPUT :
  3115.             {
  3116.                 FormatOutput(FALSE);
  3117.                 break;
  3118.             }
  3119.  
  3120.                 // Translate input
  3121.  
  3122.             case ID_EXEC :
  3123.             {
  3124.                 FormatOutput(FALSE);
  3125.                 break;
  3126.             }
  3127.  
  3128.                 // Clear input
  3129.  
  3130.             case ID_CLEAR :
  3131.             {
  3132.                 set(InputString, MUIA_String_Contents, "");
  3133.                 FormatOutput(FALSE);
  3134.                 break;
  3135.             }
  3136.  
  3137.                 // Clear input AND Memory
  3138.  
  3139.             case ID_ALLCLEAR :
  3140.             {
  3141.                 IMem = JMem = KMem = LMem = MMem = NMem = OMem = PMem = QMem = RMem = SMem = TMem = UMem = VMem = WMem = XMem = YMem = ZMem = 0.0;
  3142.                 FreeList(&StandardList);
  3143.                 FreeList(&LinearList);
  3144.                 UpdateHistoryWindow(FALSE);
  3145.                 UpdateHistoryWindow(TRUE);
  3146.                 set(InputString, MUIA_String_Contents, "");
  3147.                 FormatOutput(FALSE);
  3148.                 break;
  3149.             }
  3150.  
  3151.                 // Open Prefs window
  3152.  
  3153.             case ID_PREFS :
  3154.             {
  3155.                 set(PrefsWindow, MUIA_Window_Open, TRUE);
  3156.                 break;
  3157.             }
  3158.  
  3159.                 // Display About
  3160.  
  3161.             case ID_ABOUT :
  3162.             {
  3163.                 MUI_Request(AppObject, MainWindow, 0, NULL, "*Okay",
  3164.                     "\033cMUIProCalc v%ld.%ld, written by Kai Iske, GiftWare\n\n"
  3165.                     "\0338Powerful calculator, also suited for programmers\n\n"
  3166.                     "\033l\0332To contact me, write to:\n\033c"
  3167.                     "Kai Iske, Brucknerstrasse 18, 63452 Hanau, Germany\n"
  3168.                     "Tel.: +49-(0)6181-850181\n\n"
  3169.                     "\033lor use electronical mail\n\033c"
  3170.                     "iske@informatik.uni-frankfurt.de\n"
  3171.                     "Kai Iske, 100524,1201\n"
  3172.                     "Kai Iske, 2:244/6302.11\n"
  3173.                     "KAI@SWEET.RHEIN-MAIN.DE\n\n"
  3174.                     "\033c\0332MUIProCalc is a MUI-Application\n"
  3175.                     "MUI is © Stefan Stuntz",
  3176.                     VERNUM, REVNUM, TAG_DONE);
  3177.                 set(MainWindow, MUIA_Window_ActiveObject, InputString);
  3178.                 break;
  3179.             }
  3180.                 // Quit the program
  3181.  
  3182.             case ID_QUIT :
  3183.             case MUIV_Application_ReturnID_Quit :
  3184.             {
  3185.                 set(PrefsWindow, MUIA_Window_Open, FALSE);
  3186.                 GoOn = FALSE;
  3187.                 break;
  3188.             }
  3189.  
  3190.                 // Pick left entry from History ???
  3191.  
  3192.             case ID_PICKLEFT :
  3193.             {
  3194.                 struct    ListStruct    *LSV;
  3195.                 ULONG    ClickCol;
  3196.  
  3197.                 DoMethod(OutputBox, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &LSV);
  3198.  
  3199.                 if(LSV)
  3200.                 {
  3201.                     if(ListLook == 0 || ListLook == 2)
  3202.                         ClickCol = 0;
  3203.                     else if(ListLook == 1 || ListLook == 3)
  3204.                         ClickCol = 1;
  3205.  
  3206.                     if(!ClickCol)
  3207.                         InsertText(LSV->Input);
  3208.                     else
  3209.                         InsertText(LSV->Output);
  3210.                 }
  3211.                 break;
  3212.             }
  3213.  
  3214.                 // Pick right entry from History ???
  3215.  
  3216.             case ID_PICKRIGHT :
  3217.             {
  3218.                 struct    ListStruct    *LSV;
  3219.                 ULONG    ClickCol;
  3220.  
  3221.                 DoMethod(OutputBox, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &LSV);
  3222.  
  3223.                 if(LSV)
  3224.                 {
  3225.                     if(ListLook == 0 || ListLook == 3)
  3226.                         ClickCol = 1;
  3227.                     else if(ListLook == 1 || ListLook == 2)
  3228.                         ClickCol = 0;
  3229.  
  3230.                     if(!ClickCol)
  3231.                         InsertText(LSV->Input);
  3232.                     else
  3233.                         InsertText(LSV->Output);
  3234.                 }
  3235.                 break;
  3236.             }
  3237.  
  3238.                 // Copy left history entry to clipboard
  3239.  
  3240.             case ID_CLIPCUTLEFT :
  3241.             {
  3242.                 struct    ListStruct    *LSV;
  3243.                 ULONG    ClickCol;
  3244.  
  3245.                 DoMethod(OutputBox, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &LSV);
  3246.  
  3247.                 if(LSV)
  3248.                 {
  3249.                     if(ListLook == 0 || ListLook == 2)
  3250.                         ClickCol = 0;
  3251.                     else if(ListLook == 1 || ListLook == 3)
  3252.                         ClickCol = 1;
  3253.  
  3254.                     if(!ClickCol)
  3255.                         WriteClip(LSV->Input);
  3256.                     else
  3257.                         WriteClip(LSV->Output);
  3258.                 }
  3259.  
  3260.                 break;
  3261.             }
  3262.  
  3263.                 // Copy left history entry to clipboard
  3264.  
  3265.             case ID_CLIPCUTRIGHT :
  3266.             {
  3267.                 struct    ListStruct    *LSV;
  3268.                 ULONG    ClickCol;
  3269.  
  3270.                 DoMethod(OutputBox, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &LSV);
  3271.  
  3272.                 if(LSV)
  3273.                 {
  3274.                     if(ListLook == 0 || ListLook == 3)
  3275.                         ClickCol = 1;
  3276.                     else if(ListLook == 1 || ListLook == 2)
  3277.                         ClickCol = 0;
  3278.  
  3279.                     if(!ClickCol)
  3280.                         WriteClip(LSV->Input);
  3281.                     else
  3282.                         WriteClip(LSV->Output);
  3283.                 }
  3284.  
  3285.                 break;
  3286.             }
  3287.  
  3288.                 // Delete current entry from list
  3289.  
  3290.             case ID_DELHISTORY :
  3291.             {
  3292.                 DeleteHistory(-1);
  3293.                 break;
  3294.             }
  3295.  
  3296.                 // Check Output Type
  3297.  
  3298.             case ID_DECIMAL :
  3299.             case ID_HEXDECIMAL :
  3300.             case ID_OCTAL :
  3301.             case ID_BINARY :
  3302.             {
  3303.                 DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntType, FALSE);
  3304.                 IntType    = ReturnID;
  3305.                 DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntType, TRUE);
  3306.                 FormatOutput(TRUE);
  3307.                 break;
  3308.             }
  3309.  
  3310.                 // Check for Bases
  3311.  
  3312.             case ID_8BIT :
  3313.             case ID_16BIT :
  3314.             case ID_32BIT :
  3315.             {
  3316.                 DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntBase, FALSE);
  3317.                 IntBase    = ReturnID;
  3318.                 DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntBase, TRUE);
  3319.                 FormatOutput(TRUE);
  3320.                 break;
  3321.             }
  3322.  
  3323.                 // Check for Signs
  3324.  
  3325.             case ID_SIGNED :
  3326.             case ID_UNSIGNED :
  3327.             {
  3328.                 DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntSign, FALSE);
  3329.                 IntSign    = ReturnID;
  3330.                 DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntSign, TRUE);
  3331.                 FormatOutput(TRUE);
  3332.                 break;
  3333.             }
  3334.  
  3335.                 // Check angle
  3336.  
  3337.             case ID_RAD :
  3338.             case ID_DEG :
  3339.             case ID_GRAD :
  3340.             {
  3341.                 DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntAngle, FALSE);
  3342.                 IntAngle    = ReturnID;
  3343.                 DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntAngle, TRUE);
  3344.                 FormatOutput(TRUE);
  3345.                 break;
  3346.             }
  3347.  
  3348.                 // Check for window open/close
  3349.  
  3350.             case ID_STDHISTORY :
  3351.             {
  3352.                 set(StdHistoryWindow, MUIA_Window_Open, TRUE);
  3353.                 break;
  3354.             }
  3355.  
  3356.             case ID_CLOSESTD :
  3357.             {
  3358.                 set(StdHistoryWindow, MUIA_Window_Open, FALSE);
  3359.                 break;
  3360.             }
  3361.  
  3362.             case ID_LINHISTORY :
  3363.             {
  3364.                 set(LinHistoryWindow, MUIA_Window_Open, TRUE);
  3365.                 break;
  3366.             }
  3367.  
  3368.             case ID_CLOSELIN :
  3369.             {
  3370.                 set(LinHistoryWindow, MUIA_Window_Open, FALSE);
  3371.                 break;
  3372.             }
  3373.  
  3374.             case ID_CONSTANTS :
  3375.             {
  3376.                 set(ConstantsWindow, MUIA_Window_Open, TRUE);
  3377.                 break;
  3378.             }
  3379.  
  3380.             case ID_CLOSECONST :
  3381.             {
  3382.                 set(ConstantsWindow, MUIA_Window_Open, FALSE);
  3383.                 break;
  3384.             }
  3385.  
  3386.             case ID_SELECTCONST :
  3387.             {
  3388.                 struct    ConstNode    *Select;
  3389.  
  3390.                 DoMethod(ConstantsObj, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &Select);
  3391.  
  3392.                 if(Select)
  3393.                     InsertText(Select->Value);
  3394.                 break;
  3395.             }
  3396.  
  3397.  
  3398.  
  3399.                 //
  3400.                 // This is for the Prefs window
  3401.                 //
  3402.  
  3403.                 // Close prefs window
  3404.  
  3405.             case ID_PREFS_QUIT :
  3406.             {
  3407.                 set(PrefsWindow, MUIA_Window_Open, FALSE);
  3408.                 set(MainWindow, MUIA_Window_ActiveObject, InputString);
  3409.  
  3410.                     // Reset preferences
  3411.  
  3412.                 set(InOutObj, MUIA_Cycle_Active, InOutLook);
  3413.                 set(DFuncObj, MUIA_Selected, NoFuncs);
  3414.                 set(DInObj, MUIA_Selected, NoInput);
  3415.                 set(TypeObj, MUIA_Cycle_Active, (ULONG)IntType);
  3416.                 set(SizeObj, MUIA_Cycle_Active, (ULONG)IntBase);
  3417.                 set(SignObj, MUIA_Cycle_Active, (ULONG)IntSign);
  3418.                 set(AngleObj, MUIA_Cycle_Active, (ULONG)IntAngle);
  3419.                 set(LinesObj, MUIA_Slider_Level, (ULONG)HistLines);
  3420.                 set(ClipObj, MUIA_Slider_Level, (ULONG)ClipUnit);
  3421.                 set(LookObj, MUIA_Cycle_Active, (ULONG)ListLook);
  3422.                 set(ClearInObj, MUIA_Selected, (ULONG)ClearInput);
  3423.                 set(FlushObj, MUIA_Selected, (ULONG)FlushOnExit);
  3424.                 set(StdWinObj, MUIA_Selected, (ULONG)OpenStdWin);
  3425.                 set(LinWinObj, MUIA_Selected, (ULONG)OpenLinWin);
  3426.                 set(ConstWinObj, MUIA_Selected, (ULONG)OpenConstWin);
  3427.                 break;
  3428.             }
  3429.  
  3430.             case ID_PREFS_NEW :
  3431.             {
  3432.                 ULONG    NewInOut, NewFunc, NewInput, NewLook;
  3433.  
  3434.                     // Get clear flag
  3435.  
  3436.                 get(ClearInObj, MUIA_Selected, &NewFunc);
  3437.                 ClearInput = NewFunc;
  3438.  
  3439.                     // Get flush flag
  3440.  
  3441.                 get(FlushObj, MUIA_Selected, &NewFunc);
  3442.                 FlushOnExit = NewFunc;
  3443.  
  3444.                     // Get window flags
  3445.  
  3446.                 get(StdWinObj, MUIA_Selected, &NewFunc);
  3447.                 OpenStdWin = NewFunc;
  3448.  
  3449.                 get(LinWinObj, MUIA_Selected, &NewFunc);
  3450.                 OpenLinWin = NewFunc;
  3451.  
  3452.                 get(ConstWinObj, MUIA_Selected, &NewFunc);
  3453.                 OpenConstWin = NewFunc;
  3454.  
  3455.                     // Get ClipBoard unit
  3456.  
  3457.                 get(ClipObj, MUIA_Slider_Level, &NewFunc);
  3458.                 ClipUnit = NewFunc;
  3459.  
  3460.                 set(PrefsWindow, MUIA_Window_Open, FALSE);
  3461.                 get(LinesObj, MUIA_Slider_Level, &NewFunc);
  3462.                 HistLines = NewFunc;
  3463.  
  3464.                     // Rebuild History
  3465.  
  3466.                 get(OutputBox, MUIA_List_Entries, &NewInput);
  3467.                 while(NewInput > HistLines)
  3468.                 {
  3469.                     DoMethod(OutputBox, MUIM_List_Remove, MUIV_List_Remove_First);
  3470.                     NewInput--;
  3471.                 }
  3472.  
  3473.                     // Check for changes on layout
  3474.  
  3475.                 get(InOutObj, MUIA_Cycle_Active, &NewInOut);
  3476.                 get(DFuncObj, MUIA_Selected, &NewFunc);
  3477.                 get(DInObj, MUIA_Selected, &NewInput);
  3478.                 get(LookObj, MUIA_Cycle_Active, &NewLook);
  3479.  
  3480.                 if((NewInOut != InOutLook) || (NewFunc != NoFuncs) || (NewInput != NoInput))
  3481.                 {
  3482.                         // Close main window first
  3483.  
  3484.                     set(MainWindow, MUIA_Window_Open, FALSE);
  3485.  
  3486.                         // Rearrange input output order
  3487.  
  3488.                     if(NewInOut != InOutLook)
  3489.                     {
  3490.                         InOutLook = NewInOut;
  3491.  
  3492.                             // Remove groups first
  3493.  
  3494.                         DoMethod(InOutGroup, OM_REMMEMBER, InputGroup);
  3495.                         DoMethod(InOutGroup, OM_REMMEMBER, OutputGroup);
  3496.  
  3497.                             // Readd groups
  3498.  
  3499.                         if(!InOutLook)
  3500.                         {
  3501.                             DoMethod(InOutGroup, OM_ADDMEMBER, InputGroup);
  3502.                             DoMethod(InOutGroup, OM_ADDMEMBER, OutputGroup);
  3503.                         }
  3504.                         else
  3505.                         {
  3506.                             DoMethod(InOutGroup, OM_ADDMEMBER, OutputGroup);
  3507.                             DoMethod(InOutGroup, OM_ADDMEMBER, InputGroup);
  3508.                         }
  3509.  
  3510.                             // Reset cycle order
  3511.  
  3512.                         SetMainWinCycle();
  3513.                     }
  3514.  
  3515.                         // First remove existent groups from main group
  3516.  
  3517.                     if(!NoFuncs)
  3518.                         DoMethod(MainGroup, OM_REMMEMBER, FuncGroup);
  3519.  
  3520.                     if(!NoInput)
  3521.                         DoMethod(MainGroup, OM_REMMEMBER, InGroup);
  3522.  
  3523.                         // Add Function group when needed
  3524.  
  3525.                     NoFuncs = NewFunc;
  3526.                     if(!NoFuncs)
  3527.                         DoMethod(MainGroup, OM_ADDMEMBER, FuncGroup);
  3528.  
  3529.                         // Add Input group when needed
  3530.  
  3531.                     NoInput = NewInput;
  3532.                     if(!NoInput)
  3533.                         DoMethod(MainGroup, OM_ADDMEMBER, InGroup);
  3534.  
  3535.  
  3536.                         // Reopen window
  3537.  
  3538.                     set(MainWindow, MUIA_Window_Open, TRUE);
  3539.                 }
  3540.  
  3541.                 if(NewLook != ListLook)
  3542.                 {
  3543.                             // Set listview look
  3544.  
  3545.                     ListLook = NewLook;
  3546.                     set(OutputBox, MUIA_List_Format, LookTemplates[ListLook]);
  3547.                 }
  3548.  
  3549.                 set(MainWindow, MUIA_Window_Activate, TRUE);
  3550.                 set(MainWindow, MUIA_Window_ActiveObject, InputString);
  3551.                 break;
  3552.             }
  3553.         }
  3554.  
  3555.         if(GoOn && MySig)
  3556.             Wait(MySig);
  3557.     }
  3558. }
  3559.  
  3560.  
  3561.  
  3562.  
  3563.  
  3564. /**********************************************************************/
  3565. /*                            Free a list                             */
  3566. /**********************************************************************/
  3567. void FreeList(struct List *Lst)
  3568. {
  3569.     struct    Node    *DelNode;
  3570.  
  3571.     while((DelNode = RemHead(Lst)))
  3572.         FreeVec(DelNode);
  3573. }
  3574.  
  3575.  
  3576.  
  3577.  
  3578.  
  3579.  
  3580.  
  3581. /**********************************************************************/
  3582. /*                 Update one of the history windows                  */
  3583. /**********************************************************************/
  3584. void UpdateHistoryWindow(BOOL LinearHistory)
  3585. {
  3586.     struct    List        *Lst        = (LinearHistory ? &LinearList : &StandardList);
  3587.     struct    DoubleNode    *Check        = (struct DoubleNode *)Lst->lh_Head;
  3588.     APTR            Obj        = (LinearHistory ? LinHistoryObj : StdHistoryObj);
  3589.  
  3590.         // Clear old list
  3591.  
  3592.     DoMethod(Obj, MUIM_List_Clear, NULL);
  3593.  
  3594.         // Add new entries
  3595.  
  3596.     while(Check->Link.ln_Succ)
  3597.     {
  3598.         DoMethod(Obj, MUIM_List_InsertSingle, (APTR)Check, MUIV_List_Insert_Bottom);
  3599.  
  3600.         Check    = (struct DoubleNode *)Check->Link.ln_Succ;
  3601.     }
  3602. }
  3603.