home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
database
/
msg.zip
/
MSG.DOC
< prev
next >
Wrap
Text File
|
1988-10-24
|
9KB
|
234 lines
MSG()
For Clipper, version Summer '87
by Steve Badaracco
10/24/88
MSG() is a function written in Clipper which makes use of the new low
level file I/O functions. The purpose is to allow your application to
read text strings from an external message file at runtime.
Why? Because Clipper stores character strings from your source code
into the output (EXE) file. As a result, each byte of text is one less
byte of RAM available to your application! If you want a user-friendly
application with lots of messages, you generally get a MEMORY-HOG.
With MSG(), you can store text strings externally, for use in ...
@...Say <text>
?/?? <text>
@...Prompt <text> Message <text>
[MemVar] = <text>
@...Get [MemVar/Field] Picture <text> Valid &<text>.
Accept/Input <text> to [MemVar]
KeyBoard <text>
Replace [Field] With <text>
Run/! &<text>.
Set Filter To &<text>.
Set Path To (<text>)
Wait <text>
and many, many more commands and functions. Just use MSG() wherever
a long character string ("<expC>") would otherwise be used.
Using macro expansion you can even store complex VALIDs or FILTER
expressions in the external file (of course, you may have to use
EXTERNAL commands to ensure that the necessary functions are linked
into your application).
For example ...
OLD code:
USE CONTACTS
Set Filter To (.Not.Deleted()).And.(LenNum(CONTACTS->CONNUM)#0);
.And.(CONTACTS->ACCTEXEC='Smith').And.(CONTACTS->EFFDATE=Date())
NEW code:
USE CONTACTS
Filt = Msg(22)
Set Filter To &Filt.
MSG() v1.00 is being introduced into the public domain. That is, you
can copy the program all you want, and give it to whomever you want.
I have omitted the source code only because I hope to include it in
a library which I am working on. I ask for no money, but I certainly
would not refuse any if it came!
<< Disclaimer >>
| Please note that MSG() has not been fully tested under all runtime
| conditions...it works on my IBM PS/2, running my own applications.
| MSG() is being released "as is" with no warranty, expressed or
| implied, as to usability, "safety", or fitness for a particular use.
| In no event will I be liable for any direct, indirect, or
| consequential damages, real or imagined.
Please report any bugs to me at the following address:
Steve Badaracco
48 Park Street
Willimantic, CT 06226
or leave me a message on THE BOSS BBS Clipper conference.
Incidentally, THE BOSS has the best Clipper conference going,
hands down! The number is (201) 568-7293.
-2-
SYNTAX:
MSG([<expN>[,<expL>]])
ARGUMENTS:
Calling MSG() with no arguments will attempt to close the .MSG
file, should it be open.
It is advisable to do this before QUITting your application.
<expN> is the line number in the .MSG file to be returned as
a character expression. If this argument is not numeric,
MSG() will return "<record not found>".
<expL> is result class, should an error occur.
The argument is optional, and defaults to .T.
.T. will result in a fatal error, reported through the
error system function MISC_ERROR().
.F. will result in a non-fatal error, and return a "*".
RETURNS:
MSG():
If the .MSG file had been open, and was properly closed, ".T." .
If the .MSG file was not open, or was open but could not be
closed, ".F." .
Note that the returns are of type CHARACTER, to maintain
compatibility with other return values.
MSG(<expN>[,.T.]) : FATAL error class
If the specified line number exists in the proper format in the
.MSG file, the char string contained in that line is returned.
If an error occurred, MISC_ERROR() is called, with the following
arguments:
NAME: "<filename>.MSG, record <line # from expN>"
LINE: 913
INFO: "<applicable error message: see below>"
MSG(<expN>,.F.) : NON-FATAL error class
If the specified line number exists in the proper format in the
.MSG file, the char string contained in that line is returned.
If an error occurred, the value "*" is returned so that processing
can continue.
-3-
ERROR MESSAGES passed to MISC_ERROR():
"<file is not accessible>": Could not open the file SYSTEM.MSG.
If you have specified an alternate filename, then could not
open the file &sysn..MSG. See ENVIRONMENT.
"<record not found>": Could not find the line # specified in <expN>.
This could mean (1)that <expN> was not numeric, (2)that the line
does not, in fact, exist, or (3)that a previous line is not 85
positions long, including the CR/LF pair. See FILE FORMAT.
"<EOR/delimiter error>": The line does not contain a character
expression. This could mean (1)that the EOR (end-of-record) byte
is misplaced, (2)that a previous line is not 85 positions long,
including the CR/LF pair, or (3)that the line is not in the proper
format. See FILE FORMAT.
"<undetermined error>": Any other miscellaneous condition.
ENVIRONMENT:
There are two variables used which are external to MSG().
All others are declared PRIVATE. The two externals are:
MSGHANDLE (public):
This one is created on the first call to MSG() with argument(s).
Contains the value .F. if the .MSG file is closed.
Contains a numeric value representing the DOS file handle if the
.MSG file is open.
SYSN (public):
This is not created by MSG().
If you wish to use a .MSG filename other than the default,
which is "SYSTEM", then declare a PUBLIC variable SYSN, and
assign to it a valid DOS filename (1..8 characters, no extension).
In this case, &sysn..MSG will be searched by MSG().
Note that if you use more than one file, you MUST close one before
searching another. Use MSG() without arguments to do this.
FILE FORMAT:
See the sample file SYSTEM.MSG, supplied with this ARC file.
The .MSG. file is a pseudo-database; each line is an 85-byte
record, in the following format:
1..82: Is a valid Clipper character expression. Don't
forget to use quotes ( '', "", or [] ) !
83: Is any character used to mark the end of the record (EOR).
The purpose is to make it possible to edit the .MSG file
using an editor which does not allow positioning of the
end-of-line marker (i.e. SideKick).
84..85: Is the CR/LF sequence inserted in the file by your editor
when the Return key is pressed.
-4-
LINKING MSGFUNC.OBJ WITH YOUR APPLICATION:
You need to have Clipper, version Summer '87.
The MSG() function is contained in the file MSGFUNC.OBJ and must
be linked with your application. Here is the syntax for linking
with PLINK-86 Plus, Microsoft Link, or Turbo Link:
PLINK86 FI <yourprgs>,MSGFUNC LIB CLIPPER,EXTEND
LINK <yourprgs>+MSGFUNC,,,CLIPPER+EXTEND
TLINK <yourprgs>+MSGFUNC,,,CLIPPER+EXTEND
TO COMPILE AND LINK THE DEMO:
You need to have Clipper, version Summer '87.
First compile the demo program:
CLIPPER DEMO
Then link:
PLINK86 FI DEMO,MSGFUNC LIB CLIPPER,EXTEND
LINK DEMO+MSGFUNC,,,CLIPPER+EXTEND
TLINK DEMO+MSGFUNC,,,CLIPPER+EXTEND
Now run it:
DEMO
CRITICAL ERROR HANDLING:
Since we have the capability in Summer '87 of handling Clipper
critical errors, many folks have undertaken to write their own
error functions to replace MISC_ERROR(), etc.
I highly recommend DMSERROR.PRG, marketed by
Data Management Systems
PO Box 3104
Fallbrook, California 92028
(619) 728-0984.
This system is an excellent vehicle for handling all critical
errors in a uniform way.
It is shareware, and can be found on most BBS's which have a
Clipper conference (try THE BOSS first!).
<End of free advertisement.>
LEGAL STUFF:
NANTUCKET is a registered trademark of Nantucket Corporation.
CLIPPER is a trademark of Nantucket Corporation.
PLINK86-Plus is a trademark of Phoenix Technologies, Ltd.
MICROSOFT LINK is a registered trademark of Microsoft Corp.
TURBO LINK is a trademark of Borland International, Inc.