home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / text / print / casslabel / source / casslabel.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-05  |  53.6 KB  |  1,707 lines

  1. /**********************************************************************
  2.  * File            : CassLabel.c                                      *
  3.  * Purpose         : The MUI based Multimedia Cover-Editor            *
  4.  * Last Revised    : 05.06.1994                                       *
  5.  * Created by      : Dirk Nehring                                     *
  6.  * Current revision: V2.1                                             *
  7.  **********************************************************************/
  8.  
  9. /***** History (* = New) *****
  10. Version 1.0 (21.09.93)
  11.  - First official release
  12.  
  13. Version 1.1 (04.10.93)
  14.  * Now CassLabel uses its own Icon as Diskobject when iconified
  15.  - Improved GUI (the window was too big)
  16.  - File format changed (Sorry ;-( )
  17.  - Better ARexx-Script
  18.  * Included tape type and tape length
  19.  * Disabled <CTRL-C> Checking
  20.  - From now on no back text
  21.  - LaTeX output: back side changed (tape type and tape length)
  22.  * New ISO-Latin 1 to LaTeX Source-Converter
  23.  * Error text when CassLabel can't open the Main Window
  24.  * New LaTex output formats
  25.  * LaTeX output: if you have not enough songs, the second page will not
  26.    be printed
  27.  - Catalogs changed
  28.  - Divide source in some parts
  29.  
  30. Version 1.2 (20.10.93)
  31.  - Action buttons moved into the Window Menu (=> smaller Window)
  32.  - 'rexx/Start_LateX.rexx' changed (now handles PasTeX and AmigaTeX
  33.    correctly)
  34.  * Now handles <CTRL-C> as <ESC>
  35.  * Listview-Stringgadgets are now disabled at Startup
  36.  * Online Help can be invoked by pressing <HELP>
  37.  * ARexx-Script will now be called with System() instead of Execute()
  38.  
  39. Version 2.0 (26.03.94)
  40. - Recompiled with SAS/C 6.51
  41. - Nederlands catalog added (Thanks to Ivo Kroone)
  42. * Now there is a safety Requester
  43. * selectable Device Driver (i.e. PasTeX, MuchMore, PostView, etc.)
  44. * selectable Format (i.e. LaTeX, ASCII, PostScript, etc.)
  45. * every song have a now group and an extension
  46. - New File format, but the old format is still supported
  47. - Improved GUI
  48. * Filename now in the window border
  49.  
  50. Version 2.1 (05.06.94)
  51. * CON-Window opens, when CassLabel is started from the WB and the driver
  52.   makes some output
  53. * Errorshandler now uses EasyRequest()
  54. * Help on Format-Button in the Preferences
  55. - some bugs in the format files removed
  56.  
  57. ***** End of History *****/
  58.  
  59. /**********************************************************************
  60.  *                             Includes                               *
  61.  **********************************************************************/
  62. #include "global.h"
  63.  
  64. /* Locale support */
  65. #define CATCOMP_NUMBERS
  66. #define CATCOMP_BLOCK
  67. #include "CassLabel_strings.h"
  68.  
  69.  
  70. /**********************************************************************
  71.  *                              Defines                               *
  72.  **********************************************************************/
  73. #define REVISION        "2.1"
  74. #define REVDATE            __DATE__
  75. #define REVTIME            __TIME__
  76.  
  77. /* Online Help */
  78. #define GUIDEFILE        "CassLabel.guide"
  79. #define NODE_MAIN        "MainWindow"
  80. #define NODE_PREFS        "MENU_Preferences"
  81.  
  82.  
  83. /**********************************************************************
  84.  *                    Turning off CTRL-C checking                     *
  85.  **********************************************************************/
  86. void __regargs __chkabort(void) {}
  87.  
  88.  
  89. /**********************************************************************
  90.  *                Global variables, structures, enums                 *
  91.  **********************************************************************/
  92. struct Library *MUIMasterBase;
  93.  
  94. long __oslibversion = 37;
  95. long __stack = 8192;
  96.  
  97. static char *programname;
  98. static char programpath[256];
  99. static char pathname[256];
  100. static struct DiskObject *diskobj;
  101.  
  102. char dirbuf_load[256];
  103. char filebuf_load[256];
  104. char dirbuf_save[256];
  105. char filebuf_save[256];
  106. char dirbuf_generate[256] = "RAM:";
  107. char filebuf_generate[256];
  108.  
  109. static struct NewMenu Menu[] =
  110. {
  111.     {NM_TITLE, "", NULL, 0, 0, NULL},
  112.     {NM_ITEM, "", NULL, 0, 0, (APTR) ID_NEW},
  113.     {NM_ITEM, "", "", 0, 0, (APTR) ID_LOAD},
  114.     {NM_ITEM, "", NULL, 0, 0, (APTR) ID_LOAD_OLD},
  115.     {NM_ITEM, "", NULL, 0, 0, (APTR) ID_APPEND},
  116.     {NM_ITEM, "", "", 0, 0, (APTR) ID_SAVE},
  117.     {NM_ITEM, "", NULL, 0, 0, (APTR) ID_SAVE_AS},
  118.     {NM_ITEM, NM_BARLABEL, NULL, 0, 0, NULL},
  119.     {NM_ITEM, "", NULL, 0, 0, (APTR) ID_PREFS},
  120.     {NM_ITEM, NM_BARLABEL, NULL, 0, 0, NULL},
  121.     {NM_ITEM, "", "", 0, 0, (APTR) ID_GENERATE},
  122.     {NM_ITEM, "", "", 0, 0, (APTR) ID_PRINT},
  123.     {NM_ITEM, NM_BARLABEL, NULL, 0, 0, NULL},
  124.     {NM_ITEM, "", "", 0, 0, (APTR) ID_ABOUT},
  125.     {NM_ITEM, "", "", 0, 0, (APTR) ID_QUIT},
  126.     {NM_END, NULL, NULL, 0, 0, NULL},
  127. };
  128.  
  129. const char *CYA_Source[] = {"CD", "MC", "Vinyl", "Live", "Radio", "Video", "TV", NULL};
  130. const char *CYA_NoiseR[] = {"-", "Dolby B", "Dolby C", "Dolby S", "DBX", NULL};
  131. const char *CYA_Position[] = {"Normal", "Chrome", "Metal", NULL};
  132. const char *CYA_Length[] = {"30", "60", "90", "100", "110", "120", NULL};
  133. const char *Pages[] = {"", "", "", NULL};
  134.  
  135. APTR App;
  136. APTR MainWindow;
  137. APTR PrefsWindow;
  138.  
  139. APTR LV_SideA;
  140. APTR ST_ElementTitleA;
  141. APTR ST_ElementGroupA;
  142. APTR ST_ElementExtensionA;
  143. APTR BT_AddA;
  144. APTR BT_RemoveA;
  145. APTR BT_UpA;
  146. APTR BT_DownA;
  147. APTR ST_DateA;
  148. APTR ST_GroupA;
  149. APTR ST_TitleA;
  150. APTR CY_SourceA;
  151. APTR CY_NoiseRA;
  152.  
  153. APTR LV_SideB;
  154. APTR ST_ElementTitleB;
  155. APTR ST_ElementGroupB;
  156. APTR ST_ElementExtensionB;
  157. APTR BT_AddB;
  158. APTR BT_RemoveB;
  159. APTR BT_UpB;
  160. APTR BT_DownB;
  161. APTR ST_DateB;
  162. APTR ST_GroupB;
  163. APTR ST_TitleB;
  164. APTR CY_SourceB;
  165. APTR CY_NoiseRB;
  166.  
  167. APTR BT_New;
  168. APTR BT_Load;
  169. APTR BT_Save;
  170. APTR BT_Print;
  171. APTR BT_Create;
  172.  
  173. APTR GA_GaugeA;
  174. APTR GA_GaugeB;
  175. APTR ST_Number;
  176. APTR CY_Position;
  177. APTR CY_Length;
  178.  
  179. APTR BT_PrefsSave;
  180. APTR BT_PrefsOK;
  181. APTR BT_PrefsCancel;
  182. APTR PS_PopFormat;
  183. APTR PS_PopFormat_String;
  184. APTR PS_PopDriver;
  185. APTR PS_PopDriver_String;
  186. APTR CM_Translate;
  187. APTR BT_PrefsHelp;
  188.  
  189.  
  190. /**********************************************************************
  191.  *                         Support Functions                          *
  192.  **********************************************************************/
  193. char *GetStr(APTR obj)
  194. {
  195.     char *str;
  196.  
  197.     if (!get(obj, MUIA_String_Contents, &str))
  198.         get(obj, MUIA_Text_Contents, &str);
  199.  
  200.     return (str);
  201. }
  202.  
  203. long GetBool(APTR obj)
  204. {
  205.     long x;
  206.     get(obj, MUIA_Selected, &x);
  207.     return (x);
  208. }
  209.  
  210. long GetRadio(APTR obj)
  211. {
  212.     long x;
  213.     get(obj, MUIA_Radio_Active, &x);
  214.     return (x);
  215. }
  216.  
  217. long GetCycle(APTR obj)
  218. {
  219.     long x;
  220.     get(obj, MUIA_Cycle_Active, &x);
  221.     return (x);
  222. }
  223.  
  224.  
  225. /**********************************************************************
  226.  *                          Locale Support                            *
  227.  **********************************************************************/
  228. struct LocaleInfo CassLabelLocaleInfo = {NULL, NULL};
  229. struct Library *LocaleBase;
  230. APTR CassLabelCatalog;
  231.  
  232. STRPTR GetLocaleString(long stringNum)
  233. {
  234.     long *l;
  235.     unsigned short *w;
  236.     STRPTR builtIn;
  237.  
  238.     l = (long *) CatCompBlock;
  239.  
  240.     while (*l != stringNum)
  241.     {
  242.         w = (unsigned short *) ((unsigned long) l + 4);
  243.         l = (long *) ((unsigned long) l + (unsigned long) * w + 6);
  244.     }
  245.     builtIn = (STRPTR) ((unsigned long) l + 6);
  246.  
  247.     if (LocaleBase)
  248.         return (GetCatalogStr(CassLabelCatalog, stringNum, builtIn));
  249.  
  250.     return (builtIn);
  251. }
  252.  
  253.  
  254. /**********************************************************************
  255.  *                          Fail Functions                            *
  256.  **********************************************************************/
  257. static void fail(APTR app, char *str)
  258. {
  259.     struct EasyStruct es = {sizeof (struct EasyStruct), 0, NULL, NULL, "OK"};
  260.  
  261.     if (diskobj)
  262.         FreeDiskObject(diskobj);
  263.  
  264.     if (app)
  265.         MUI_DisposeObject(app);
  266.  
  267.     if (MUIMasterBase)
  268.         CloseLibrary(MUIMasterBase);
  269.  
  270.     if (CassLabelCatalog)
  271.         CloseCatalog(CassLabelCatalog);
  272.  
  273.     if (LocaleBase)
  274.         CloseLibrary(LocaleBase);
  275.  
  276.     if (str)
  277.     {
  278.         es.es_TextFormat = str;
  279.         EasyRequestArgs(NULL, &es, NULL, NULL);
  280.         exit(EXIT_FAILURE);
  281.     }
  282.  
  283.     exit(EXIT_SUCCESS);
  284. }
  285.  
  286.  
  287. /**********************************************************************
  288.  *              Functions for changing Listview entries               *
  289.  **********************************************************************/
  290. static void ga_update(APTR lv, APTR ga)
  291. {
  292.     long last;
  293.  
  294.     get(lv, MUIA_List_Entries, &last);
  295.     set(ga, MUIA_Gauge_Current, last);
  296. }
  297.  
  298. static void lv_add(APTR lv, APTR st1, APTR st2, APTR st3, APTR bt1, APTR bt2, APTR bt3, APTR bt4, APTR ga)
  299. {
  300.     struct NodeEntry entry = {"", ""}, *entrypointer = &entry;
  301.     
  302.     long pos, last;
  303.  
  304.     /* Insert at Cursor-Position */
  305.     get(lv, MUIA_List_Active, &pos);
  306.     get(lv, MUIA_List_Entries, &last);
  307.     if (pos == -1)
  308.     {
  309.         /* Enable the String Gadget */
  310.         set(st1, MUIA_Disabled, FALSE);
  311.         set(st2, MUIA_Disabled, FALSE);
  312.         set(st3, MUIA_Disabled, FALSE);
  313.         set(bt2, MUIA_Disabled, FALSE);
  314.         set(bt3, MUIA_Disabled, FALSE);
  315.         set(bt4, MUIA_Disabled, FALSE);
  316.         pos = last;
  317.     }
  318.     if (last < MAX_ENTRIES)
  319.     {
  320.         pos++;
  321.         DoMethod(lv, MUIM_List_Insert, &entrypointer, 1, pos);
  322.         set(lv, MUIA_List_Active, pos);
  323.         ga_update(lv, ga);
  324.         /* Activate String Gadget */
  325.         set(MainWindow, MUIA_Window_ActiveObject, st1);
  326.     }
  327.     if (last + 1 == MAX_ENTRIES)
  328.         set(bt1, MUIA_Disabled, TRUE);
  329. }
  330.  
  331. static void lv_remove(APTR lv, APTR st1, APTR st2, APTR st3, APTR bt1, APTR bt2, APTR bt3, APTR bt4, APTR ga)
  332. {
  333.     long pos, last;
  334.  
  335.     get(lv, MUIA_List_Active, &pos);
  336.     DoMethod(lv, MUIM_List_Remove, pos);
  337.     get(lv, MUIA_List_Entries, &last);
  338.     /* If there is no more entry, disable the Stringgadget */
  339.     if (!last)
  340.     {
  341.         set(st1, MUIA_Disabled, TRUE);
  342.         set(st2, MUIA_Disabled, TRUE);
  343.         set(st3, MUIA_Disabled, TRUE);
  344.         set(bt2, MUIA_Disabled, TRUE);
  345.         set(bt3, MUIA_Disabled, TRUE);
  346.         set(bt4, MUIA_Disabled, TRUE);
  347.     }
  348.     set(bt1, MUIA_Disabled, FALSE);
  349.     ga_update(lv, ga);
  350. }
  351.  
  352. static void lv_up(APTR lv)
  353. {
  354.     long pos;
  355.  
  356.     get(lv, MUIA_List_Active, &pos);
  357.     if (pos > 0)
  358.     {
  359.         DoMethod(lv, MUIM_List_Exchange, pos, pos - 1);
  360.         set(lv, MUIA_List_Active, pos - 1);
  361.     }
  362. }
  363.  
  364. static void lv_down(APTR lv)
  365. {
  366.     long pos, last;
  367.  
  368.     get(lv, MUIA_List_Entries, &last);
  369.     get(lv, MUIA_List_Active, &pos);
  370.  
  371.     last--;
  372.     if (pos < last && last > 0)
  373.     {
  374.         DoMethod(lv, MUIM_List_Exchange, pos, pos + 1);
  375.         set(lv, MUIA_List_Active, pos + 1);
  376.     }
  377. }
  378.  
  379. static void lv_edit(APTR lv, APTR st1, APTR st2, APTR st3)
  380. {
  381.     long pos;
  382.     char *title;
  383.     char *group;
  384.     char *extension;
  385.     struct NodeEntry entry, *entrypointer = &entry;
  386.  
  387.     set(lv, MUIA_List_Quiet, TRUE);
  388.     get(lv, MUIA_List_Active, &pos);
  389.     DoMethod(lv, MUIM_List_Remove, pos);
  390.     get(st1, MUIA_String_Contents, &title);
  391.     get(st2, MUIA_String_Contents, &group);
  392.     get(st3, MUIA_String_Contents, &extension);
  393.     strncpy(entry.title, title, MAXLENGTH_ENTRY);
  394.     strncpy(entry.group, group, MAXLENGTH_ENTRY);
  395.     strncpy(entry.extension, extension, MAXLENGTH_ENTRY);
  396.     DoMethod(lv, MUIM_List_Insert, &entrypointer, 1, pos);
  397.     set(lv, MUIA_List_Quiet, FALSE);
  398.     set(lv, MUIA_List_Active, pos);
  399. }
  400.  
  401. static void lv_copy(APTR lv, APTR st1, APTR st2, APTR st3)
  402. {
  403.     struct NodeEntry *entry;
  404.  
  405.     DoMethod(lv, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &entry);
  406.     set(st1, MUIA_String_Contents, entry->title);
  407.     set(st2, MUIA_String_Contents, entry->group);
  408.     set(st3, MUIA_String_Contents, entry->extension);
  409.     set(MainWindow, MUIA_Window_ActiveObject, st1);
  410. }
  411.  
  412.  
  413. /**********************************************************************
  414.  *         Constructing and Destructing Hooks for Listviews           *
  415.  **********************************************************************/
  416. static __saveds __asm APTR DisplayFunc(register __a0 struct Hook *hook,
  417.                                          register __a2 char **array,
  418.                                          register __a1 struct NodeEntry *entry)
  419. {
  420.     *array++ = entry->title;
  421.     *array++ = entry->group;
  422.     *array = entry->extension;
  423.     return NULL;
  424. }
  425.  
  426. static struct Hook DisplayHook =
  427. {
  428.     {NULL, NULL},
  429.     (HOOKFUNC) DisplayFunc,
  430.     NULL, NULL
  431. };
  432.  
  433. static __saveds __asm APTR ConstructFunc(register __a0 struct Hook *hook,
  434.                                            register __a2 APTR mempool,
  435.                                            register __a1 struct NodeEntry *data)
  436. {
  437.     struct NodeEntry *new;
  438.  
  439.     if (new = (struct NodeEntry*) AllocMem(sizeof(struct NodeEntry), MEMF_ANY))
  440.         *new = *data;
  441.     return new;
  442. }
  443.  
  444. static struct Hook ConstructHook =
  445. {
  446.     {NULL, NULL},
  447.     (HOOKFUNC) ConstructFunc,
  448.     NULL, NULL
  449. };
  450.  
  451. static __saveds __asm APTR DestructFunc(register __a0 struct Hook *hook,
  452.                                         register __a2 APTR mempool,
  453.                                          register __a1 struct NodeEntry *data)
  454. {
  455.     FreeMem(data, sizeof(struct NodeEntry));
  456.     return NULL;
  457. }
  458.  
  459. static struct Hook DestructHook =
  460. {
  461.     {NULL, NULL},
  462.     (HOOKFUNC) DestructFunc,
  463.     NULL, NULL
  464. };
  465.  
  466.  
  467. /**********************************************************************
  468.  *                             Clear all                              *
  469.  **********************************************************************/
  470. static void Clear_Cass(void)
  471. {
  472.     setstring(ST_TitleA, "");
  473.     setstring(ST_GroupA, "");
  474.     setstring(ST_DateA, "");
  475.     setcycle(CY_SourceA, 0);
  476.     setcycle(CY_NoiseRA, 0);
  477.     setstring(ST_TitleB, "");
  478.     setstring(ST_GroupB, "");
  479.     setstring(ST_DateB, "");
  480.     setcycle(CY_SourceB, 0);
  481.     setcycle(CY_NoiseRB, 0);
  482.     setstring(ST_Number, "");
  483.     setcycle(CY_Position, 1);
  484.     setcycle(CY_Length, 2);
  485.  
  486.     DoMethod(LV_SideA, MUIM_List_Clear);
  487.     ga_update(LV_SideA, GA_GaugeA);
  488.     setstring(ST_ElementTitleA, "");
  489.     setstring(ST_ElementGroupA, "");
  490.     setstring(ST_ElementExtensionA, "");
  491.     set(ST_ElementTitleA, MUIA_Disabled, TRUE);
  492.     set(ST_ElementGroupA, MUIA_Disabled, TRUE);
  493.     set(ST_ElementExtensionA, MUIA_Disabled, TRUE);
  494.     set(BT_AddA, MUIA_Disabled, FALSE);
  495.     set(BT_RemoveA, MUIA_Disabled, TRUE);
  496.     set(BT_UpA, MUIA_Disabled, TRUE);
  497.     set(BT_DownA, MUIA_Disabled, TRUE);
  498.  
  499.     DoMethod(LV_SideB, MUIM_List_Clear);
  500.     ga_update(LV_SideB, GA_GaugeB);
  501.     setstring(ST_ElementTitleB, "");
  502.     setstring(ST_ElementGroupB, "");
  503.     setstring(ST_ElementExtensionB, "");
  504.     set(ST_ElementTitleB, MUIA_Disabled, TRUE);
  505.     set(ST_ElementGroupB, MUIA_Disabled, TRUE);
  506.     set(ST_ElementExtensionB, MUIA_Disabled, TRUE);
  507.     set(BT_AddB, MUIA_Disabled, FALSE);
  508.     set(BT_RemoveB, MUIA_Disabled, TRUE);
  509.     set(BT_UpB, MUIA_Disabled, TRUE);
  510.     set(BT_DownB, MUIA_Disabled, TRUE);
  511.  
  512.     filebuf_save[0] = '\0';
  513.     settitle(NULL);
  514. }
  515.  
  516.  
  517. /**********************************************************************
  518.  *                           File Handling                            *
  519.  **********************************************************************/
  520. static void File_Cass(enum files filemode)
  521. {
  522.     char *dirbuf;
  523.     char *filebuf;
  524.  
  525.     struct Window *window;
  526.     char pathbuf[256], linebuf[256];
  527.     char *title;
  528.     char *suffix = NULL;
  529.     FILE *fh;
  530.     struct FileRequester *frq;
  531.     long i, end, end2;
  532.     char *temp;
  533.     struct NodeEntry entry = {"", ""}, *entrypointer = &entry;
  534.     int saveflag = 0; /* Flag for saving without requester */
  535.     int sourceside, destside;
  536.  
  537.     /* Put our Application to sleep while displaying the Requester */
  538.     set(App, MUIA_Application_Sleep, TRUE);
  539.  
  540.     switch (filemode)
  541.     {
  542.         case ID_LOAD:
  543.             title = GetLocaleString(MSG_LOAD_FILE);
  544.             dirbuf = dirbuf_load;
  545.             filebuf = filebuf_load;
  546.             suffix = "#?.cas";
  547.             break;
  548.  
  549.         case ID_LOAD_OLD:
  550.             title = GetLocaleString(MSG_LOAD_OLD_FILE);
  551.             dirbuf = dirbuf_load;
  552.             filebuf = filebuf_load;
  553.             suffix = "#?.cas";
  554.             break;
  555.  
  556.         case ID_APPEND:
  557.             title = GetLocaleString(MSG_APPEND_FILE);
  558.             dirbuf = dirbuf_load;
  559.             filebuf = filebuf_load;
  560.             suffix = "#?.cas";
  561.             break;
  562.  
  563.         case ID_SAVE:
  564.             dirbuf = dirbuf_save;
  565.             filebuf = filebuf_save;
  566.             saveflag = 1;
  567.             suffix = "#?.cas";
  568.             break;
  569.  
  570.         case ID_SAVE_AS:
  571.             title = GetLocaleString(MSG_SAVE_FILE);
  572.             dirbuf = dirbuf_save;
  573.             filebuf = filebuf_save;
  574.             suffix = "#?.cas";
  575.             break;
  576.  
  577.         case ID_GENERATE:
  578.             title = GetLocaleString(MSG_GENERATE_FILE);
  579.             dirbuf = dirbuf_generate;
  580.             filebuf = filebuf_generate;
  581.             suffix = "#?";
  582.             break;
  583.     }
  584.  
  585.     /* Get the Calling Objects Window */
  586.     get(MainWindow, MUIA_Window_Window, &window);
  587.  
  588.     if (frq = MUI_AllocAslRequestTags(ASL_FileRequest, TAG_DONE))
  589.     {
  590.         if (!saveflag)
  591.         {
  592.             saveflag = MUI_AslRequestTags(frq,
  593.                                           ASLFO_Window, window,
  594.                                           ASLFO_PrivateIDCMP, TRUE,
  595.                                           ASLFO_TitleText, title,
  596.                                           ASLFO_InitialLeftEdge, window->LeftEdge + window->Width / 4,
  597.                                           ASLFO_InitialTopEdge, window->TopEdge + window->Height / 8,
  598.                                           ASLFO_InitialWidth, window->Width / 2,
  599.                                           ASLFO_InitialHeight, window->Height * 6 / 8,
  600.                                           ASLFR_DoPatterns, TRUE,
  601.                                           ASLFR_InitialPattern, suffix,
  602.                                           ASLFR_InitialFile, filebuf,
  603.                                           ASLFR_InitialDrawer, dirbuf,
  604.                                           ASLFR_RejectIcons, TRUE,
  605.                                           TAG_DONE);
  606.             /* Save directory and filename */
  607.             stccpy(dirbuf, frq->fr_Drawer, 256);
  608.             stccpy(filebuf, frq->fr_File, 64);
  609.         }
  610.         stccpy(pathbuf, dirbuf, 256);
  611.         AddPart(pathbuf, filebuf, 256);
  612.  
  613.         if (saveflag)
  614.         {
  615.             switch (filemode)
  616.             {
  617.                 case ID_LOAD:
  618.                     /*************
  619.                      * Load File *
  620.                      *************/
  621.                     if (fh = fopen(pathbuf, "r"))
  622.                     {
  623.                         /* Disable list refresh */
  624.                         set(LV_SideA, MUIA_List_Quiet, TRUE);
  625.                         set(LV_SideB, MUIA_List_Quiet, TRUE);
  626.  
  627.                         /* Clear all entries */
  628.                         Clear_Cass();
  629.                         stccpy(dirbuf_save, dirbuf, 256);
  630.                         stccpy(filebuf_save, filebuf, 64);
  631.                         settitle(filebuf_save);
  632.  
  633.                         fgets(linebuf, 256, fh);
  634.                         end = atoi(linebuf);
  635.                         if (end)
  636.                         {
  637.                             set(ST_ElementTitleA, MUIA_Disabled, FALSE);
  638.                             set(ST_ElementGroupA, MUIA_Disabled, FALSE);
  639.                             set(ST_ElementExtensionA, MUIA_Disabled, FALSE);
  640.                             set(BT_RemoveA, MUIA_Disabled, FALSE);
  641.                             set(BT_UpA, MUIA_Disabled, FALSE);
  642.                             set(BT_DownA, MUIA_Disabled, FALSE);
  643.                         }
  644.                         if (end == MAX_ENTRIES)
  645.                             set(BT_AddA, MUIA_Disabled, TRUE);
  646.  
  647.                         for (i = 0; i < end; i++)
  648.                         {
  649.                             temp = fgets(linebuf, 256, fh);
  650.                             temp[strlen(temp) - 1] = '\0';
  651.                             stccpy(entry.title, temp, 30);
  652.                             temp = fgets(linebuf, 256, fh);
  653.                             temp[strlen(temp) - 1] = '\0';
  654.                             stccpy(entry.group, temp, 30);
  655.                             temp = fgets(linebuf, 256, fh);
  656.                             temp[strlen(temp) - 1] = '\0';
  657.                             stccpy(entry.extension, temp, 30);
  658.                             DoMethod(LV_SideA, MUIM_List_Insert, &entrypointer, 1,
  659.                                      MUIV_List_Insert_Bottom);
  660.                         }
  661.                         temp = fgets(linebuf, 256, fh);
  662.                         temp[strlen(temp) - 1] = '\0';
  663.                         setstring(ST_DateA, temp);
  664.                         temp = fgets(linebuf, 256, fh);
  665.                         temp[strlen(temp) - 1] = '\0';
  666.                         setstring(ST_GroupA, temp);
  667.                         temp = fgets(linebuf, 256, fh);
  668.                         temp[strlen(temp) - 1] = '\0';
  669.                         setstring(ST_TitleA, temp);
  670.  
  671.                         fgets(linebuf, 256, fh);
  672.                         setcycle(CY_SourceA, atoi(linebuf));
  673.                         fgets(linebuf, 256, fh);
  674.                         setcycle(CY_NoiseRA, atoi(linebuf));
  675.  
  676.                         fgets(linebuf, 256, fh);
  677.                         end = atoi(linebuf);
  678.                         if (end)
  679.                         {
  680.                             set(ST_ElementTitleB, MUIA_Disabled, FALSE);
  681.                             set(ST_ElementGroupB, MUIA_Disabled, FALSE);
  682.                             set(ST_ElementExtensionB, MUIA_Disabled, FALSE);
  683.                             set(BT_RemoveB, MUIA_Disabled, FALSE);
  684.                             set(BT_UpB, MUIA_Disabled, FALSE);
  685.                             set(BT_DownB, MUIA_Disabled, FALSE);
  686.                         }
  687.                         if (end == MAX_ENTRIES)
  688.                             set(BT_AddB, MUIA_Disabled, TRUE);
  689.  
  690.                         for (i = 0; i < end; i++)
  691.                         {
  692.                             temp = fgets(linebuf, 256, fh);
  693.                             temp[strlen(temp) - 1] = '\0';
  694.                             stccpy(entry.title, temp, 30);
  695.                             temp = fgets(linebuf, 256, fh);
  696.                             temp[strlen(temp) - 1] = '\0';
  697.                             stccpy(entry.group, temp, 30);
  698.                             temp = fgets(linebuf, 256, fh);
  699.                             temp[strlen(temp) - 1] = '\0';
  700.                             stccpy(entry.extension, temp, 30);
  701.                             DoMethod(LV_SideB, MUIM_List_Insert, &entrypointer, 1,
  702.                                      MUIV_List_Insert_Bottom);
  703.                         }
  704.                         temp = fgets(linebuf, 256, fh);
  705.                         temp[strlen(temp) - 1] = '\0';
  706.                         setstring(ST_DateB, temp);
  707.                         temp = fgets(linebuf, 256, fh);
  708.                         temp[strlen(temp) - 1] = '\0';
  709.                         setstring(ST_GroupB, temp);
  710.                         temp = fgets(linebuf, 256, fh);
  711.                         temp[strlen(temp) - 1] = '\0';
  712.                         setstring(ST_TitleB, temp);
  713.  
  714.                         fgets(linebuf, 256, fh);
  715.                         setcycle(CY_SourceB, atoi(linebuf));
  716.                         fgets(linebuf, 256, fh);
  717.                         setcycle(CY_NoiseRB, atoi(linebuf));
  718.  
  719.                         fgets(linebuf, 256, fh);
  720.                         setcycle(CY_Position, atoi(linebuf));
  721.                         fgets(linebuf, 256, fh);
  722.                         setcycle(CY_Length, atoi(linebuf));
  723.  
  724.                         temp = fgets(linebuf, 256, fh);
  725.                         temp[strlen(temp) - 1] = '\0';
  726.                         setstring(ST_Number, temp);
  727.  
  728.                         /* Refresh lists */
  729.                         set(LV_SideA, MUIA_List_Quiet, FALSE);
  730.                         set(LV_SideB, MUIA_List_Quiet, FALSE);
  731.                         set(LV_SideA, MUIA_List_Active, 0);
  732.                         set(LV_SideB, MUIA_List_Active, 0);
  733.                         DoMethod(LV_SideA, MUIM_List_Redraw, MUIV_List_Redraw_All);
  734.                         DoMethod(LV_SideB, MUIM_List_Redraw, MUIV_List_Redraw_All);
  735.                         ga_update(LV_SideA, GA_GaugeA);
  736.                         ga_update(LV_SideB, GA_GaugeB);
  737.                         fclose(fh);
  738.                     }
  739.                     break;
  740.  
  741.                 case ID_LOAD_OLD:
  742.                     /*****************
  743.                      * Load old File *
  744.                      *****************/
  745.                     if (fh = fopen(pathbuf, "r"))
  746.                     {
  747.                         /* Disable list refresh */
  748.                         set(LV_SideA, MUIA_List_Quiet, TRUE);
  749.                         set(LV_SideB, MUIA_List_Quiet, TRUE);
  750.  
  751.                         /* Clear all entries */
  752.                         Clear_Cass();
  753.                         stccpy(dirbuf_save, dirbuf, 256);
  754.  
  755.                         fgets(linebuf, 256, fh);
  756.                         end = atoi(linebuf);
  757.                         if (end)
  758.                         {
  759.                             set(ST_ElementTitleA, MUIA_Disabled, FALSE);
  760.                             set(ST_ElementGroupA, MUIA_Disabled, FALSE);
  761.                             set(ST_ElementExtensionA, MUIA_Disabled, FALSE);
  762.                             set(BT_RemoveA, MUIA_Disabled, FALSE);
  763.                             set(BT_UpA, MUIA_Disabled, FALSE);
  764.                             set(BT_DownA, MUIA_Disabled, FALSE);
  765.                         }
  766.                         if (end == MAX_ENTRIES)
  767.                             set(BT_AddA, MUIA_Disabled, TRUE);
  768.  
  769.                         for (i = 0; i < end; i++)
  770.                         {
  771.                             temp = fgets(linebuf, 256, fh);
  772.                             temp[strlen(temp) - 1] = '\0';
  773.                             stccpy(entry.title, temp, 30);
  774.                             DoMethod(LV_SideA, MUIM_List_Insert, &entrypointer, 1,
  775.                                      MUIV_List_Insert_Bottom);
  776.                         }
  777.                         temp = fgets(linebuf, 256, fh);
  778.                         temp[strlen(temp) - 1] = '\0';
  779.                         setstring(ST_DateA, temp);
  780.                         temp = fgets(linebuf, 256, fh);
  781.                         temp[strlen(temp) - 1] = '\0';
  782.                         setstring(ST_GroupA, temp);
  783.                         temp = fgets(linebuf, 256, fh);
  784.                         temp[strlen(temp) - 1] = '\0';
  785.                         setstring(ST_TitleA, temp);
  786.  
  787.                         fgets(linebuf, 256, fh);
  788.                         setcycle(CY_SourceA, atoi(linebuf));
  789.                         fgets(linebuf, 256, fh);
  790.                         setcycle(CY_NoiseRA, atoi(linebuf));
  791.  
  792.                         fgets(linebuf, 256, fh);
  793.                         end = atoi(linebuf);
  794.                         if (end)
  795.                         {
  796.                             set(ST_ElementTitleB, MUIA_Disabled, FALSE);
  797.                             set(ST_ElementGroupB, MUIA_Disabled, FALSE);
  798.                             set(ST_ElementExtensionB, MUIA_Disabled, FALSE);
  799.                             set(BT_RemoveB, MUIA_Disabled, FALSE);
  800.                             set(BT_UpB, MUIA_Disabled, FALSE);
  801.                             set(BT_DownB, MUIA_Disabled, FALSE);
  802.                         }
  803.                         if (end == MAX_ENTRIES)
  804.                             set(BT_AddB, MUIA_Disabled, TRUE);
  805.  
  806.                         for (i = 0; i < end; i++)
  807.                         {
  808.                             temp = fgets(linebuf, 256, fh);
  809.                             temp[strlen(temp) - 1] = '\0';
  810.                             stccpy(entry.title, temp, 30);
  811.                             DoMethod(LV_SideB, MUIM_List_Insert, &entrypointer, 1,
  812.                                      MUIV_List_Insert_Bottom);
  813.                         }
  814.                         temp = fgets(linebuf, 256, fh);
  815.                         temp[strlen(temp) - 1] = '\0';
  816.                         setstring(ST_DateB, temp);
  817.                         temp = fgets(linebuf, 256, fh);
  818.                         temp[strlen(temp) - 1] = '\0';
  819.                         setstring(ST_GroupB, temp);
  820.                         temp = fgets(linebuf, 256, fh);
  821.                         temp[strlen(temp) - 1] = '\0';
  822.                         setstring(ST_TitleB, temp);
  823.  
  824.                         fgets(linebuf, 256, fh);
  825.                         setcycle(CY_SourceB, atoi(linebuf));
  826.                         fgets(linebuf, 256, fh);
  827.                         setcycle(CY_NoiseRB, atoi(linebuf));
  828.  
  829.                         fgets(linebuf, 256, fh);
  830.                         setcycle(CY_Position, atoi(linebuf));
  831.                         fgets(linebuf, 256, fh);
  832.                         setcycle(CY_Length, atoi(linebuf));
  833.  
  834.                         temp = fgets(linebuf, 256, fh);
  835.                         temp[strlen(temp) - 1] = '\0';
  836.                         setstring(ST_Number, temp);
  837.  
  838.                         /* Refresh lists */
  839.                         set(LV_SideA, MUIA_List_Quiet, FALSE);
  840.                         set(LV_SideB, MUIA_List_Quiet, FALSE);
  841.                         set(LV_SideA, MUIA_List_Active, 0);
  842.                         set(LV_SideB, MUIA_List_Active, 0);
  843.                         DoMethod(LV_SideA, MUIM_List_Redraw, MUIV_List_Redraw_All);
  844.                         DoMethod(LV_SideB, MUIM_List_Redraw, MUIV_List_Redraw_All);
  845.                         ga_update(LV_SideA, GA_GaugeA);
  846.                         ga_update(LV_SideB, GA_GaugeB);
  847.                         fclose(fh);
  848.                     }
  849.                     break;
  850.  
  851.                 case ID_APPEND:
  852.                     /***************
  853.                      * Append Side *
  854.                      ***************/
  855.                     sourceside = MUI_Request(App, MainWindow, 0,
  856.                                              GetLocaleString(MSG_TITLE_SOURCE_SIDE),
  857.                                              GetLocaleString(MSG_QUESTION_SIDE_BUTTONS),
  858.                                              GetLocaleString(MSG_QUESTION_SOURCE_SIDE_TEXT));
  859.                     destside = MUI_Request(App, MainWindow, 0,
  860.                                            GetLocaleString(MSG_TITLE_DEST_SIDE),
  861.                                            GetLocaleString(MSG_QUESTION_SIDE_BUTTONS),
  862.                                            GetLocaleString(MSG_QUESTION_DEST_SIDE_TEXT));
  863.                     /* Side A:=1, Side B:=0 */
  864.  
  865.                     if (fh = fopen(pathbuf, "r"))
  866.                     {
  867.                         /* Disable list refresh */
  868.                         set(LV_SideA, MUIA_List_Quiet, TRUE);
  869.                         set(LV_SideB, MUIA_List_Quiet, TRUE);
  870.  
  871.                         fgets(linebuf, 256, fh);
  872.                         end = atoi(linebuf);
  873.                         if (end)
  874.                         {
  875.                             set(destside ? ST_ElementTitleA : ST_ElementTitleB, MUIA_Disabled, FALSE);
  876.                             set(destside ? ST_ElementGroupA : ST_ElementGroupB, MUIA_Disabled, FALSE);
  877.                             set(destside ? ST_ElementExtensionA : ST_ElementExtensionB, MUIA_Disabled, FALSE);
  878.                             set(destside ? BT_RemoveA : BT_RemoveB, MUIA_Disabled, FALSE);
  879.                             set(destside ? BT_UpA : BT_UpB, MUIA_Disabled, FALSE);
  880.                             set(destside ? BT_DownA : BT_DownB, MUIA_Disabled, FALSE);
  881.                         }
  882.                         get(destside ? LV_SideA : LV_SideB, MUIA_List_Entries, &end2);
  883.                         for (i = 0; i < end; i++, end2++)
  884.                         {
  885.                             temp = fgets(linebuf, 256, fh);
  886.                             temp[strlen(temp) - 1] = '\0';
  887.                             stccpy(entry.title, temp, 30);
  888.                             temp = fgets(linebuf, 256, fh);
  889.                             temp[strlen(temp) - 1] = '\0';
  890.                             stccpy(entry.group, temp, 30);
  891.                             temp = fgets(linebuf, 256, fh);
  892.                             temp[strlen(temp) - 1] = '\0';
  893.                             stccpy(entry.extension, temp, 30);
  894.                             if (sourceside && end2 < MAX_ENTRIES)
  895.                                 DoMethod(destside ? LV_SideA : LV_SideB,
  896.                                          MUIM_List_Insert, &entrypointer, 1,
  897.                                          MUIV_List_Insert_Bottom);
  898.                         }
  899.                         if (end2 >= MAX_ENTRIES)
  900.                             set(destside ? BT_AddA : BT_AddB, MUIA_Disabled, TRUE);
  901.                         fgets(linebuf, 256, fh);
  902.                         fgets(linebuf, 256, fh);
  903.                         fgets(linebuf, 256, fh);
  904.  
  905.                         fgets(linebuf, 256, fh);
  906.                         fgets(linebuf, 256, fh);
  907.  
  908.                         fgets(linebuf, 256, fh);
  909.                         end = atoi(linebuf);
  910.                         if (end)
  911.                         {
  912.                             set(destside ? ST_ElementTitleA : ST_ElementTitleB, MUIA_Disabled, FALSE);
  913.                             set(destside ? ST_ElementGroupA : ST_ElementGroupB, MUIA_Disabled, FALSE);
  914.                             set(destside ? ST_ElementExtensionA : ST_ElementExtensionB, MUIA_Disabled, FALSE);
  915.                         }
  916.                         get(destside ? LV_SideA : LV_SideB, MUIA_List_Entries, &end2);
  917.                         for (i = 0; i < end; i++, end2++)
  918.                         {
  919.                             temp = fgets(linebuf, 256, fh);
  920.                             temp[strlen(temp) - 1] = '\0';
  921.                             stccpy(entry.title, temp, 30);
  922.                             temp = fgets(linebuf, 256, fh);
  923.                             temp[strlen(temp) - 1] = '\0';
  924.                             stccpy(entry.group, temp, 30);
  925.                             temp = fgets(linebuf, 256, fh);
  926.                             temp[strlen(temp) - 1] = '\0';
  927.                             stccpy(entry.extension, temp, 30);
  928.                             if (!sourceside && end2 < MAX_ENTRIES)
  929.                                 DoMethod(destside ? LV_SideA : LV_SideB,
  930.                                          MUIM_List_Insert, &entrypointer, 1,
  931.                                          MUIV_List_Insert_Bottom);
  932.                         }
  933.                         if (end2 >= MAX_ENTRIES)
  934.                             set(destside ? BT_AddA : BT_AddB, MUIA_Disabled, TRUE);
  935.                         fclose(fh);
  936.  
  937.                         /* Refresh lists */
  938.                         set(LV_SideA, MUIA_List_Quiet, FALSE);
  939.                         set(LV_SideB, MUIA_List_Quiet, FALSE);
  940.                         set(LV_SideA, MUIA_List_Active, 0);
  941.                         set(LV_SideB, MUIA_List_Active, 0);
  942.                         DoMethod(LV_SideA, MUIM_List_Redraw, MUIV_List_Redraw_All);
  943.                         DoMethod(LV_SideB, MUIM_List_Redraw, MUIV_List_Redraw_All);
  944.                         ga_update(LV_SideA, GA_GaugeA);
  945.                         ga_update(LV_SideB, GA_GaugeB);
  946.                         /* Activate String Gadget */
  947.                         set(MainWindow, MUIA_Window_ActiveObject, destside ? ST_ElementTitleA : ST_ElementTitleB);
  948.                     }
  949.                     break;
  950.  
  951.                 case ID_SAVE:
  952.                 case ID_SAVE_AS:
  953.                     /*************
  954.                      * Save File *
  955.                      *************/
  956.                     settitle(filebuf_save);
  957.                     if (fh = fopen(pathbuf, "w"))
  958.                     {
  959.                         /* Get number of all entries of SideA */
  960.                         get(LV_SideA, MUIA_List_Entries, &end);
  961.                         fprintf(fh, "%ld\n", end);
  962.  
  963.                         for (i = 0; i < end; i++)
  964.                         {
  965.                             DoMethod(LV_SideA, MUIM_List_GetEntry, i, &entrypointer);
  966.                             fprintf(fh, "%s\n%s\n%s\n", entrypointer->title, entrypointer->group, entrypointer->extension);
  967.                         }
  968.  
  969.                         fprintf(fh, "%s\n", GetStr(ST_DateA));
  970.                         fprintf(fh, "%s\n", GetStr(ST_GroupA));
  971.                         fprintf(fh, "%s\n", GetStr(ST_TitleA));
  972.                         fprintf(fh, "%ld\n", GetCycle(CY_SourceA));
  973.                         fprintf(fh, "%ld\n", GetCycle(CY_NoiseRA));
  974.  
  975.                         /* Get number of all entries of SideB */
  976.                         get(LV_SideB, MUIA_List_Entries, &end);
  977.                         fprintf(fh, "%ld\n", end);
  978.  
  979.                         for (i = 0; i < end; i++)
  980.                         {
  981.                             DoMethod(LV_SideB, MUIM_List_GetEntry, i, &entrypointer);
  982.                             fprintf(fh, "%s\n%s\n%s\n", entrypointer->title, entrypointer->group, entrypointer->extension);
  983.                         }
  984.  
  985.                         fprintf(fh, "%s\n", GetStr(ST_DateB));
  986.                         fprintf(fh, "%s\n", GetStr(ST_GroupB));
  987.                         fprintf(fh, "%s\n", GetStr(ST_TitleB));
  988.                         fprintf(fh, "%ld\n", GetCycle(CY_SourceB));
  989.                         fprintf(fh, "%ld\n", GetCycle(CY_NoiseRB));
  990.  
  991.                         fprintf(fh, "%ld\n", GetCycle(CY_Position));
  992.                         fprintf(fh, "%ld\n", GetCycle(CY_Length));
  993.                         fprintf(fh, "%s\n", GetStr(ST_Number));
  994.  
  995.                         fclose(fh);
  996.                     }
  997.                     break;
  998.  
  999.                 case ID_GENERATE:
  1000.                     /*****************
  1001.                      * Generate File *
  1002.                      *****************/
  1003.                     stccpy(dirbuf_generate, dirbuf, 256);
  1004.                     stccpy(filebuf_generate, filebuf, 64);
  1005.                     generate_file(pathbuf);
  1006.                     break;
  1007.             }
  1008.         }
  1009.         MUI_FreeAslRequest(frq);
  1010.     }
  1011.  
  1012.     /* Wake up our Application again */
  1013.     set(App, MUIA_Application_Sleep, FALSE);
  1014. }
  1015.  
  1016. /**********************************************************************
  1017.  *                       Set the Window title                         *
  1018.  **********************************************************************/
  1019. void settitle(char *filename)
  1020. {
  1021.     static char titlebuffer[256];
  1022.  
  1023.     strcpy(titlebuffer, "CassLabel " REVISION " - ");
  1024.     if (filename)
  1025.         strcat(titlebuffer, filename);
  1026.     else
  1027.         strcat(titlebuffer, "Unnamed");
  1028.     set(MainWindow, MUIA_Window_Title, titlebuffer);
  1029. }
  1030.  
  1031.  
  1032. /**********************************************************************
  1033.  *                           Main Program                             *
  1034.  **********************************************************************/
  1035. int main(int argc, char *argv[])
  1036. {
  1037.     BOOL running = TRUE;
  1038.     unsigned long signal, open;
  1039.     char keychar[20]; /* Enough place for key shortcuts */
  1040.  
  1041.     if (argc)
  1042.     {
  1043.         /* Shell startup */
  1044.         char *temp;
  1045.         int length;
  1046.  
  1047.         GetProgramName(programpath, 256);
  1048.         temp = PathPart(programpath);
  1049.         length = temp - programpath;
  1050.         if (length > 1)
  1051.         {
  1052.             strncpy(pathname, programpath, length);
  1053.             pathname[length] = '/';
  1054.             pathname[length + 1] = '\0';
  1055.         }
  1056.         else
  1057.             pathname[0] = '\0';
  1058.     }
  1059.     else
  1060.     {
  1061.         /* Workbench startup */
  1062.         struct WBStartup *WBenchMsg = (struct WBStartup *) argv;
  1063.         BPTR tmplock;
  1064.  
  1065.         programname    = WBenchMsg->sm_ArgList->wa_Name;
  1066.         tmplock    = Lock(programname, ACCESS_READ);
  1067.         NameFromLock(tmplock, programpath, 256);
  1068.         UnLock(tmplock);
  1069.         pathname[0] = '\0';
  1070.     }
  1071.  
  1072.     /* Get real program name */
  1073.     programname = FilePart(programpath);
  1074.  
  1075.     /* Correct the path for the cassettes-files */
  1076.      strcpy(dirbuf_load, pathname);
  1077.     strcat(dirbuf_load, "Cassettes");
  1078.     strcpy(dirbuf_save, dirbuf_load);
  1079.  
  1080.     /* Get disk object */
  1081.     diskobj = GetDiskObject(programpath);
  1082.  
  1083.     /* Try to open locale - if no success, english texts are used! */
  1084.     if (LocaleBase = OpenLibrary("locale.library", 38))
  1085.         CassLabelCatalog = OpenCatalogA(NULL, "CassLabel.catalog", NULL);
  1086.  
  1087.     if (!(MUIMasterBase = OpenLibrary(MUIMASTER_NAME, 7)))
  1088.         fail(NULL, "Failed to open " MUIMASTER_NAME ".");
  1089.  
  1090.     /* Fill the localized strings into the menu structure */
  1091.     Menu[0].nm_Label = GetLocaleString(MSG_MENU_PROJECT);
  1092.     Menu[1].nm_Label = GetLocaleString(MSG_MENU_NEW);
  1093.     Menu[2].nm_Label = GetLocaleString(MSG_MENU_LOAD);
  1094.     Menu[2].nm_CommKey = GetLocaleString(MSG_MENU_LOAD_SHORTCUT);
  1095.     Menu[3].nm_Label = GetLocaleString(MSG_MENU_LOAD_OLD_FORMAT);
  1096.     Menu[4].nm_Label = GetLocaleString(MSG_MENU_APPEND);
  1097.     Menu[5].nm_Label = GetLocaleString(MSG_MENU_SAVE);
  1098.     Menu[5].nm_CommKey = GetLocaleString(MSG_MENU_SAVE_SHORTCUT);
  1099.     Menu[6].nm_Label = GetLocaleString(MSG_MENU_SAVE_AS);
  1100.     Menu[8].nm_Label = GetLocaleString(MSG_MENU_PREFERENCES);
  1101.     Menu[10].nm_Label = GetLocaleString(MSG_MENU_GENERATE);
  1102.     Menu[10].nm_CommKey = GetLocaleString(MSG_MENU_GENERATE_SHORTCUT);
  1103.     Menu[11].nm_Label = GetLocaleString(MSG_MENU_PRINT);
  1104.     Menu[11].nm_CommKey = GetLocaleString(MSG_MENU_PRINT_SHORTCUT);
  1105.     Menu[13].nm_Label = GetLocaleString(MSG_MENU_ABOUT);
  1106.     Menu[13].nm_CommKey = GetLocaleString(MSG_MENU_ABOUT_SHORTCUT);
  1107.     Menu[14].nm_Label = GetLocaleString(MSG_MENU_QUIT);
  1108.     Menu[14].nm_CommKey = GetLocaleString(MSG_MENU_QUIT_SHORTCUT);
  1109.  
  1110.     /* The Register titles */
  1111.     Pages[0] = GetLocaleString(MSG_LABEL_GLOBAL);
  1112.     Pages[1] = GetLocaleString(MSG_LABEL_SIDEA);
  1113.     Pages[2] = GetLocaleString(MSG_LABEL_SIDEB);
  1114.  
  1115.     /* Trouble with pointer conversion, so going this way */
  1116.     keychar[0] = *GetLocaleString(MSG_LABEL_POSITION_SHORTCUT);
  1117.     keychar[1] = *GetLocaleString(MSG_LABEL_LENGTH_SHORTCUT);
  1118.     keychar[2] = *GetLocaleString(MSG_LABEL_NUMBER_SHORTCUT);
  1119.     keychar[3] = *GetLocaleString(MSG_LABEL_ADD_SHORTCUT);
  1120.     keychar[4] = *GetLocaleString(MSG_LABEL_REMOVE_SHORTCUT);
  1121.     keychar[5] = *GetLocaleString(MSG_LABEL_UP_SHORTCUT);
  1122.     keychar[6] = *GetLocaleString(MSG_LABEL_DOWN_SHORTCUT);
  1123.     keychar[7] = *GetLocaleString(MSG_LABEL_PREFS_SAVE_SHORTCUT);
  1124.     keychar[8] = *GetLocaleString(MSG_LABEL_PREFS_OK_SHORTCUT);
  1125.     keychar[9] = *GetLocaleString(MSG_LABEL_PREFS_CANCEL_SHORTCUT);
  1126.     keychar[10] = *GetLocaleString(MSG_LABEL_PREFS_FORMAT_SHORTCUT);
  1127.     keychar[11] = *GetLocaleString(MSG_LABEL_PREFS_DRIVER_SHORTCUT);
  1128.     keychar[12] = *GetLocaleString(MSG_LABEL_PREFS_TR_SHORTCUT);
  1129.     keychar[13] = *GetLocaleString(MSG_LABEL_PREFS_HELP_SHORTCUT);
  1130.  
  1131.     App = ApplicationObject,
  1132.         MUIA_Application_Title, "CassLabel",
  1133.         MUIA_Application_Version, "$VER: CassLabel " REVISION " " __AMIGADATE__,
  1134.         MUIA_Application_Copyright, GetLocaleString(MSG_ABOUT_COPYRIGHT),
  1135.         MUIA_Application_Author, "Dirk Nehring",
  1136.         MUIA_Application_Description, GetLocaleString(MSG_ABOUT_PROGRAM),
  1137.         MUIA_Application_Base, "CassLabel",
  1138.         MUIA_Application_SingleTask, TRUE,
  1139.         MUIA_Application_Menu, Menu,
  1140.         MUIA_Application_DiskObject, diskobj,
  1141.         MUIA_HelpFile, GUIDEFILE,
  1142.  
  1143.         SubWindow, MainWindow = WindowObject,
  1144.             MUIA_Window_ID, MAKE_ID('M', 'A', 'I', 'N'),
  1145.             MUIA_HelpNode, NODE_MAIN,
  1146.             WindowContents, VGroup,
  1147.                 Child, TextObject,
  1148.                     TextFrame,
  1149.                     MUIA_Background, MUII_FILLBACK,
  1150.                     MUIA_Text_Contents, GetLocaleString(MSG_WINDOW_TITLE),
  1151.                     End,
  1152.                 Child, VSpace(2),
  1153.                 Child, RegisterGroup(Pages),
  1154.                     Child, VGroup,
  1155.                         Child, ColGroup(2), GroupFrameT(GetLocaleString(MSG_LABEL_SIDEA)),
  1156.                             Child, Label2(GetLocaleString(MSG_LABEL_TITLE)),
  1157.                             Child, ST_TitleA = StringObject,
  1158.                                 StringFrame,
  1159.                                 MUIA_String_MaxLen, MAXLENGTH_ENTRY,
  1160.                                 End,
  1161.                             Child, Label2(GetLocaleString(MSG_LABEL_GROUP)),
  1162.                             Child, ST_GroupA = StringObject,
  1163.                                 StringFrame,
  1164.                                 MUIA_String_MaxLen, MAXLENGTH_ENTRY,
  1165.                                 End,
  1166.                             Child, Label2(GetLocaleString(MSG_LABEL_DATE)),
  1167.                             Child, HGroup,
  1168.                                 Child, ST_DateA = StringObject,
  1169.                                     MUIA_String_Accept, "1234567890.",
  1170.                                     MUIA_String_MaxLen, 11,
  1171.                                     MUIA_FixWidthTxt, "00.00.00000",
  1172.                                     StringFrame,
  1173.                                     End,
  1174.                                 Child, HSpace(0),
  1175.                                 End,
  1176.                             Child, Label2(GetLocaleString(MSG_LABEL_SOURCE)),
  1177.                             Child, HGroup,
  1178.                                 Child, CY_SourceA = KeyCycle(CYA_Source, 0),
  1179.                                 Child, Label2(GetLocaleString(MSG_LABEL_NOISER)),
  1180.                                 Child, CY_NoiseRA = KeyCycle(CYA_NoiseR, 0),
  1181.                                 End,
  1182.                             End,
  1183.                         Child, VSpace(0),
  1184.                         Child, ColGroup(2), GroupFrameT(GetLocaleString(MSG_LABEL_SIDEB)),
  1185.                             Child, Label2(GetLocaleString(MSG_LABEL_TITLE)),
  1186.                             Child, ST_TitleB = StringObject,
  1187.                                 StringFrame,
  1188.                                 MUIA_String_MaxLen, MAXLENGTH_ENTRY,
  1189.                                 End,
  1190.                             Child, Label2(GetLocaleString(MSG_LABEL_GROUP)),
  1191.                             Child, ST_GroupB = StringObject,
  1192.                                 StringFrame,
  1193.                                 MUIA_String_MaxLen, MAXLENGTH_ENTRY,
  1194.                                 End,
  1195.                             Child, Label2(GetLocaleString(MSG_LABEL_DATE)),
  1196.                             Child, HGroup,
  1197.                                 Child, ST_DateB = StringObject,
  1198.                                     MUIA_String_Accept, "1234567890.",
  1199.                                     MUIA_String_MaxLen, 11,
  1200.                                     MUIA_FixWidthTxt, "00.00.00000",
  1201.                                     StringFrame,
  1202.                                     End,
  1203.                                 Child, HSpace(0),
  1204.                                 End,
  1205.                             Child, Label2(GetLocaleString(MSG_LABEL_SOURCE)),
  1206.                             Child, HGroup,
  1207.                                 Child, CY_SourceB = KeyCycle(CYA_Source, 0),
  1208.                                 Child, Label2(GetLocaleString(MSG_LABEL_NOISER)),
  1209.                                 Child, CY_NoiseRB = KeyCycle(CYA_NoiseR, 0),
  1210.                                 End,
  1211.                             End,
  1212.                         Child, VSpace(0),
  1213.                         Child, VSpace(0),
  1214.                         Child, HGroup, GroupFrame,
  1215.                             Child, KeyLabel2(GetLocaleString(MSG_LABEL_POSITION), keychar[0]),
  1216.                             Child, CY_Position = KeyCycle(CYA_Position, keychar[0]),
  1217.                             Child, KeyLabel2(GetLocaleString(MSG_LABEL_LENGTH), keychar[1]),
  1218.                             Child, CY_Length = KeyCycle(CYA_Length, keychar[1]),
  1219.                             Child, KeyLabel2(GetLocaleString(MSG_LABEL_NUMBER), keychar[2]),
  1220.                             Child, ST_Number = StringObject,
  1221.                                 MUIA_ControlChar, keychar[2],
  1222.                                 MUIA_String_Accept, "1234567890",
  1223.                                 MUIA_String_MaxLen, 4,
  1224.                                 MUIA_FixWidthTxt, "0000",
  1225.                                 StringFrame,
  1226.                                 End,
  1227.                             End,
  1228.                         End,
  1229.                     Child, VGroup,
  1230.                         Child, HGroup,
  1231.                             Child, GA_GaugeA = GaugeObject,
  1232.                                 GaugeFrame,
  1233.                                 MUIA_FixWidth, 8,
  1234.                                 MUIA_Gauge_Max, MAX_ENTRIES,
  1235.                                 End,
  1236.                             Child, LV_SideA = ListviewObject,
  1237.                                 MUIA_Listview_Input, TRUE,
  1238.                                 MUIA_Listview_List, ListObject,
  1239.                                     InputListFrame,
  1240.                                     MUIA_List_ConstructHook, &ConstructHook,
  1241.                                     MUIA_List_DestructHook, &DestructHook,
  1242.                                     MUIA_List_DisplayHook, &DisplayHook,
  1243.                                     MUIA_List_Format, "MAW=100,P=\033r D=8, P=\033r\0338",
  1244.                                     End,
  1245.                                 End,
  1246.                             End,
  1247.                         Child, HGroup, GroupSpacing(0), MUIA_Group_SameSize, TRUE,
  1248.                             Child, BT_AddA = KeyButton(GetLocaleString(MSG_LABEL_ADD), keychar[3]),
  1249.                             Child, BT_RemoveA = KeyButton(GetLocaleString(MSG_LABEL_REMOVE), keychar[4]),
  1250.                             Child, BT_UpA = KeyButton(GetLocaleString(MSG_LABEL_UP), keychar[5]),
  1251.                             Child, BT_DownA = KeyButton(GetLocaleString(MSG_LABEL_DOWN), keychar[6]),
  1252.                             End,
  1253.                         Child, ColGroup(2),
  1254.                             Child, Label2(GetLocaleString(MSG_LABEL_TITLE)),
  1255.                             Child, ST_ElementTitleA = StringObject,
  1256.                                 StringFrame,
  1257.                                 MUIA_String_MaxLen, MAXLENGTH_ENTRY,
  1258.                                 End,
  1259.                             Child, Label2(GetLocaleString(MSG_LABEL_GROUP)),
  1260.                             Child, ST_ElementGroupA = StringObject,
  1261.                                 StringFrame,
  1262.                                 End,
  1263.                             Child, Label2(GetLocaleString(MSG_LABEL_EXTENSION)),
  1264.                             Child, ST_ElementExtensionA = StringObject,
  1265.                                 StringFrame,
  1266.                                 End,
  1267.                             End,
  1268.                         End,
  1269.                     Child, VGroup,
  1270.                         Child, HGroup,
  1271.                             Child, GA_GaugeB = GaugeObject,
  1272.                                 GaugeFrame,
  1273.                                 MUIA_FixWidth, 8,
  1274.                                 MUIA_Gauge_Max, MAX_ENTRIES,
  1275.                                 End,
  1276.                             Child, LV_SideB = ListviewObject,
  1277.                                 MUIA_Listview_Input, TRUE,
  1278.                                 MUIA_Listview_List, ListObject,
  1279.                                     InputListFrame,
  1280.                                     MUIA_List_ConstructHook, &ConstructHook,
  1281.                                     MUIA_List_DestructHook, &DestructHook,
  1282.                                     MUIA_List_DisplayHook, &DisplayHook,
  1283.                                     MUIA_List_Format, "MAW=100,P=\033r D=8,P=\033r\0338",
  1284.                                     End,
  1285.                                 End,
  1286.                             End,
  1287.                         Child, HGroup, GroupSpacing(0), MUIA_Group_SameSize, TRUE,
  1288.                             Child, BT_AddB = KeyButton(GetLocaleString(MSG_LABEL_ADD), keychar[3]),
  1289.                             Child, BT_RemoveB = KeyButton(GetLocaleString(MSG_LABEL_REMOVE), keychar[4]),
  1290.                             Child, BT_UpB = KeyButton(GetLocaleString(MSG_LABEL_UP), keychar[5]),
  1291.                             Child, BT_DownB = KeyButton(GetLocaleString(MSG_LABEL_DOWN), keychar[6]),
  1292.                             End,
  1293.                         Child, ColGroup(2),
  1294.                             Child, Label2(GetLocaleString(MSG_LABEL_TITLE)),
  1295.                             Child, ST_ElementTitleB = StringObject,
  1296.                                 StringFrame,
  1297.                                 MUIA_String_MaxLen, MAXLENGTH_ENTRY,
  1298.                                 End,
  1299.                             Child, Label2(GetLocaleString(MSG_LABEL_GROUP)),
  1300.                             Child, ST_ElementGroupB = StringObject,
  1301.                                 StringFrame,
  1302.                                 End,
  1303.                             Child, Label2(GetLocaleString(MSG_LABEL_EXTENSION)),
  1304.                             Child, ST_ElementExtensionB = StringObject,
  1305.                                 StringFrame,
  1306.                                 End,
  1307.                             End,
  1308.                         End,
  1309.                     End,
  1310.                 End,
  1311.             End,
  1312.         SubWindow, PrefsWindow = WindowObject,
  1313.             MUIA_Window_Title, GetLocaleString(MSG_LABEL_PREFS_TITLE),
  1314.             MUIA_Window_ID, MAKE_ID('P', 'R', 'E', 'F'),
  1315.             MUIA_Window_NoMenus, TRUE,
  1316.             MUIA_HelpNode, NODE_PREFS,
  1317.             WindowContents, VGroup,
  1318.                 Child, VGroup,
  1319.                     Child, ColGroup(2), GroupFrame,
  1320.                         Child, KeyLabel2(GetLocaleString(MSG_LABEL_PREFS_FORMAT), keychar[10]),
  1321.                         Child, PS_PopFormat = PopaslObject,
  1322.                             MUIA_Popstring_String, PS_PopFormat_String = StringObject,
  1323.                                 StringFrame,
  1324.                                 MUIA_ControlChar, keychar[10],
  1325.                                 MUIA_String_MaxLen, 256,
  1326.                                 MUIA_ExportID, 1,
  1327.                                 End,
  1328.                             MUIA_Popstring_Button, PopButton(MUII_PopFile),
  1329.                             ASLFR_TitleText, GetLocaleString(MSG_LABEL_PREFS_FORMAT),
  1330.                             ASLFR_DoPatterns, TRUE,
  1331.                             ASLFR_InitialPattern, "#?.form",
  1332.                             End,
  1333.                         Child, KeyLabel2(GetLocaleString(MSG_LABEL_PREFS_DRIVER), keychar[11]),
  1334.                         Child, PS_PopDriver = PopaslObject,
  1335.                             MUIA_Popstring_String, PS_PopDriver_String = StringObject,
  1336.                                 StringFrame,
  1337.                                 MUIA_ControlChar, keychar[11],
  1338.                                 MUIA_String_MaxLen, 256,
  1339.                                 MUIA_ExportID, 2,
  1340.                                 End,
  1341.                             MUIA_Popstring_Button, PopButton(MUII_PopFile),
  1342.                             ASLFR_TitleText, GetLocaleString(MSG_LABEL_PREFS_DRIVER),
  1343.                             ASLFR_DoPatterns, TRUE,
  1344.                             ASLFR_InitialPattern, "#?.drv",
  1345.                             End,
  1346.                         Child, KeyLabel1(GetLocaleString(MSG_LABEL_PREFS_TR), keychar[12]),
  1347.                         Child, HGroup,
  1348.                             Child, CM_Translate = ImageObject,
  1349.                                 ImageButtonFrame,
  1350.                                 MUIA_InputMode, MUIV_InputMode_Toggle,
  1351.                                 MUIA_Image_Spec, MUII_CheckMark,
  1352.                                 MUIA_Background, MUII_ButtonBack,
  1353.                                 MUIA_ShowSelState, FALSE,
  1354.                                 MUIA_ControlChar, keychar[12],
  1355.                                 MUIA_ExportID, 3,
  1356.                                 End,
  1357.                             Child, HSpace(0),
  1358.                             Child, BT_PrefsHelp = KeyButton(GetLocaleString(MSG_LABEL_PREFS_HELP), keychar[13]),
  1359.                             End,
  1360.                         End,                    
  1361.                     Child, HGroup, GroupFrame, MUIA_Group_SameSize, TRUE,
  1362.                         Child, BT_PrefsSave = KeyButton(GetLocaleString(MSG_LABEL_PREFS_SAVE), keychar[7]),
  1363.                         Child, BT_PrefsOK = KeyButton(GetLocaleString(MSG_LABEL_PREFS_OK), keychar[8]),
  1364.                         Child, BT_PrefsCancel = KeyButton(GetLocaleString(MSG_LABEL_PREFS_CANCEL), keychar[9]),
  1365.                         End,
  1366.                     End,
  1367.                 End,
  1368.             End,
  1369.         End;
  1370.  
  1371.     /* Error when we declare the Application? */
  1372.     if (!App)
  1373.         fail(App, GetLocaleString(MSG_ERROR_APP));
  1374.  
  1375.     /**************
  1376.      * MainWindow *
  1377.      **************/
  1378.     /* Close Connection */
  1379.     DoMethod(MainWindow, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, App, 2,
  1380.              MUIM_Application_ReturnID, ID_QUIT);
  1381.     DoMethod(MainWindow, MUIM_Notify, MUIA_Window_InputEvent, "control c",
  1382.              App, 2, MUIM_Application_ReturnID, ID_QUIT);
  1383.  
  1384.     /* Control the list manipulation buttons */
  1385.     DoMethod(LV_SideA, MUIM_Notify, MUIA_List_Active, MUIV_EveryTime, App, 2,
  1386.              MUIM_Application_ReturnID, ID_LISTA);
  1387.     DoMethod(ST_ElementTitleA, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
  1388.              App, 2, MUIM_Application_ReturnID, ID_ELEMENTTITLEA);
  1389.     DoMethod(ST_ElementGroupA, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
  1390.              App, 2, MUIM_Application_ReturnID, ID_ELEMENTGROUPA);
  1391.     DoMethod(ST_ElementExtensionA, MUIM_Notify, MUIA_String_Acknowledge,
  1392.              MUIV_EveryTime, App, 2, MUIM_Application_ReturnID, ID_ELEMENTEXTENSIONA);
  1393.     DoMethod(BT_AddA, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
  1394.              MUIM_Application_ReturnID, ID_ADDA);
  1395.     DoMethod(BT_RemoveA, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
  1396.              MUIM_Application_ReturnID, ID_REMOVEA);
  1397.     DoMethod(BT_UpA, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
  1398.              MUIM_Application_ReturnID, ID_UPA);
  1399.     DoMethod(BT_DownA, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
  1400.              MUIM_Application_ReturnID, ID_DOWNA);
  1401.  
  1402.     DoMethod(LV_SideB, MUIM_Notify, MUIA_List_Active, MUIV_EveryTime, App, 2,
  1403.              MUIM_Application_ReturnID, ID_LISTB);
  1404.     DoMethod(ST_ElementTitleB, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
  1405.              App, 2, MUIM_Application_ReturnID, ID_ELEMENTTITLEB);
  1406.     DoMethod(ST_ElementGroupB, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
  1407.              App, 2, MUIM_Application_ReturnID, ID_ELEMENTGROUPB);
  1408.     DoMethod(ST_ElementExtensionB, MUIM_Notify, MUIA_String_Acknowledge,
  1409.              MUIV_EveryTime, App, 2, MUIM_Application_ReturnID, ID_ELEMENTEXTENSIONB);
  1410.     DoMethod(BT_AddB, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
  1411.              MUIM_Application_ReturnID, ID_ADDB);
  1412.     DoMethod(BT_RemoveB, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
  1413.              MUIM_Application_ReturnID, ID_REMOVEB);
  1414.     DoMethod(BT_UpB, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
  1415.              MUIM_Application_ReturnID, ID_UPB);
  1416.     DoMethod(BT_DownB, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
  1417.              MUIM_Application_ReturnID, ID_DOWNB);
  1418.  
  1419.     /* Cycle chain for keyboard control */
  1420.     DoMethod(MainWindow, MUIM_Window_SetCycleChain, ST_TitleA, ST_GroupA,
  1421.              ST_DateA, CY_SourceA, CY_NoiseRA, ST_TitleB, ST_GroupB,
  1422.              ST_DateB, CY_SourceB, CY_NoiseRB, CY_Position, CY_Length,
  1423.              ST_Number, ST_ElementTitleA, ST_ElementGroupA,ST_ElementExtensionA,
  1424.              BT_AddA, BT_RemoveA, BT_UpA, BT_DownA, ST_ElementTitleB,
  1425.              ST_ElementGroupB, ST_ElementExtensionB, BT_AddB, BT_RemoveB, BT_UpB,
  1426.              BT_DownB, NULL);
  1427.  
  1428.     DoMethod(PrefsWindow, MUIM_Window_SetCycleChain, PS_PopFormat,
  1429.              PS_PopDriver, CM_Translate, BT_PrefsSave, BT_PrefsOK, BT_PrefsCancel,
  1430.              NULL);
  1431.  
  1432.     /* Concatenate strings, <return> will activate the next one */
  1433.     DoMethod(ST_TitleA, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
  1434.              MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, ST_GroupA);
  1435.     DoMethod(ST_GroupA, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
  1436.              MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, ST_DateA);
  1437.     DoMethod(ST_DateA, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
  1438.              MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, ST_TitleB);
  1439.     DoMethod(ST_TitleB, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
  1440.              MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, ST_GroupB);
  1441.     DoMethod(ST_GroupB, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
  1442.              MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, ST_DateB);
  1443.     DoMethod(ST_DateB, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
  1444.              MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, ST_Number);
  1445.     DoMethod(ST_Number, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
  1446.              MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, ST_TitleA);
  1447.  
  1448.     DoMethod(ST_ElementTitleA, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
  1449.              MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, ST_ElementGroupA);
  1450.     DoMethod(ST_ElementGroupA, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
  1451.              MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, ST_ElementExtensionA);
  1452.     DoMethod(ST_ElementTitleB, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
  1453.              MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, ST_ElementGroupB);
  1454.     DoMethod(ST_ElementGroupB, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
  1455.              MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, ST_ElementExtensionB);
  1456.  
  1457.     DoMethod(PS_PopFormat, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
  1458.              MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, PS_PopDriver);
  1459.     DoMethod(PS_PopDriver, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
  1460.              MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, PS_PopFormat);
  1461.  
  1462.     /* Load the settings */
  1463.     DoMethod(App, MUIM_Application_Load, MUIV_Application_Load_ENV);
  1464.  
  1465.     /***************
  1466.      * PrefsWindow *
  1467.      ***************/
  1468.     /* Close Request */
  1469.     DoMethod(PrefsWindow, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, App, 2,
  1470.              MUIM_Application_ReturnID, ID_PREFS_QUIT);
  1471.  
  1472.     /* On OK, first save the prefs to ENV: */
  1473.     DoMethod(BT_PrefsOK, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
  1474.              MUIM_Application_Save, MUIV_Application_Save_ENV);
  1475.  
  1476.     /* Then quit the preferences */
  1477.     DoMethod(BT_PrefsOK, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
  1478.              MUIM_Application_ReturnID, ID_PREFS_QUIT);
  1479.  
  1480.     /* On SAVE, save both to ENV: and ENVARC: */
  1481.     DoMethod(BT_PrefsSave, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
  1482.              MUIM_Application_Save, MUIV_Application_Save_ENV);
  1483.     DoMethod(BT_PrefsSave, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
  1484.             MUIM_Application_Save, MUIV_Application_Save_ENVARC);
  1485.  
  1486.     /* Then quit the preferences */
  1487.     DoMethod(BT_PrefsSave, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
  1488.              MUIM_Application_ReturnID, ID_PREFS_QUIT);
  1489.  
  1490.     /* On Cancel, simply close the window */
  1491.     DoMethod(BT_PrefsCancel, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
  1492.              MUIM_Application_ReturnID, ID_PREFS_QUIT);
  1493.  
  1494.     /* Help on Format */
  1495.     DoMethod(BT_PrefsHelp, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
  1496.              MUIM_Application_ReturnID, ID_PREFS_HELP);
  1497.  
  1498.     /********************
  1499.      * Startup Settings *
  1500.      ********************/
  1501.     set(LV_SideA, MUIA_List_Active, 0);
  1502.     set(LV_SideB, MUIA_List_Active, 0);
  1503.     set(ST_ElementTitleA, MUIA_String_AttachedList, LV_SideA);
  1504.     set(ST_ElementGroupA, MUIA_String_AttachedList, LV_SideA);
  1505.     set(ST_ElementExtensionA, MUIA_String_AttachedList, LV_SideA);
  1506.     set(ST_ElementTitleB, MUIA_String_AttachedList, LV_SideB);
  1507.     set(ST_ElementGroupB, MUIA_String_AttachedList, LV_SideB);
  1508.     set(ST_ElementExtensionB, MUIA_String_AttachedList, LV_SideB);
  1509.     set(ST_ElementTitleA, MUIA_Disabled, TRUE);
  1510.     set(ST_ElementGroupA, MUIA_Disabled, TRUE);
  1511.     set(ST_ElementExtensionA, MUIA_Disabled, TRUE);
  1512.     set(BT_RemoveA, MUIA_Disabled, TRUE);
  1513.     set(BT_UpA, MUIA_Disabled, TRUE);
  1514.     set(BT_DownA, MUIA_Disabled, TRUE);
  1515.     set(ST_ElementTitleB, MUIA_Disabled, TRUE);
  1516.     set(ST_ElementGroupB, MUIA_Disabled, TRUE);
  1517.     set(ST_ElementExtensionB, MUIA_Disabled, TRUE);
  1518.     set(BT_RemoveB, MUIA_Disabled, TRUE);
  1519.     set(BT_UpB, MUIA_Disabled, TRUE);
  1520.     set(BT_DownB, MUIA_Disabled, TRUE);
  1521.     setcycle(CY_Position, 1);
  1522.     setcycle(CY_Length, 2);
  1523.     set(MainWindow, MUIA_Window_Open, TRUE);
  1524.     settitle(NULL);
  1525.  
  1526.     /* Is the Main Window opened? */
  1527.     get(MainWindow, MUIA_Window_Open, &open);
  1528.     if (!open)
  1529.         fail(App, GetLocaleString(MSG_ERROR_WINDOW));
  1530.  
  1531.     /*****************
  1532.      * IDMCP-Handler *
  1533.      *****************/
  1534.     while (running)
  1535.     {
  1536.         switch (DoMethod(App, MUIM_Application_Input, &signal))
  1537.         {
  1538.             case ID_QUIT:
  1539.             case MUIV_Application_ReturnID_Quit:
  1540.                 if (MUI_Request(App, MainWindow, 0, NULL,
  1541.                     GetLocaleString(MSG_QUESTION_QUIT_BUTTONS),
  1542.                     GetLocaleString(MSG_QUESTION_QUIT_TEXT)))
  1543.                     running = FALSE;
  1544.                 break;
  1545.  
  1546.             case ID_NEW:
  1547.                 Clear_Cass();
  1548.                 break;
  1549.  
  1550.             case ID_LOAD:
  1551.                 File_Cass(ID_LOAD);
  1552.                 break;
  1553.  
  1554.             case ID_LOAD_OLD:
  1555.                 File_Cass(ID_LOAD_OLD);
  1556.                 break;
  1557.  
  1558.             case ID_APPEND:
  1559.                 File_Cass(ID_APPEND);
  1560.                 break;
  1561.  
  1562.             case ID_SAVE:
  1563.                 if (filebuf_save[0] != '\0')
  1564.                     File_Cass(ID_SAVE);
  1565.                 else
  1566.                     File_Cass(ID_SAVE_AS);
  1567.                 break;
  1568.  
  1569.             case ID_SAVE_AS:
  1570.                 File_Cass(ID_SAVE_AS);
  1571.                 break;
  1572.  
  1573.             case ID_GENERATE:
  1574.                 File_Cass(ID_GENERATE);
  1575.                 break;
  1576.  
  1577.             case ID_PRINT:
  1578.                 print();
  1579.                 break;
  1580.  
  1581.             case ID_ABOUT:
  1582.                 MUI_Request(App, MainWindow, 0, GetLocaleString(MSG_MENU_ABOUT), "*OK",
  1583.                             "\033c\0338CassLabel\0332\n\n"
  1584.                             "\0332CassLabel V" REVISION " (" REVDATE ", " REVTIME " )"
  1585.                             "\n%s%s%s%s%s%s%s%s",
  1586.                             GetLocaleString(MSG_ABOUT_COPYRIGHT),
  1587.                             "\n\nDirk Nehring\n",
  1588.                             "Hörster Bruch 57\n",
  1589.                             "D-32791 Lage\n",
  1590.                             "GERMANY\n",
  1591.                             "Phone: +49-5232-89130\n",
  1592.                             "E-Mail: dnehring@TechFak.Uni-Bielefeld.DE\n\n",
  1593.                             GetLocaleString(MSG_ABOUT_MUIAPPLICATION),
  1594.                             GetLocaleString(MSG_ABOUT_MUICOPYRIGHT));
  1595.                 break;
  1596.  
  1597.             case ID_LISTA:
  1598.                 {
  1599.                     long end;
  1600.                     get(LV_SideA, MUIA_List_Entries, &end);
  1601.                     if (end)
  1602.                         lv_copy(LV_SideA, ST_ElementTitleA, ST_ElementGroupA, ST_ElementExtensionA);
  1603.                     else
  1604.                     {
  1605.                         setstring(ST_ElementTitleA, "");
  1606.                         setstring(ST_ElementGroupA, "");
  1607.                         setstring(ST_ElementExtensionA, "");
  1608.                     }
  1609.                 }
  1610.                 break;
  1611.  
  1612.             case ID_ELEMENTTITLEA:
  1613.             case ID_ELEMENTGROUPA:
  1614.             case ID_ELEMENTEXTENSIONA:
  1615.                 lv_edit(LV_SideA, ST_ElementTitleA, ST_ElementGroupA, ST_ElementExtensionA);
  1616.                 break;
  1617.  
  1618.             case ID_REMOVEA:
  1619.                 lv_remove(LV_SideA, ST_ElementTitleA, ST_ElementGroupA, ST_ElementExtensionA, BT_AddA, BT_RemoveA, BT_UpA, BT_DownA, GA_GaugeA);
  1620.                 break;
  1621.  
  1622.             case ID_ADDA:
  1623.                 lv_add(LV_SideA, ST_ElementTitleA, ST_ElementGroupA, ST_ElementExtensionA, BT_AddA, BT_RemoveA, BT_UpA, BT_DownA, GA_GaugeA);
  1624.                 break;
  1625.  
  1626.             case ID_UPA:
  1627.                 lv_up(LV_SideA);
  1628.                 break;
  1629.  
  1630.             case ID_DOWNA:
  1631.                 lv_down(LV_SideA);
  1632.                 break;
  1633.  
  1634.             case ID_LISTB:
  1635.                 {
  1636.                     long end;
  1637.                     get(LV_SideB, MUIA_List_Entries, &end);
  1638.                     if (end)
  1639.                         lv_copy(LV_SideB, ST_ElementTitleB, ST_ElementGroupB, ST_ElementExtensionB);
  1640.                     else
  1641.                     {
  1642.                         setstring(ST_ElementTitleB, "");
  1643.                         setstring(ST_ElementGroupB, "");
  1644.                         setstring(ST_ElementExtensionB, "");
  1645.                     }
  1646.                 }
  1647.                 break;
  1648.  
  1649.             case ID_ELEMENTTITLEB:
  1650.             case ID_ELEMENTGROUPB:
  1651.             case ID_ELEMENTEXTENSIONB:
  1652.                 lv_edit(LV_SideB, ST_ElementTitleB, ST_ElementGroupB, ST_ElementExtensionB);
  1653.                 break;
  1654.  
  1655.             case ID_REMOVEB:
  1656.                 lv_remove(LV_SideB, ST_ElementTitleB, ST_ElementGroupB, ST_ElementExtensionB, BT_AddB, BT_RemoveB, BT_UpB, BT_DownB, GA_GaugeB);
  1657.                 break;
  1658.  
  1659.             case ID_ADDB:
  1660.                 lv_add(LV_SideB, ST_ElementTitleB, ST_ElementGroupB, ST_ElementExtensionB, BT_AddB, BT_RemoveB, BT_UpB, BT_DownB, GA_GaugeB);
  1661.                 break;
  1662.  
  1663.             case ID_UPB:
  1664.                 lv_up(LV_SideB);
  1665.                 break;
  1666.  
  1667.             case ID_DOWNB:
  1668.                 lv_down(LV_SideB);
  1669.                 break;
  1670.  
  1671.             case ID_PREFS:
  1672.                 set(PrefsWindow, MUIA_Window_Open, TRUE);
  1673.                 break;
  1674.  
  1675.             case ID_PREFS_QUIT:
  1676.                 set(PrefsWindow, MUIA_Window_Open, FALSE);
  1677.                 DoMethod(App, MUIM_Application_Load, MUIV_Application_Load_ENV);
  1678.                 set(MainWindow, MUIA_Window_Activate, TRUE);
  1679.                 break;
  1680.  
  1681.             case ID_PREFS_HELP:
  1682.                 MUI_Request(App, MainWindow, 0, GetLocaleString(MSG_LABEL_PREFS_HELP), "*OK",
  1683.                             "\033c\0338CassLabel Format Documentation\0332\n\n"
  1684.                             "\033l\033bASCII:\033n Very naiv output\n"
  1685.                             "\033bStandard:\033n Date/NR/Src on the same page as the songs\n"
  1686.                             "\033bEnhanced:\033n Date/NR/Src on the back side\n"
  1687.                             "\033bRotated:\033n Cover is rotated by 180 degrees, but like Enhanced\n\n"
  1688.                             "\033c\0338The format filename\0332\n"
  1689.                             "\033l_{1|2|T|G|E} means\n"
  1690.                             "1: One group/title\n"
  1691.                             "2: Two groups/titles\n"
  1692.                             "T: songs\n"
  1693.                             "G: groups\n"
  1694.                             "E: extensions\n\n"
  1695.                             "\033c\0338Examples\0332\n"
  1696.                             "\033l\033bLaTeX-Standard_2+T+G\033n means 2 titles on top side and\n"
  1697.                             "every song has a group separatly\n"
  1698.                             "\033bASCII_1+T+E\033n means 1 group/title on the top side and\n"
  1699.                             "every song has an extension, but no group\n");
  1700.                 break;
  1701.         }
  1702.         if (running && signal)
  1703.             Wait(signal);
  1704.     }
  1705.     fail(App, NULL);
  1706. }
  1707.