home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
b
/
baslib2
/
!Help
next >
Wrap
Text File
|
1993-01-16
|
16KB
|
353 lines
@(#)BasLib 1.1 1993
(c) Copyright 1992,1993 Chris Corbett
All sources acknowledged.
This software is distributed free of charge and may be used without
restriction as long as the following conditions are adhered to:
i) No charge must be made for re-distribution
ii) All files must be included, especially this !Help file
with the copyright notice.
All helpful suggestions for changes, improvements, bug fixes etc.
gratefully received. Additions to the library is encouraged, especially
if I get a copy too!
##############################################################################
Introduction to Basic Library
=============================
This directory contains a set of BASIC procedure libraries which implement
some common tasks in programs designed for the WIMP.
Most routines have been collected from PD and magazine sources and modified,
added to, improved etc. to produce this library. The files in this directory
and their contents are:
Debug: Procedures to support the !Debug application (from RISC
user?)
Error: Error handling procedures (not finished!)
Malloc: Memory allocation modelled after UNIX
Menus: Support procedures for WIMP menus, modification of original
described in BAU 1990.
Text: Procedures to support text windows.
Win: Procedures for window creation support.
The procedures contained in each library are described in more detail in the
following sections. To use any library in a BASIC program, use a LIBRARY
statement as illustrated below:
LIBRARY "<Basic$Lib>.Malloc"
LIBRARY "<Basic$Lib>.Menus"
LIBRARY "<Basic$Lib>.Debug"
LIBRARY "<Basic$Lib>.Win"
- where <Basic$Lib> is a system variable which defines the location of the
libraries.
+-----------+
| Malloc |
+-----------+
Procedure: FNmalloc(size%)
Description: Allocate a block of memory of size% bytes, starting on a
word boundary. A pointer to the allocated memory is returned
as an integer value. If the memory could not be allocated
then a value of -1 is returned.
Procedure: FNcalloc(size%)
Description: Same as above, except that the allocated memory block is
cleared to zero before returning to the calling program.
Procedure: FNfree(ptr%)
Description: Frees the memory previously allocated by Fnmalloc or
FNcalloc above. The argument must be a valid pointer
returned from a previous call to either of these functions.
+-----------+
| Menus |
+-----------+
Procedure: FNMenus_Load(menufile$)
Description: Load a textual description of a menu structure into memory
from the file menufile$. The structure of the menu data file
and the code that handles it is derived from an article in
BAU magazine, March 1990 issue. A syntactic definition of
the file structure is:
<menu file> ::= <menu> | <menu file>
<menu> ::= <Menu title><item list><CR>
<menu title>::= [ASCII 32 .. ASCII 127]
<item list> ::= <menu item><CR> | <item list>
<menu item> ::= <*>|< >|<-> <itemname> <action>
<itemname> ::= [ASCII 32 .. ASCII 127]
<action> ::= <!><windowname> |
<@><submenu> |
<*><writeable> |
<{><wimpflags> |
<\><function> (address of menu item passed)
<windowname>::= [Basic integer variable]
<submenu> ::= <menu>
<writeable> ::= <function><,><fieldlen><,><validation>
<wimpflags> ::= [0..2^32-1]
<function> ::= [Basic function name - 'FN']<funcargs>
<funcargs> ::= [(][&]|[&,..] (Use & to pass address of menu icon)
<fieldlen> ::= [0..80]|[(0..80)"_"]
<validation>::= [As PRM pp 1184-1186]
It is recommended that all menu definition files are given the
name "menus". Please refer to the example program !Compare
which uses an example of menus. A much more detailed example
may be found in the !Yadfs application.
FNMenus_Load will return 1 if the menus file was loaded
successfully. Loading the file prepares it for use by the
remaining procedures described below. If the file does not
exist than error number &101 will be raised.
Procedure: FNMenus_Build(title$, height%)
Description: Build a WIMP menu structure for the menu whose title is title$.
The menu of that name must exist in the file previously loaded
by the FNMenus_load function. If the menu does not exist than
an error is raised, via the basic ERROR statement. If the menu
is found it is formatted into the structure required by the WIMP
ready for display to the user. A pointer to the constructed
menu block is returned as an integer. In addition, the second
argument to the function, height%, is declared as a RETURN value,
and it is set to the full height of the constructed menu in pixels.
Procedure: PROCMenus_Select(block%, menu$)
Description: Call this procedure from within the WIMP Poll loop to decode
the menu item selected and perform the action defined. The
first parameter is a pointer to the WIMP control block
filled in by the Wimp_Poll call. The second parameter is the
name of the menu currently being displayed - this must be
remembered in the calling program and passed to this
routine. Typically, each time a user opens a menu by
clicking "menu" over an application window, the program
should open the menu and save the menu name in a variable
ready to pass on to this procedure. An example can be found
in the !Compare application.
+-----------+
| Win |
+-----------+
Procedure: FNWin_Create(template$, window$, RETURN winaddr%)
Description: Create a window structure in memory given the window name
and the name of the template file. The structure created is
as required by a Wimp_Openwindow call. Thus function
automatically calculates the memory requirements to store
the window data and all its indirected strings. I assumes,
of course, that you have constructed your window template
file using the !FormEd application.
The function returns the window handle of the created window
ready for use in subsequent open and close window
operations. The RETURN parameter, "winaddr%", is used to
return the address in memory of the start of the window
block. This can be used in a program to modify window
attributes or icon attributes which are part of the window
definition.
Procedure: FNisind(flag%)
Description: This function checks the indirected bits in the icon flag
word passed as the parameter. It returns TRUE if the flag%
value indicates that the icon contains indirected data,
otherwise it returns false.
Procedure: PROCPollAssign
Description: This procedure sets a group of variable names to the values
returned in a Wimp_Poll loop. This is a convenience call
that allows readable names to be used inside the CASE
statement of the Wimp_poll procedure when decoding the
return value. The values assigned are listed below:
Poll_Null_Reason_Code = 0
Poll_Redraw_Window_Request = 1