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