; Jack's File Requester.. (c) 1996 by Jack Pritchard.; Feel free to use this requester in your own code. You can; muck about with it as much as you like...; You are advised to INCLUDE this code after you have; opened your screen as having nearly 1,000 lines of; someone elses source code in your file is not a very; good idea!!; Call the File Requester Like So..; myfile$=FileSelect{30,40,"Select A File.","Sys:"}3 .l info$(400); Qualifiers.ramiga=$80lamiga=$40ctrl=$8ralt=$20lalt=$10rshift=$2lshift=$1 Button{x,y,x1,y1,l,s} ; Simply draws a button at x,y to x1,y1.  x,y1,x,y,x1,y,l  x,y1,x1,y1,x1,y,s  Press{x,y,x1,y1} ; Allows the button to be pressed. Button{x,y,x1,y1,1,2} (0)=1 Button{x,y,x1,y1,2,1}  .b MouseXY{x,y,x1,y1} ; Checks the position of the mouse. If clicked within ; x,y to x1,y1 it returns True, else it returns False. (0)=1 B =>x B <=x1 B =>y B <=y1      SetProp{x,y,x1,y1}  OV,AV ; Creates a custom prop at position x,y to x1,y1. ; The actual size of the prop within those coords is ; determined by OV (OverallValue) & AV (ActaulValue). height=y1-y AV>0 asp.f=OV/AV asp>0 bsp.f=height/asp " bsp.f=0 x,y,x1,y+bsp,0 from=y+bsp from>y1-5 ! from=y1-5 x,from,x1,y1,1  ReadProp{x,y,x1,y1}  OV,AV,oldmousey ; Reads the value of the prop while it is being moved ; with the mouse. ; Minimum value = 0. ; Maximum value = OV. height=y1-y my=-y my>0 B myy1-5 ! from=y1-5 fromoldmousey x,y,x1,from,0 x,from,x1,y1,1 oldmousey=from  AV  Text{x,y,t$,f,b} ; A simply way of writing text to your window.  f,b :  x,y-11 ݁ t$  CursorText{x,y,text$,f.b,b.b,curpos} ; Prints a line of text with the cursor at position curspos. y-11  f,b :  x,y ݁ ܁(text$,curpos-1)  f,3 c$=܃(text$,curpos,1) c$="" ݁ " " " ݁ c$  f,b ݁ ܃(text$,curpos+1)+" "  DoubleClick{tim} ; Tests for a doubleclick of the mouse. ; The delay between clicks can be changed by use of the ; tim variable. Time is measured in 1/50th`s of a second ; so DoubleClick{25} would give the user 1/2 a second to ; make a doubleclick. A value of 6 - 8 is ideal. (0)<>1  a=1  tim  1 (0)=1      $ Mid{s$,ch$,pos} ; Inserts character ch$ into s$ at position pos. firstbit$=܁(s$,pos-1) lastbit$=܃(s$,pos)  firstbit$+ch$+lastbit$ $ Rem{s$,pos} ; Removes a character at position pos from s$. firstbit$=܁(s$,pos-1) lastbit$=܃(s$,pos+1)  firstbit$+lastbit$ .TextDisplay.curtext FRcurtext{}  filepath$,filename$,FRyc,FRxc,FRxo,NoCh,H,W ; Displays the 'cursor` text in the file requester. Button{48,H-55,W-10,H-45,2,1} ; Path. Button{48,H-40,W-10,H-30,2,1} ; File. FRyc=0 CursorText{48,H-53,܃(filepath$,FRxo+1,NoCh),1,0,FRxc} " CursorText{48,H-38,܃(filename$,FRxo+1,NoCh),1,0,FRxc}  .cleantext FRcleantext{}  filepath$,filename$,FRxc,FRxo,NoCh,FRyc,H,W FRxo=0 FRyc=0 Text{48,H-53,܁(filepath$,NoCh)+" ",1,0} " Text{48,H-38,܁(filename$,NoCh)+" ",1,0}  .centry FRcentry{}  k$,FRxc,FRxo,FRyc,filepath$,filename$,NoCh k$<>"" (܇(k$)=>32 B ܇(k$)<=126) (܇(k$)=>161 B ܇(k$)<=255) FRyc=0 filepath$=Mid{filepath$,k$,FRxc+FRxo} " filename$=Mid{filename$,k$,FRxc+FRxo} (FRxc0 ; OK? DirFound.b= name$=܁(name$,܏(name$)-1) filepath$=name$ ܂(name$,1)<>":" B ܂(name$,1)<>"/" B name$<>"" filepath$+"/" adr=(400,$10001) adr>0 (lock,adr)<>0 a$=݃(.l(adr+4)) ; DirEntryType. b$=$(adr+8) ; FileName. c$=݃(.l(adr+124)) ; Size. info$(0)="-2" ;If Right$(name$,1)=":" ; filepath$=b$+":" ;EndIf FRcleantext{} : FRyc=0 : FRxc=1 49,H-54,W-9,H-46,0 FRcurtext{} (lock,adr)<>0 B inc<200 F_info= (F_info= B ܉($(adr+8),".info")=0) inc+1 a$=݃(.l(adr+4)) ; DirEntryType. b$=$(adr+8) ; FileName. c$=݃(.l(adr+124)) ; Size. info$(inc)=ܔ(a$,2)+ܔ(b$,100)+c$ (lock) dirsize=inc ; No of entries. topline=1 ; First entry. ; We HAVE to fill the unused part of info$() with something, ; otherwise the Sort command will HANG the machine or maybe even ; CRASH it????? dirsize+1<400  a=dirsize+1  400 info$(a)="9"   info$() adr,400  .refreshdisplay refreshdisplay{}  info$(),filepath$,filename$,topline,dirsize,W,H,numlines,SelText,OV,AV ; Updates the file requesters display with the current ; list. Also sets the prop accordingly. numlines=(((H-75)-15)/8)-1 numchars=(((W-30)-10)/8)-1 topline+numlines>dirsize topline-((topline+numlines)-dirsize) topline<1 topline=1 pos=17  a=topline  topline+numlines a<=dirsize SelText=-1 (SelText+topline)<>a back=0 " back=3  ܁(info$(a),2)  "-3" Text{10,pos,܃(info$(a),3,numchars-9)+" "+ܕ(܃(info$(a),103),7),1,back}  "2 " Text{10,pos,܃(info$(a),3,numchars-8)+" Drawer",2,back}  "0 " Text{10,pos,܃(info$(a),3,numchars-8)+" Device",2,back}  "1 " Text{10,pos,܃(info$(a),3,numchars-8)+" Volume",1,back}  "3 " Text{10,pos,܃(info$(a),3,numchars-8)+" Assign",2,back}   " Text{10,pos,(numchars),1,0} pos+8  (0)<>1 OV=dirsize-numlines-1 : AV=topline-1 SetProp{W-23,18,W-13,H-85}  .devlist devlist{}  info$(),filename$,filepath$,dirsize,topline,SelText ; Creates a list of devices, assigns and volumes. >0 SelText=-1 rootnode=.l(+34) dosinfo=.l(rootnode+24)*4 devlist=.l(dosinfo+4)*4 info$(0)="-2" devlist<>0 B inc<400 devname=.l(devlist+40)*4 s$=$(devname+1) s$<>"CON" B s$<>"RAW" B s$<>"SER" B s$<>"PAR" B s$<>"PRT" B s$<>"PIPE" inc+1  .l(devlist+4)  0 ; Devices. DF1: etc. a$="0 "  1 ; Assigns. C: FONTS: etc. a$="3 "  2 ; Volumes. Mydisk: etc. a$="1 "   info$(inc)=a$+ܔ($(devname+1)+":",100) dirsize+1 devlist=.l(devlist)*4 dirsize=inc topline=1 dirsize+1<400  a=dirsize+1  400 info$(a)="9"   info$()  .keys FRkeys{}  Class,Code,Qual,FRxc,FRyc,k$,filepath$,filename$,Selected,ok  lshift,rshift,FRxo,NoCh,DirFound ܇(k$)=8 ܇(k$)=13 (܇(k$)=>32 B ܇(k$)<=127) (܇(k$)=>161 B ܇(k$)<=255) Class=$200000 k=܇(k$) " Class=$400 Code= Qual= Class=$400  Code  76 ; Up arrow. FRyc>0 FRcleantext{} FRyc=0 FRxc>܏(filepath$) FRxc=܏(filepath$)+1 FRcurtext{}  77 ; Down arrow. FRyc<1 FRcleantext{} FRyc=1 FRxc>܏(filename$) FRxc=܏(filename$)+1 FRcurtext{}  79 ; Left arrow. FRxc+FRxo>1 Qual=lshift Qual=rshift FRxc=1 FRxo=0 " FRxc>1 FRxc-1 " FRxo-1 FRcurtext{}  78 ; Right arrow. (FRxc+FRxo<=܏(filepath$) B FRyc=0) (FRxc+FRxo<=܏(filename$) B FRyc=1) Qual=rshift Qual=lshift FRyc=0 FRxc=܏(filepath$)+1 " FRxc=܏(filename$)+1 FRxc>NoCh FRxo=(FRxc-NoCh) FRxc=NoCh " FRxc1 FRxo>0 FRxo-1 " FRxc-1 FRyc=0 filepath$=Rem{filepath$,FRxc+FRxo} " filename$=Rem{filename$,FRxc+FRxo} FRcurtext{}  127 ; Del FRyc=0 filepath$=Rem{filepath$,FRxc+FRxo} " filename$=Rem{filename$,FRxc+FRxo} FRcurtext{}  FRcentry{}    .Design ReDesignRequester{}  filepath$,filename$,W,H,FRxc,FRyc,NoCh ; Designs the file requester. ; This is also called if you change the windows size. yc=FRyc W=+ : H=, NoCh=(((W-10)-48)-20)/8 / Button{10,15,W-28,H-73,2,1} ; File display. Button{W-26,15,W-10,H-82,2,1} ; Slider box. Button{W-26,H-81,W-10,H-71,2,1} ; Up arrow.  W-23,H-74, W-18,H-79, W-13,H-74, 1  W-22,H-74, W-18,H-78, W-14,H-74, 1 Button{W-26,H-70,W-10,H-60,2,1} ; Down arrow.  W-23,H-67, W-18,H-62, W-13,H-67, 1  W-22,H-67, W-18,H-63, W-14,H-67, 1 ; Drive selectors  a=10  W-70  W/7 Button{a,H-70,a+37,H-60,2,1}  (a-10)/(W/7)  0 : Text{a,H-68,"DH2:",1,0}  1 : Text{a,H-68,"DH1:",1,0}  2 : Text{a,H-68,"DH0:",1,0}  3 : Text{a,H-68,"RAM:",1,0}  4 : Text{a,H-68,"DF1:",1,0}  5 : Text{a,H-68,"DF0:",1,0}  6 : Text{a,H-68,"DF2:",1,0}    Button{48,H-55,W-10,H-45,2,1} ; Path. Text{10,H-53,"Path",1,0} Button{48,H-40,W-10,H-30,2,1} ; File. Text{10,H-38,"File",1,0} Button{10,H-25,40,H-15,2,1} ; Ok. Text{14,H-23,"OK",1,0} Button{45,H-25,100,H-15,2,1} ; Drives. Text{45,H-23,"DRIVES",1,0} Button{105,H-25,145,H-15,2,1} ; Info. Text{106,H-23,"INFO",1,0} Button{150,H-25,205,H-15,2,1} ; Parent. Text{150,H-23,"PARENT",1,0} Button{W-65,H-25,W-10,H-15,2,1} ; Cancel. Text{W-65,H-23,"CANCEL",1,0} FRxc=1 FRyc=0 : FRcleantext{} FRyc=1 : FRcleantext{} FRyc=yc : FRcurtext{} refreshdisplay{} .Mouse FSMouse{}  info$(),topline,numlines,dirsize,H,W,SelText,filepath$,filename$  FRyc,FRxc,Selected,ok,F_info,OV,AV (0)=2 devlist{} refreshdisplay{} ; The prop. MouseXY{W-23,18,W-13,H-85} (0)=1 AV=ReadProp{W-23,18,W-13,H-85} AV>dirsize-numlines-1 AV=dirsize-numlines-1 AV<0 ! AV=0 topline=AV+1 : refreshdisplay{} ; The Down Arrow. MouseXY{W-26,H-70,W-10,H-60} Button{W-26,H-70,W-10,H-60,1,2} SelText=-1 (0)=1 topline+numlines1 topline-1 refreshdisplay{} Button{W-26,H-81,W-10,H-71,2,1} refreshdisplay{} ; The Device Buttons. MouseXY{10,H-70,(W-70)+37,H-60}  a=10  W-70  W/7 MouseXY{a,H-70,a+37,H-60} Press{a,H-70,a+37,H-60}  (a-10)/(W/7)  0 : f$="DH2:"  1 : f$="DH1:"  2 : f$="DH0:"  3 : f$="RAM:"  4 : f$="DF1:"  5 : f$="DF0:"  6 : f$="DF2:"   dirlist{f$} refreshdisplay{}  ; The OK button. MouseXY{10,H-25,40,H-15} Press{10,H-25,40,H-15} Selected= ; The INFO button. MouseXY{105,H-25,145,H-15} Press{105,H-25,145,H-15} F_info F_info= " F_info= dirlist{filepath$} refreshdisplay{} ; The Cancel button. MouseXY{W-65,H-25,W-10,H-15} Press{W-65,H-25,W-10,H-15} ok= ; Clicked on the display. MouseXY{10,15,W-28,H-73} SelText=(-17)/8 refreshdisplay{}  ܁(info$(topline+SelText),2)  "2 " a$=ܓ(܃(info$(topline+SelText),3,100),32) a$=filepath$+a$+"/" dirlist{a$} refreshdisplay{}  "0 " a$=ܓ(܃(info$(topline+SelText),3,100),32) dirlist{a$} refreshdisplay{}  "1 " a$=ܓ(܃(info$(topline+SelText),3,100),32) dirlist{a$} refreshdisplay{}  "3 " a$=ܓ(܃(info$(topline+SelText),3,100),32) dirlist{a$} refreshdisplay{}  "-3" a$=ܓ(܃(info$(topline+SelText),3,100),32) filename$=a$ FRcleantext{} FRyc=1 : FRxc=1 49,H-39,W-9,H-31,0 FRcurtext{} DoubleClick{6} Selected= : ok=   ; Path. MouseXY{51,H-55,W-10,H-45} FRyc<>0 ! FRcleantext{} FRyc=0 FRxc=((-51)/8)+1 FRxc>܏(filepath$) FRxc=܏(filepath$)+1 FRcurtext{} ; File. MouseXY{51,H-40,W-10,H-30} FRyc<>1 ! FRcleantext{} FRyc=1 FRxc=((-51)/8)+1 FRxc>܏(filename$) FRxc=܏(filename$)+1 FRcurtext{} ; DRIVES. MouseXY{45,H-25,100,H-15} Press{45,H-25,100,H-15} devlist{} refreshdisplay{} ; Parent. MouseXY{150,H-25,205,H-15} Press{150,H-25,205,H-15} ܏(filepath$)>1 pos=0  a=܏(filepath$)-1  1  -1 a$=܃(filepath$,a,1) a$="/" a$=":" pos=a a=0  pos>0 a$=܁(filepath$,pos) dirlist{a$} refreshdisplay{}  .FileSelect $ FileSelect{x,y,title$,path$}  filepath$,filename$,W,H,dirsize,topline,numlines,SelText,Selected,ok,k$,FRxc FRxc=1 filepath$=path$ pos=܉(filepath$,"/") pos=0 pos=܉(filepath$,":") pos=0 filepath$+"/" pos>0 filepath$=܁(filepath$,pos) filename$=܃(path$,pos+1) SelText=-1 ; The following code will ensure that you cannot open ; the file requester outside of your screen coords. x+300>640 x-((x+300)-640) x<0 x=0 y+180>256 y-((y+180)-256) y<0 y=0 2 277,150,640,256  0,x,y,300,195,$1|$2|$4|$8|$20|$1000|$10000,title$,0,1 ReDesignRequester{} dirlist{filepath$} refreshdisplay{} ev.l= ; Wait for something to happen.  ev ; Catch the event and see what it was.  $2 ; $2 = Window has been resized. ReDesignRequester{}  $200 ; $200 = Window has been closed. ok=  $8 ; $8 = Mouse click. FSMouse{}   k$= k$<>"" ; A key has been pressed. FRkeys{} Selected= ok= +  0 Selected= f$=filepath$+filename$  f$