#ASL_FileRequest a file requester (load/save/directory) #ASL_FontRequest a font requester #ASL_ScreenModeRequest a screenmode requester
AslRequest_ () will pop up a requester if everything went fine.
If it returns FALSE, something went wrong. You should always check it.
You remember the structure we allocated in the beginning ? Well, it
now contains all changes/selections done by the user. The most important
is : which file was chosen ? The answer is quite simple
FileName$ = Peek$(*AslFile\fr_File) DrawerName$ = Peek$(*AslFile\fr_Drawer)
FreeAslRequest_(*AslFile)
DEFTYPE.FileRequester *AslFile *AslFile = AllocAslRequest_(#ASL_FileRequest,0) If *AslFile <> 0 DTAslTags(0)\ti_Tag = #ASLFR_InitialHeight : DTAslTags(0)\ti_Data = DTAslSetup\height DTAslTags(1)\ti_Tag = #ASLFR_InitialWidth : DTAslTags(1)\ti_Data = DTAslSetup\width DTAslTags(2)\ti_Tag = #ASLFR_InitialLeftEdge : DTAslTags(2)\ti_Data = DTAslSetup\left DTAslTags(3)\ti_Tag = #ASLFR_InitialTopEdge : DTAslTags(3)\ti_Data = DTAslSetup\top DTAslTags(4)\ti_Tag = #ASLFR_SleepWindow : DTAslTags(4)\ti_Data = (DTAslSetup\flags AND $8) DTAslTags(5)\ti_Tag = #ASLFR_Window : DTAslTags(5)\ti_Data = *win DTAslTags(6)\ti_Tag = #TAG_MORE DTAslTags(6)\ti_Data = tagsadr If AslRequest_(*DTAslFile,&DTAslTags(0)) succ=True If (DTAslSetup\flags AND $1)=False ; NOPOSREMEMBER DTAslSetup\left = *DTAslFile\fr_LeftEdge DTAslSetup\top = *DTAslFile\fr_TopEdge DTAslSetup\width = *DTAslFile\fr_Width DTAslSetup\height = *DTAslFile\fr_Height EndIf EndIf FreeAslRequest_(*DTAslFile) EndIf Function Return succ End Function
;================================================================== ; ; DTAslLib ; ; $VER = 1.0 (05.02.1996 21:50) ; ; by Peter 'dreamy' Traskalik ; dream technologies inc. ; ; ; commands ; ; DTAslWindow{x,y,w,h,flags} global definition asl-winsize ; DTAslFileRequest{&moretags(0)} open a filerequest ; DTAslFontRequest{&moretags(0)} open a fontrequest ; DTAslScreenRequest{&moretags(0)} open a screenmoderequest ; ; requires amigalibs.res to be resident ; ;================================================================== DEFTYPE.FileRequester *DTAslFile DEFTYPE.FontRequester *DTAslFont DEFTYPE.ScreenModeRequester *DTAslScreen NEWTYPE.DTAslSetup left.w top.w width.w height.w title.s flags.l End NEWTYPE DEFTYPE.DTAslSetup DTAslSetup Dim DTAslTags.TagItem(6) ;------------------------------------------------------------------ Statement DTAslWindow{x.w,y.w,w.w,h.w,fl.l} SHARED DTAslSetup DTAslSetup\left = x DTAslSetup\top = y DTAslSetup\width = w DTAslSetup\height = h DTAslSetup\flags = f End Statement ;------------------------------------------------------------------ Function.b DTAslFileRequest{tagsadr.l} SHARED *DTAslFile,DTAslTags(),DTAslSetup win=Used Window *win.Window=Peek.l(Addr Window(win)) succ=False *DTAslFile=AllocAslRequest_(#ASL_FileRequest,0) If *DTAslFile <> 0 DTAslTags(0)\ti_Tag = #ASLFR_InitialHeight : DTAslTags(0)\ti_Data = DTAslSetup\height DTAslTags(1)\ti_Tag = #ASLFR_InitialWidth : DTAslTags(1)\ti_Data = DTAslSetup\width DTAslTags(2)\ti_Tag = #ASLFR_InitialLeftEdge : DTAslTags(2)\ti_Data = DTAslSetup\left DTAslTags(3)\ti_Tag = #ASLFR_InitialTopEdge : DTAslTags(3)\ti_Data = DTAslSetup\top DTAslTags(4)\ti_Tag = #ASLFR_SleepWindow : DTAslTags(4)\ti_Data = (DTAslSetup\flags AND $8) DTAslTags(5)\ti_Tag = #ASLFR_Window : DTAslTags(5)\ti_Data = *win DTAslTags(6)\ti_Tag = #TAG_MORE DTAslTags(6)\ti_Data = tagsadr If AslRequest_(*DTAslFile,&DTAslTags(0)) succ=True If (DTAslSetup\flags AND $1)=False ; NOPOSREMEMBER DTAslSetup\left = *DTAslFile\fr_LeftEdge DTAslSetup\top = *DTAslFile\fr_TopEdge DTAslSetup\width = *DTAslFile\fr_Width DTAslSetup\height = *DTAslFile\fr_Height EndIf EndIf FreeAslRequest_(*DTAslFile) EndIf Function Return succ End Function ;------------------------------------------------------------------ Function.b DTAslFontRequest{tagsadr.l} SHARED *DTAslFont,DTAslTags(),DTAslSetup win=Used Window *win.Window=Peek.l(Addr Window(win)) succ=False *DTAslFont=AllocAslRequest_(#ASL_FontRequest,0) If *DTAslFont <> 0 DTAslTags(0)\ti_Tag = #ASLFO_InitialHeight : DTAslTags(0)\ti_Data = DTAslSetup\height DTAslTags(1)\ti_Tag = #ASLFO_InitialWidth : DTAslTags(1)\ti_Data = DTAslSetup\width DTAslTags(2)\ti_Tag = #ASLFO_InitialLeftEdge : DTAslTags(2)\ti_Data = DTAslSetup\left DTAslTags(3)\ti_Tag = #ASLFO_InitialTopEdge : DTAslTags(3)\ti_Data = DTAslSetup\top DTAslTags(4)\ti_Tag = #ASLFO_SleepWindow : DTAslTags(4)\ti_Data = (DTAslSetup\flags AND $8) DTAslTags(5)\ti_Tag = #ASLFO_Window : DTAslTags(5)\ti_Data = *win DTAslTags(6)\ti_Tag = #TAG_MORE DTAslTags(6)\ti_Data = tagsadr If AslRequest_(*DTAslFont,&DTAslTags(0)) succ=True If (DTAslSetup\flags AND $1)=False ; NOPOSREMEMBER DTAslSetup\left = *DTAslFont\fo_LeftEdge DTAslSetup\top = *DTAslFont\fo_TopEdge DTAslSetup\width = *DTAslFont\fo_Width DTAslSetup\height = *DTAslFont\fo_Height EndIf EndIf FreeAslRequest_(*DTAslFont) EndIf Function Return succ End Function ;------------------------------------------------------------------ Function.b DTAslScreenRequest{tagsadr.l} SHARED *DTAslScreen,DTAslTags(),DTAslSetup win=Used Window *win.Window=Peek.l(Addr Window(win)) succ=False *DTAslScreen=AllocAslRequest_(#ASL_ScreenModeRequest,0) If *DTAslScreen <> 0 DTAslTags(0)\ti_Tag = #ASLSM_InitialHeight : DTAslTags(0)\ti_Data = DTAslSetup\height DTAslTags(1)\ti_Tag = #ASLSM_InitialWidth : DTAslTags(1)\ti_Data = DTAslSetup\width DTAslTags(2)\ti_Tag = #ASLSM_InitialLeftEdge : DTAslTags(2)\ti_Data = DTAslSetup\left DTAslTags(3)\ti_Tag = #ASLSM_InitialTopEdge : DTAslTags(3)\ti_Data = DTAslSetup\top DTAslTags(4)\ti_Tag = #ASLSM_SleepWindow : DTAslTags(4)\ti_Data = (DTAslSetup\flags AND $8) DTAslTags(5)\ti_Tag = #ASLSM_Window : DTAslTags(5)\ti_Data = *win DTAslTags(6)\ti_Tag = #TAG_MORE DTAslTags(6)\ti_Data = tagsadr If AslRequest_(*DTAslScreen,&DTAslTags(0)) succ=True If (DTAslSetup\flags AND $1)=False ; NOPOSREMEMBER DTAslSetup\left = *DTAslScreen\sm_LeftEdge DTAslSetup\top = *DTAslScreen\sm_TopEdge DTAslSetup\width = *DTAslScreen\sm_Width DTAslSetup\height = *DTAslScreen\sm_Height EndIf EndIf FreeAslRequest_(*DTAslScreen) EndIf Function Return succ End Function ;================================================================== ; ; Example ; ; ; open a screen and window ; FindScreen 0 Window 0,10,10,500,230,$10000+$400+14,"DTLocaleLib test",0,0 ; ; Set the global size etc. of the asl windows ; ; leftedge 10 ; topedge 20 ; width 200 ; height 250 ; flags 0 (remember new position) DTAslWindow{10,20,800,250,$0} Goto hihiman ; ; simple FileRequest ; If DTAslFileRequest{0} ; no additional tags FileName$ = Peek$(*DTAslFile\fr_File) DrawerName$ = Peek$(*DTAslFile\fr_Drawer) NPrint "File : "+FileName$ NPrint "Drawer : "+DrawerName$ Else NPrint "asl failed / nothing selected / cancelled" ; ; you can use afterwards IoErr_ to recognize why... ; NPrint "dos Error : "+Str$(IoErr_) EndIf ; ; FileRequest with add tags ; ; ; define a taglist ; Dim Tags.TagItem(3) ; creates a savemode-requester with black background ; a double click is not allowed Tags(0)\ti_Tag = #ASLFR_DoSaveMode : Tags(0)\ti_Data = True ; begin in the drawer "Work:Test/" drawer.s="Work:Test/" Tags(1)\ti_Tag = #ASLFR_InitialDrawer : Tags(1)\ti_Data = &drawer ; ban the icons ! Tags(2)\ti_Tag = #ASLFR_RejectIcons : Tags(2)\ti_Data = True ; tags done Tags(3)\ti_Tag = #TAG_DONE : Tags(3)\ti_Data = 0 If DTAslFileRequest{&Tags(0)} FileName$ = Peek$(*DTAslFile\fr_File) DrawerName$ = Peek$(*DTAslFile\fr_Drawer) NPrint "File : "+FileName$ NPrint "Drawer : "+DrawerName$ Else NPrint "asl failed / nothing selected / cancelled" NPrint "dos Error : "+Str$(IoErr_) EndIf ;------------------------------------------------- ; ; simple FontRequest ; If DTAslFontRequest{0} FontName$ = Peek$(*DTAslFont\fo_Attr\ta_Name) FontYSize = *DTAslFont\fo_Attr\ta_YSize NPrint "FontName : "+FontName$ NPrint "FontSize : "+Str$(FontYSize) Else NPrint "asl failed / nothing selected / cancelled" NPrint "dos Error : "+Str$(IoErr_) EndIf ;------------------------------------------------- hihiman: ; ; simple ScreenModeRequest ; If DTAslScreenRequest{0} DisplayID.l=*DTAslScreen\sm_DisplayID NPrint "DisplayID : "+Hex$(DisplayID) NPrint "Width : ",*DTAslScreen\sm_DisplayWidth NPrint "Height : ",*DTAslScreen\sm_DisplayHeight DEFTYPE.NameInfo NameInfo dummy=GetDisplayInfoData_(0,&NameInfo,SizeOf.NameInfo,#DTAG_NAME,DisplayID) DisplayName.s=Peek$(&NameInfo\Name[0]) NPrint "Name : "+DisplayName Else NPrint "asl failed / nothing selected / cancelled" NPrint "dos Error : "+Str$(IoErr_) EndIf Repeat ev.l=WaitEvent ; Wait for IDCMP_CLOSEWINDOW Until ev=$200 CloseWindow 0 End