home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
339.lha
/
KLib
/
kd_freq.doc.pp
/
kd_freq.doc
Wrap
Text File
|
1990-02-08
|
12KB
|
332 lines
kd_freq.library Release 1.00
--------------- ------------
By: Khalid Aldoseri
'kd_freq.library' is a standard Amiga library that has three functions:
FReq(), Path() and PatMatch(). FReq() calls my file requester (FR) so that
any program can use it. The FR is totally reentrant, and you can have
multiple programs calling it simultaenously. Path() simply returns
the full path to a file or directory. PatMatch() implements AmigaDOS style
wildcard pattern matching.
To open the library, use OpenLibrary() like any other normal Amiga library.
Look at test.c for the exact opening procedure. You will need to assemble
and link glue.asm (either manx.glue.asm or lattice.glue.asm) along with your
own object files.
e.g. for Manx:
cc +l test.c
as glue.asm
ln test.o glue.o -lc32
AutoDocs:
------------------------------------------------------------------------------
kd_freq.library/FReq
NAME
FReq - bring up a file requester and obtain a file name.
SYNOPSIS
result = FReq(screen,reqtitle,filename,directory,pattern,flags,extras);
LONG result
struct Screen *screen;
UBYTE *reqtitle;
UBYTE *filename;
UBYTE *directory;
UBYTE *pattern;
ULONG flags;
struct ExtraData *extras;
FUNCTION
Accepts a default directory name, default file name, and a
default pattern (standard AmigaDOS wildcard pattern) and returns
a selected directory, selected file name, and last pattern used
in the same variables that were used to call the requester.
The 'screen' argument is a pointer to a Screen structure. This tells
the file requester to show up on a specific screen. If you use
NULL, then the FR will show up on the WorkBench screen.
'reqtitle' is the title that will appear as the title of the file
requester.
'flags' is a set of flags that control the operation of the FR.
The flags are the following:
FR_NOINFO Do not show any file that ends with <.info>.
The user can change this setting later by
clicking on the 'I' gadget.
FR_NORESIZE Do not allow the user to resize the FR.
FR_NOTITLEBAR Do not show the close window gadget, the drag
bar, or the front/back gadgets. The title still
gets displayed. This makes the FR non-movable.
This also automatically triggers FR_NORESIZE.
If you don't provide a title the file list will
resize and fill in the empty space.
FR_AUTOPOSITION Tells the FR to decide where it wants to come up
on its own. (i.e. ignore LeftEdge and TopEdge)
FR_AUTOSIZE Tells the FR to decide its size on its own.
(i.e. ignore Width and Height)
FR_OKTEXT Tells the FR that we specified an alternate
OK text in 'extras.oktext'.
FR_CANCELTEXT Tells the FR that we specified an alternate
'Cancel' text in 'extras.canceltext'.
FR_DUALWILD When you set this flag, the wildcard pattern
you provide in 'pattern' is fixed and is applied
to all files in the FR. The user then gets a
second wildcard in the Wildcard gadget. (this
defauls to #?). In essence, this allows you
to specify a pattern that will appply to ALL
the FR, no matter what the user selects as a
wildcard. The user's wildcard is applied to
a file after it passes from the first wildcard.
FR_FRONTSCREEN Forces the FR to come up on the front screen.
FR_NOTEXTSHADOW Turns off the text shadowing in all of the FR.
FR_NEWFONT Tells the FR to use a different font than the
standard Topaz 8. This can be any fixed spacing
font from 5 to 16 in size. NO sanity checking is
done on the font size. It is up to you to see
how the font looks like. The FR will rescale
everything to suit the new font. You need to
provide a pointer to a TextFont structure in
extras->NewFont.
FR_SCREENFONT As above, but uses the current font on the screen
the FR will show up on. This always overrides
FR_NEWFONT.
FR_REPLACEIMAGES Replaces the standard images in the FR with
the users's own. The ExtraData struct below
shows where to place each pointer. You can
use any depth of bitplanes as long as they match
the same width/height as the original gadgets.
Be creative! Note that the size of the imagery
changes with the requested font size.
These flags are defined in KDBase.h. You can OR any of these flags
together. There are no restrictions on which flags can be or'd with
others.
The 'extras' is a struct ExtraData (as defined in KDBase.h).
struct ExtraData {
struct Image *UpArrow; /* replacement image for Up Arrow */
struct Image *DnArrow; /* replacement image for Down Arrow */
struct Image *DiskNormal; /* replacement image for Disks */
struct Image *DiskSelected; /* replacement select image for Disks */
struct Image *SizeStrip; /* replacement image for Size gadgets */
UBYTE *oktext; /* text to be used as OK text */
UBYTE *canceltext; /* text to be used as CANCEL text */
USHORT LeftEdge,TopEdge,Width,Height;
struct TextFont *NewFont; /* New Font to use instead of Topaz 8 */
};
You can request a specific LeftEdge, TopEdge, Width, and Height
by giving a non-zero value in any of the above arguments. However,
it is recommended that you do not. The requester will attempt to
come back up where it was the last time if you don't give it the
FR_AUTOSIZE and/or FR_AUTOPOSITION flags. The default values are:
LeftEdge 120
TopEdge 20
Width 400
Height 152
'oktext' is the text that will be shown in the 'OK' gadget. This
should be something like "Load" or "Save" or whatever. The string
must not be longer than 7 characters or it will be truncated. Make
sure that you set the FR_OKTEXT as described above.
'canceltext' is the text that will be shown in the 'Cancel' gadget.
This should be something like "No!" or whatever. The string
must not be longer than 7 characters or it will be truncated. Make
sure that you set the FR_CANCELTEXT as described above.
RESULT
directory - selected path
filename - selected file
pattern - last pattern used
result - 1 = success, 0 = requester cancelled or failed.
Note: UBYTE directory must be least UBYTE [128] in size.
and filename and pattern, [32].
e.g.
UBYTE directory[128];
UBYTE filename[32];
UBYTE pattern[32];
Also, make sure that they are either initialized with
default values, or zero'd out.
BUGS
None.
EXAMPLE
See the file test.c for a detailed example.
------------------------------------------------------------------------------
kd_freq.library/Path
NAME
Path - expand a file name to its full path.
SYNOPSIS
Path(filename);
UBYTE *filename;
FUNCTION
Accepts a string that a valid AmigaDOS file or directory name and
expands it to the full path leading to the file/directory name.
RESULT
filename - full path
Note: UBYTE *filename must be least UBYTE [128] in size.
e.g. UBYTE filename[128];
The string is terminated with either a / or a : depending on whether
it is a valid directory or device.
If the filename is not a valid file name, then 'filename' is truncated
to 0 length;
BUGS
None.
EXAMPLE
UBYTE filename[128] = "dh0:";
Path(filename);
------------------------------------------------------------------------------
kd_freq.library/PatMatch
NAME
PatMatch - do AmigaDOS style wild card filename pattern matching.
SYNOPSIS
result = PatMatch(pattern,filename);
LONG result
UBYTE *pattern;
UBYTE *filename;
FUNCTION
Accepts a string that is a valid AmigaDOS file name (filename) and
a valid AmigaDOS wild card pattern and tells you whether the
filename matches the pattern or not.
Supported wildcards in pattern:
1. Standard AmigaDOS Wildcards:
--------------------------------
? Matches any single character
#p Match any number of occurences of the pattern p
% Matches the null string
() Make a group of characters into a single pattern
| The OR operator
' Disable wildcard interpretation of next character
(unless it is an extended wildcard as shown below.)
2. Extended Wildcards:
-----------------------
These are wildcards not supported by the standard AmigaDOS
convention, but expand it to make it more versatile.
'd Matches any single digit. (0 to 9)
'a Matches any single alpha character. (a to z)
'n Matches any single alphanumeric character.
For examples of standard wildcard usage, look up any AmigaDOS
tutorial book.
Examples of extended wildcards:
Pattern Matching possibilities
------- ----------------------
test'n test0, test1, test9, testa, testA, testz, testZ
test'd test0, test1, test9
test'a testa, testA, testz, testZ
test 'd test 1, test 2, test 9
test#'d test1, test100, test10234
#'a#'d a1, ab12, abc1, abc123, adks34234
(matches any string with some or no alpha characters,
then some or no digits.)
#'a'd#'d.c a1.c, a203.c, 100.c, 1.c, adsdfs931234.c
(matches any string that starts with some of no alpha
characters, then at least 1 or more digits, and ends
with .c)
RESULT
result = -1 Syntax error in wildcard pattern.
result = 0 Filename did not match pattern.
result = 1 Filename matched pattern.
BUGS
None.
EXAMPLE
LONG result;
result = PatMatch("#?.c","test.c");
This will result in: result == 1
------------------------------------------------------------------------------
If you have any trouble getting any call to work, don't hesitate to email me
on Compuserve 75166,2531 or leave me a message in the AmigaTech forum on CIS.
------------------------------------------------------------------------------
Copyright 1990 Khalid Aldoseri.
16 January 1990.
------------------------------------------------------------------------------