Fix IRQ name
[AROS.git] / workbench / demos / filereq.c
blob53f7343e541709017da476f339951b807df99b86
1 ;/* filereq.c - Execute me to compile me with SASC 5.10
2 LC -b1 -cfistq -v -y -j73 filereq.c
3 Blink FROM LIB:c.o,filereq.o TO filereq LIBRARY LIB:LC.lib,LIB:Amiga.lib
4 quit
5 */
7 /*
8 Copyright (c) 1992 Commodore-Amiga, Inc.
10 This example is provided in electronic form by Commodore-Amiga, Inc. for
11 use with the "Amiga ROM Kernel Reference Manual: Libraries", 3rd Edition,
12 published by Addison-Wesley (ISBN 0-201-56774-1).
14 The "Amiga ROM Kernel Reference Manual: Libraries" contains additional
15 information on the correct usage of the techniques and operating system
16 functions presented in these examples. The source and executable code
17 of these examples may only be distributed in free electronic form, via
18 bulletin board or as part of a fully non-commercial and freely
19 redistributable diskette. Both the source and executable code (including
20 comments) must be included, without modification, in any copy. This
21 example may not be published in printed form or distributed with any
22 commercial product. However, the programming techniques and support
23 routines set forth in these examples may be used in the development
24 of original executable software products for Commodore Amiga computers.
26 All other rights reserved.
28 This example is provided "as-is" and is subject to change; no
29 warranties are made. All use is at your own risk. No liability or
30 responsibility is assumed.
33 #include <exec/types.h>
34 #include <exec/libraries.h>
35 #include <libraries/asl.h>
36 #ifndef __AROS__
37 #include <clib/exec_protos.h>
38 #include <clib/asl_protos.h>
39 #else
40 #include <proto/exec.h>
41 #include <proto/asl.h>
42 #endif
43 #include <stdio.h>
45 #ifdef LATTICE
46 int CXBRK(void) { return(0); } /* Disable Lattice CTRL/C handling */
47 void chkabort(void) { return; } /* really */
48 #endif
50 UBYTE *vers = "$VER: filereq 37.0";
52 #define MYLEFTEDGE 0
53 #define MYTOPEDGE 0
54 #define MYWIDTH 320
55 #define MYHEIGHT 400
57 struct Library *AslBase = NULL;
59 struct TextAttr mytextattr =
61 "arial.font", 13, 0, 0
64 struct TagItem frtags[] =
66 { ASLFR_TextAttr, (IPTR)&mytextattr},
67 { ASLFR_TitleText, (IPTR)"Custom Positive and Negative text" },
68 { ASLFR_PositiveText, (IPTR)"Load File" },
69 { ASLFR_NegativeText, (IPTR)"Forget it" },
70 { ASLFR_InitialShowVolumes, TRUE },
71 { ASLFR_SetSortBy, ASLFRSORTBY_Size },
72 { ASLFR_SetSortOrder, ASLFRSORTORDER_Descend },
73 { ASLFR_SetSortDrawers, ASLFRSORTDRAWERS_Mix },
74 { TAG_DONE, 0 }
77 struct TagItem frtags2[] =
79 { ASLFR_TextAttr, (IPTR)&mytextattr},
80 { ASLFR_TitleText, (IPTR)"Save mode" },
81 { ASLFR_DoSaveMode, TRUE},
82 { TAG_DONE, 0 }
85 struct TagItem frtags3[] =
87 { ASLFR_TextAttr, (IPTR)&mytextattr},
88 { ASLFR_TitleText, (IPTR)"DoPatterns" },
89 { ASLFR_DoSaveMode, TRUE},
90 { ASLFR_DoPatterns, TRUE},
91 { TAG_DONE, 0 }
94 struct TagItem frtags4[] =
96 { ASLFR_TextAttr, (IPTR)&mytextattr},
97 { ASLFR_TitleText, (IPTR)"Drawers Only" },
98 { ASLFR_DrawersOnly, TRUE},
99 { TAG_DONE, 0 }
102 struct TagItem frtags5[] =
104 { ASLFR_TextAttr, (IPTR)&mytextattr},
105 { ASLFR_TitleText, (IPTR)"Drawers Only + DoPatterns (pattern hasn't any effect like on AmigaoS)" },
106 { ASLFR_DrawersOnly, TRUE},
107 { ASLFR_DoPatterns, TRUE},
108 { TAG_DONE, 0 }
111 struct TagItem frtags6[] =
113 { ASLFR_TextAttr, (IPTR)&mytextattr},
114 { ASLFR_TitleText, (IPTR)"Multiselection (use SHIFT)" },
115 { ASLFR_DoMultiSelect, TRUE},
116 { ASLFR_InitialDrawer, (IPTR)"Libs:"},
117 { ASLFR_InitialFile, (IPTR)"Initial file"},
118 { ASLFR_DoPatterns, TRUE},
119 { TAG_DONE, 0 }
123 struct TagItem frtags_[] =
125 { ASLFR_TextAttr, (IPTR)&mytextattr},
126 { ASLFR_TitleText, (IPTR)"The RKM file requester" },
127 { ASLFR_InitialHeight, MYHEIGHT },
128 { ASLFR_InitialWidth, MYWIDTH },
129 { ASLFR_InitialLeftEdge, MYLEFTEDGE },
130 { ASLFR_InitialTopEdge, MYTOPEDGE },
131 { ASLFR_PositiveText, (IPTR)"OKAY" },
132 { ASLFR_NegativeText, (IPTR)"Not OK" },
133 { ASLFR_InitialFile, (IPTR)"asl.library" },
134 { ASLFR_InitialDrawer, (IPTR)"libs:" },
135 { ASLFR_DoSaveMode, TRUE},
136 { ASLFR_DoPatterns, TRUE},
137 { ASLFR_DoMultiSelect, TRUE},
138 { TAG_DONE, 0 }
141 static void showrequester(char *msg, struct TagItem *tags)
143 struct FileRequester *fr;
145 printf("\n%s:\n",msg ? msg : "");
147 if ((fr = (struct FileRequester *)AllocAslRequest(ASL_FileRequest, tags)))
149 if (AslRequest(fr, NULL))
151 printf("\n-------------------------------------------------------\n\n");
152 printf("PATH=\"%s\" FILE=\"%s\"\n", fr->rf_Dir, fr->rf_File ? fr->rf_File : (STRPTR)"<NOFILE>");
153 printf("To combine the path and filename, copy the path\n");
154 printf("to a buffer, add the filename with Dos AddPart().\n\n");
156 if(fr->fr_NumArgs > 0)
158 struct WBArg *wbarg = fr->fr_ArgList;
159 WORD i;
161 printf("MULTI SELECTION:\n"
162 "----------------\n");
164 for(i = 1; i <= fr->fr_NumArgs; i++)
166 printf("%3ld: %s\n", (long)i, wbarg->wa_Name);
167 wbarg++;
170 } else printf("\nRequester was aborted\n");
171 FreeAslRequest(fr);
173 else printf("Could not alloc FileRequester\n");
176 int main(int argc, char **argv)
178 if ((AslBase = OpenLibrary("asl.library", 37L)))
180 showrequester("Default requester with no tags", NULL);
181 showrequester(NULL, frtags);
182 showrequester(NULL, frtags2);
183 showrequester(NULL, frtags3);
184 showrequester(NULL, frtags4);
185 showrequester(NULL, frtags5);
186 showrequester(NULL, frtags6);
187 showrequester(NULL, frtags_);
189 CloseLibrary(AslBase);
190 } else {
191 puts("Could not open asl.library!\n");
193 return 0;