CLS LOCATE 1,8 PRINT "Demo AmigaBasic program using MULTIPLE_SELECT FileIO requester" LOCATE 2,11 PRINT "Mercilessly hacked together by Jeff Glatt (68000 asm dissidude)" DEFLNG a-Z 'IMPORTANT! All variables are longs (for the library calls) 'requester.bmap and exec.bmap must be in the current directory LIBRARY "requester.library" LIBRARY "exec.library" DECLARE FUNCTION AllocMem() LIBRARY DECLARE FUNCTION DoFileIOWindow() LIBRARY 'These are FileIO lib routines DECLARE FUNCTION GetFileIO() LIBRARY DECLARE FUNCTION AutoFileMessage() LIBRARY DECLARE FUNCTION AutoPrompt3() LIBRARY DECLARE FUNCTION AddEntry() LIBRARY DECLARE FUNCTION RetrieveEntry() LIBRARY 'For SPECIAL_REQ, we don't need a buffer for the pathname. FileIO=GetFileIO(0) 'Get the address of the FileIO structure 'Actually you don't need to pass the 0, but AmigaBasic seems to want something... IF FileIO = 0 THEN GOTO CloseUp1 '0 means that you don't have a FileIO. 'Set the title that will displayed in the FileIO window. This can be changed 'for each call. Zero$="" WindowTitle$ = "FileIO Example: MULTIPLE_SELECT" WindowTitle$=WindowTitle$+Zero$ 'for some reason, AmigaBasic adds a quote char 'to the end of strings. This gets rid of it. 'If you comment out this line and look at the 'title bar of the requester window, you'll see it. POKEL FileIO+244,SADD(WindowTitle$) 'Set the fore pen, back pen, and draw mode for title bar routines to some 'defaults. POKE FileIO+261,1 'JAM2 DrawMode POKE FileIO+262,1 'PenA = Color1 POKE FileIO+263,0 'PenB = Color0 DIM message$(196) 'A place large enough to store user's chosen string 'Enable the SPECIAL_REQ feature of the FileIO value=PEEK(FileIO+0) value=value+128 'Only do this ONCE!!! To turn off SPECIAL_REQ later, subtract 128 POKE FileIO+0,value 'Turn on SPECIAL_REQ 'Enable the MULTIPLE_SELECT feature of the FileIO value=PEEK(FileIO+1) value=value+64 POKE FileIO+1,value 'Let's make up a list to display. We'll display strings of "One" to "Ten" 'with the IDs being the respective values. First, we should call 'NewEntryList as that will free any previous list for this FileIO. CALL NewEntryList(FileIO) FOR i = 1 TO 10 READ message$ message$=message$+Zero$ Result=AddEntry(i,SADD(message$),FileIO) IF Result<0 THEN GOTO CloseUp 'Couldn't add the string to the list. 'Actually you could continue on after 'informing the user that "something" 'will be missing from the list. NEXT i Again: 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 chkmore CheckError: '0 means the FileIO window couldn't open due (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 InUse 'Message number 0 in the FileIO lib says "Out of memory for this operation" Result=AutoFileMessage(0,WINDOW(7)) GOTO chkmore InUse: '-2 means somebody else is using the requester. IF Result <> -2 THEN GOTO GotString message$ = "Requester in use."+CHR$(0) CALL AutoMessageLen(SADD(message$),WINDOW(7),17) GOTO chkmore GotString: 'We got selections from the user! 'Now, all the entries selected the FileIO's FileList have their SELECTED BIT 'set. We use RetrieveEntry to extract each selected string one at a time 'until there are no more. Note that all of these strings will be in the list '(because that's what we're examining). It's also possible that the user 'could have typed in a string not in the list. We can either ignore this 'if not relevant, or we could get that string from the FileIO's Filename 'field. The FileSize will be -1 if that string was not in the list. Otherwise, 'it's one of the strings that we're going to get from the list anyway. 'Here, I ignore the user typing in a non-existant string. CLS LOCATE 7,1 fileEntryPtr=0 'initially 0 MoreSelect: entry = RetrieveEntry(VARPTR(fileEntryPtr),FileIO) 'This returns a FileEntry structure IF entry = 0 THEN GOTO chkmore 'Was there another one? ptr = PEEKL(entry+8) 'get the Entry structure from the FileEntry 'copy the string to message$ message$ = "" FOR i = 0 TO 193 'there can be a total of 191 chars in the string value = PEEK(ptr+5+i) IF value = 0 THEN GOTO GetID char$ = CHR$(value) message$ = message$+char$ NEXT i 'get the ID GetID: ID=PEEKL(ptr) 'Print out the chosen string and its ID PRINT "The chosen string is ",message$ PRINT "The ID is ",ID 'Get the next selected one if there is one GOTO MoreSelect chkmore: 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 'Note how the lib automatically spaces these messages symmetrically message$ = "Example program and asm lib by Jeff Glatt" + CHR$(0) message2$ = "(dissidents)" + CHR$(0) Message3$ = "Based on an example by RJ Mical" + CHR$(0) boolean=AutoPrompt3(SADD(message$),SADD(message2$),SADD(Message3$),WINDOW(7)) CloseUp: CALL ResetTitle(FileIO,WINDOW(7)) 'Maybe we changed it for the error msgs. CloseUp1: CALL ReleaseFileIO(FileIO) 'Free the FileIO structure LIBRARY CLOSE END DATA "This is One" DATA "Two" DATA "Three" DATA "Four" DATA "Five" DATA "Six" DATA "Seven" DATA "Eight" DATA "Nine" DATA "Ten"