CLS LOCATE 1,8 PRINT "Demo AmigaBasic program using the FileIO MULTIPLE_SELECT files" LOCATE 2,11 PRINT "Atrociously hacked together by Jeff Glatt (dissidents)" DEFLNG a-Z LIBRARY "requester.library" LIBRARY "exec.library" DECLARE FUNCTION AllocMem() LIBRARY DECLARE FUNCTION DoFileIOWindow() LIBRARY DECLARE FUNCTION GetFileIO() LIBRARY DECLARE FUNCTION AutoFileMessage() LIBRARY DECLARE FUNCTION AutoPrompt3() LIBRARY DECLARE FUNCTION RetrieveEntry() LIBRARY MEMF.PUBLIC = 1 : MEMF.CLEAR = 65536 : BUFSIZE = 202 BufferPtr=AllocMem(BUFSIZE,MEMF.PUBLIC+MEMF.CLEAR) 'A buffer to copy the pathname to IF BufferPtr = 0 THEN GOTO NoMem1 BUFSIZE2 = 24 ExtPtr=AllocMem(BUFSIZE2,MEMF.PUBLIC+MEMF.CLEAR) IF ExtPtr = 0 THEN GOTO NoMem2 FileIO=GetFileIO(0) IF FileIO = 0 THEN GOTO CloseUp1 POKEL FileIO+248,BufferPtr POKEL FileIO+222,ExtPtr message$ = "" WindowTitle$ = "Multiple Select Files" + message$ POKEL FileIO+244,SADD(WindowTitle$) POKE FileIO+261,1 'JAM2 DrawMode POKE FileIO+262,1 'PenA = Color1 POKE FileIO+263,0 'PenB = Color0 DIM Pathname$(202) DIM Filename$(30) DIM VolName$(30) DIM DrawerName$(132) Again: 'suppress the .info files and do MULTIPLE_FILES POKE FileIO+1,128+64 DoIO: Result=DoFileIOWindow(FileIO,0) 'do the FileIO selection on WB screen IF Result <> -1 THEN GOTO CheckError '-1 means the user selected CANCEL. message$ = "User selected CANCEL."+CHR$(0) CALL AutoMessageLen(SADD(message$),WINDOW(7),21) '21 is the number of chars in Message$ not counting the CHR$(0) GOTO CloseUp2 CheckError: '0 means the FileIO window couldn't open (probably due to lack of mem). 'Too bad! You'll have to get the filename some other way. Maybe an INPUT statement? IF Result <> 0 THEN GOTO GotPathname 'Message number 0 in the FileIO lib says "Out of memory for this operation" Result=AutoFileMessage(0,WINDOW(7)) GOTO Retry GotPathname: 'We got a selection from the user! 'Now, our PathBuffer$ has the complete pathname. The FileIO's Filename 'buffer has just the Filename separated from the disk and drawer names '(which are also separated into their own FileIO buffers). Let's copy out 'the disk and drawers to a dir string, then we'll use RetrieveEntry() to 'get each selected file within that dir. Note that the user could have typed 'in a filename not in the list. If this is important, examine the FileIO's 'FileSize field. If not 0, then the user selected one of the ones in the list. 'If 0, then the user typed in a new filename (not in the list) and the 'returned PathBuffer$ is the full name, and the filename part is in the 'FileIO's Filename buffer. Here, I ignore any new filename 'Copy out all the drawers DrawerName$ = "" FOR i = 0 TO 132 value = PEEK(FileIO+32+i) IF value = 0 THEN GOTO CopyVol char$ = CHR$(value) DrawerName$ = DrawerName$+char$ NEXT i CopyVol: 'Copy out the diskname VolName$ = "" FOR i = 0 TO 30 value = PEEK(FileIO+164+i) IF value = 0 THEN GOTO CopyFN char$ = CHR$(value) VolName$ = VolName$+char$ NEXT i CopyFN: fileEntryPtr = 0 'initially 0 NextSelect: Pathname$ = DrawerName$ + VolName$ 'Get the next FileEntry entry = RetrieveEntry(VARPTR(fileEntryPtr),FileIO) 'Was there another selection? IF entry = 0 THEN GOTO Retry 'Get the Entry structure from the FileEntry ptr = PEEKL(entry+8) Filename$ = "" 'Copy out the Filename to Filename$. FOR i = 0 TO 30 value = PEEK(ptr+5+i) IF value = 0 THEN GOTO PrintPath char$ = CHR$(value) Filename$ = Filename$+char$ NEXT i PrintPath: 'Now append the filename to the dir Pathname$ = Pathname$ + Filename$ CALL AutoMessage(SADD(Pathname$),WINDOW(7)) 'display our complete path in a 'requester first CLS LOCATE 7,1 PRINT 'Let's print out the disk, drawers, and filename PRINT "The Diskname is ",VolName$ PRINT "The Drawernames are ",DrawerName$ PRINT "The Filename is ",Filename$ 'Note that there is no Filename if the 'user selected only a disc or drawer. 'Let's get the amount of free disk space on the disk that the user chose PRINT "Free disk space: ",PEEKL(FileIO+236)," bytes." 'Note: we get the size from the Entry PRINT "Size of file: ",PEEKL(ptr)," bytes." 'Go back for next selection if there is one GOTO NextSelect Retry: message$ = "This has been a test of the FileIO library." + CHR$(0) Message2$ = "Do you want to retry?" + CHR$(0) boolean=AutoPrompt3(SADD(message$),SADD(Message2$),0,WINDOW(7)) CLS IF boolean = 1 THEN GOTO Again CloseUp2: CALL ReleaseFileIO(FileIO) 'Free the FileIO structure CloseUp1: CALL FreeMem(ExtPtr,BUFSIZE2) NoMem2: CALL FreeMem(BufferPtr,BUFSIZE) NoMem1: LIBRARY CLOSE END