home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d9xx / d952 / machv.lha / MachV / programmer.lha / vars / list_example.c next >
C/C++ Source or Header  |  1993-08-07  |  2KB  |  69 lines

  1. /* List_Example  1.0  08-07-93
  2.  
  3.    Simple program to demonstrate how to open a window with a list of macro
  4.    names.
  5.  
  6.    sc list_example
  7.    slink lib:c.o list_example.o lib lib:sc.lib lib:amiga.lib
  8.  
  9.  
  10. */
  11.  
  12. #include <stdio.h>                                                       
  13. #include <ctype.h>                                                       
  14. #include <exec/types.h>
  15. #include <exec/libraries.h>
  16. #include <proto/exec.h>
  17. #include <exec/semaphores.h>
  18. #include "/headers/mach.h"
  19. #include "/headers/machlib.h"                                            
  20. #include "/headers/machlib_protos.h"                                     
  21. #include "/headers/machlib_pragmas.h"                                    
  22.  
  23. struct MachLibrary *MachBase;                                            
  24.  
  25. /* This lets you call OpenListWindow() with a variable number of tags. */
  26.  
  27. BOOL OpenListWindowTags(ULONG tags,...);
  28.  
  29. BOOL OpenListWindowTags(ULONG tags,...)
  30. {
  31.     return(OpenListWindow((struct TagItem *)&tags));
  32. }
  33.  
  34. main(int argc, char **argv)                                              
  35. {                                                                        
  36.     struct TaskInfo list_task_info;
  37.     LONG listsig_nr;
  38.     ULONG list_sig;
  39.  
  40.     MachBase = (struct MachLibrary*)OpenLibrary("mach.library",37L); 
  41.     if (MachBase) {                                                  
  42.         if ((listsig_nr = AllocSignal(-1L)) != -1L) {
  43.             list_sig = 1 << listsig_nr;
  44.             list_task_info.Task = FindTask(NULL);
  45.             list_task_info.Sig = list_sig;
  46.  
  47.             /* Open list window listing macro names */
  48.  
  49.             if (OpenListWindowTags(LIST_TaskInfo,    (ULONG)&list_task_info,
  50.                                    LIST_Type,        LIST_MACRONAMES,
  51.                                    LIST_Title,        (ULONG)"Macro Names",
  52.                                    TAG_DONE)) {
  53.  
  54.                 /* Wait for selection, ok, cancel or close window */
  55.  
  56.                 Wait(list_sig);
  57.  
  58.                 FreeSignal(listsig_nr);
  59.  
  60.                 if (MachBase->ml_ListSelection ) 
  61.                     printf("Selected %s\n",MachBase->ml_ListSelection);
  62.                 else
  63.                     printf("No selection\n" );
  64.             }
  65.         }
  66.         CloseLibrary((struct Library*)MachBase);                     
  67.     }                                                                
  68. }                                                                        
  69.