home *** CD-ROM | disk | FTP | other *** search
-
- ' a program showing the use of the ARP File Requestor
- ' IMPORTANT: will *not* work on versions of the compiler
- ' prior to 1.04 due to a bug; it will compile but not run correctly
-
- ' new version allows it to appear on any screen
-
- DEFINT a-z
-
- LIBRARY "arp.library"
- DECLARE FUNCTION FileRequest&(buffer&) LIBRARY
- DECLARE FUNCTION BaseName&(pathptr&) LIBRARY
- DECLARE SUB TackOn(path&,file&) LIBRARY
-
- ' passed a complete pathname, breaks it up into path/filename
- ' then calls the ARP selector
- ' returns -1 if OK, 0 means Cancelled
- ' changes the parameter if OK selected
- ' if scrnum%<>0 then it is used as the screen number
-
- FUNCTION GetFile%(fname$,message$,VAL scrnum%)
- LOCAL path$,file$,buffer&(11),result&,term%,scr&,buf&
-
- ' split up the pathname as required
- path$=SPACE$(80)
- LSET path$=fname$+CHR$(0)
- file$=SPACE$(40)
- result&=BaseName(SADD(path$))
- POKEB result&,0 'into path$
- term%=result&-SADD(path$)
- LSET file$=RIGHT$(fname$,LEN(fname$)-term%)+CHR$(0)
-
- ' get the FR_buffer set up and call ARP
- buf&=VARPTR(buffer&(0))
- POKEL buf&,SADD(message$+CHR$(0))
- POKEL buf&+4,SADD(file$)
- POKEL buf&+8,SADD(path$)
- POKEL buf&+12,0
- POKEW buf&+16,0 'flag
- POKEL buf&+18,0 'function
- POKEL buf&+22,0 'reserved
-
- ' handle custom screens (this is a bit messy, but it works...)
- IF scrnum% THEN
- scr&=PEEKL(SYSTAB+8+4*scrnum%)
- IF (scr&=0) OR (scrnum%<1) OR (scrnum%>4) THEN PRINT "Error":STOP
- POKEW buf&+26,&h217C
- POKEL buf&+28,scr&
- POKEL buf&+32,&h001E317C
- POKEL buf&+36,&h000F002E
- POKEW buf&+40,&h4E75
- POKEL buf&+18,buf&+26
- POKEB buf&+16,8
- END IF
-
- result&=FileRequest(buf&)
- IF result&=0 THEN
- GetFile%=0
- ELSE
- TackOn SADD(path$),SADD(file$)
- fname$=LEFT$(path$,INSTR(path$,CHR$(0))-1)
- GetFile%=-1
- END IF
- END FUNCTION
-
-
-
- ' example code:
-
- file$="test.bas"
- DO
- worked=GetFile(file$,"Select File",0) '0=on Workbench screen
- PRINT file$
- LOOP UNTIL worked=0 'until cancelled
-
-