home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
326.lha
/
requester.library_v1.3
/
BasicList
(
.txt
)
< prev
next >
Wrap
AmigaBASIC Source Code
|
1989-12-30
|
6KB
|
159 lines
CLS
LOCATE 1,8
PRINT "Demo AmigaBasic program using the FileIO requester library."
LOCATE 2,11
PRINT "Literally hacked together by Jeff Glatt (dissidents)"
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 in the FileIO lib.
DECLARE FUNCTION GetFullPathname() LIBRARY 'Other functions in the lib do
DECLARE FUNCTION GetFileIO() LIBRARY 'not return values, and so do not
DECLARE FUNCTION AutoFileMessage() LIBRARY 'need declaring
DECLARE FUNCTION AutoPrompt3() LIBRARY
DECLARE FUNCTION TypeFilename() LIBRARY
DECLARE FUNCTION UserEntry() LIBRARY
DECLARE FUNCTION PromptUserEntry() LIBRARY
DECLARE FUNCTION GetRawkey() LIBRARY
DECLARE FUNCTION DecodeRawkey() LIBRARY
DECLARE FUNCTION AddEntry() LIBRARY
DECLARE FUNCTION IsEntryThere() 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: SPECIAL_REQ"
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$(60) '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
'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
'It's OK to set the Text that appears in the custom gadget, but don't try
'to install a custom routine. Not in AmigaBasic you don't!
GadgText$="Basic Test"
GadgText$=GadgText$+Zero$
POKEL FileIO+208,SADD(GadgText$)
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 a selection from the user!
'Now, the FileIO's Filename buffer has the chosen string, and the FileIO's
'FileSize field is the ID for that string. Let's copy these to AmigaBasic
'variables.
message$ = ""
FOR i = 0 TO 60
value = PEEK(FileIO+2+i)
IF value = 0 THEN GOTO GetID
char$ = CHR$(value)
message$ = message$+char$
NEXT i
GetID:
ID=PEEKL(FileIO+240)
'Print out the chosen string and its ID
CLS
LOCATE 16,1
PRINT "The chosen string is ",message$
PRINT "The ID is ",ID
IF ID = -1 THEN PRINT "This string is not in the list."
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"