📄 bstring.doc
字号:
BSTRING PROGRAMMER'S MANUAL
VERSION 2.0
(BASIC String Functions for C)
TechniLib Company
Copyright 1995, by TechniLib (TM) Company
All Rights Reserved
TERMS OF USE AND DISTRIBUTION
BSTRING is a shareware product; therefore, unregistered copies of BSTRING
are made available free of charge so that potential purchasers will have the
opportunity to examine and test the software before committing payment.
Distribution of unregistered copies of BSTRING to other potential users is
also permitted and appreciated. However, usage and distribution of BSTRING
must conform to the following conditions. In the following statement, the
term "commercial distribution," includes shareware distribution.
1) BSTRING and accompanying software must be distributed together in copies of
the original archive provided by TechniLib. Neither the archive nor
individual files therein may be modified.
2) The BSTRING archive may be distributed in combination with other shareware
products; however, the BSTRING archive may not be distributed with other
commercially distributed software without written consent of TechniLib.
3) Copies of BSTRING which have been used to develop software for commercial
distribution must be registered before such software is marketed. Copies of
BSTRING which have been used to develop noncommercial software must be
registered if such software is to be regularly used either by the developer or
others.
4) Commercially distributed software must embed BSTRING procedures in the
software code. Files contained in the BSTRING archive may not be placed in
the distribution media.
5) BSTRING is designed to offer a set of services to other executable code.
BSTRING may not be used to develop software for commercial distribution which
will essentially offer any of these same services to other executable code.
Exceptions to this condition require written consent of TechniLib.
6) Rights afforded by registering a single copy of BSTRING pertain only to a
single computer.
7) BSTRING may be registered for a fee of $15.00 per copy. Consult README.DOC
in the BSTRING archive for further instructions regarding registration.
DISCLAIMER OF WARRANTY
BSTRING AND ALL ACCOMPANYING SOFTWARE AND LITERATURE ARE DISTRIBUTED WITH
THE EXCLUSION OF ANY AND ALL IMPLIED WARRANTIES, AND WITH THE EXCLUSION OF
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. TechniLib
SHALL HAVE NO LIABILITY FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
RESULTING FROM THE USE OF BSTRING OR ACCOMPANYING MATERIALS. The user assumes
the entire risk of using this software.
Copyright 1995, by TechniLib (TM) Company
All Rights Reserved
Introduction
------------
BASIC is generally regarded as having the best string handling
capabilities of all programming languages. Most programmers who have
converted from BASIC to C have probably missed the BASIC string functions ever
since. The string functions in standard C libraries have names and prototypes
that are difficult to remember whereas BASIC functions are intuitively named
and designed. BSTRING is a library of C functions which emulate the string
functions in BASIC. BSTRING functions are named after the corresponding BASIC
functions and have prototypes as near to the BASIC functions as C will permit.
All procedures in BSTRING are written in assembly language. BSTRING
functions are therefore very compact and very fast. In fact, they are faster
than analogous string functions in standard C libraries. Speed improvements
are even more pronounced on Pentium processors because BSTRING code is
designed to fully utilize the superscalar architecture.
The BSTRING archive includes libraries for both Microsoft C and Borland
C. Microsoft libraries are contained in MICROSOF.ZIP. Borland libraries are
in BORLAND.ZIP. Each archive contains a file called BSTRING.LIB. This is a
fully functional version of BSTRING but is designed to operate under the small
memory model only. Libraries for other memory models are contained in
REGISTRD.ZIP. REGISTRD.ZIP is password protected. One must register BSTRING
to obtain this password. The quickest way to obtain the password is by email
registration using the file EMAIL.REG. Refer to EMAIL.REG for further
details.
REGISTRD.ZIP also contains libraries of useful date and time functions.
These libraries are complements of TechniLib for BSTRING registration.
To use BSTRING, the programmer should include the BSTRING.H header file
in their C program, and should link the program with the appropriate BSTRING
library. The following is a list of available BSTRING libraries matched with
their corresponding memory models.
Library Memory Model
------------ ------------
BSTRING.LIB Small
BSTRINGS.LIB Small
BSTRINGC.LIB Compact
BSTRINGM.LIB Medium
BSTRINGL.LIB Large and Huge
BSTRINGL.LIB may actually be used with all memory models provided that the
include file is changed to BSTRINGL.H.
Two functions have been added to version 2.0 of BSTRING. These functions
are designed for syntax checking of numeric strings. The functions are
intchk() and floatchk(). They have no equivalents in BASIC. They are
included in BSTRING to overcome deficiencies in the BASIC VAL function.
1
Detailed Specifications
-----------------------
This section presents detailed descriptions of the various string
functions in BSTRING. Each description includes a BASIC equivalent to the
BSTRING function. These descriptions use variables which would be declared as
follows:
BASIC:
DIM sstring AS STRING, dstring AS STRING
DIM start AS INTEGER, n AS INTEGER, ShortInt AS INTEGER, ASCIIcode as integer
DIM LongInt AS LONG
DIM DoubleFloat as DOUBLE
C:
char sstring[.], dstring[.]; /* Dimensions must be supplied */
int start, n, ShortInt, ASCIIcode;
long LongInt;
double DoubleFloat;
dstring is used in all of the following descriptions as the destination
string. sstring is used as the source string. If the destination string may
be modified by the function, then the function will always return the pointer
to this string. The source string is never modified provided that it is
stored at a different location than the destination. All BSTRING functions
are designed such that the source string and destination string may be equal.
Copy Strings
------------
BASIC: dstring = sstring
C: movstr(dstring, sstring);
PROTOTYPE: char* movstr(char* dstring, char* sstring);
Compute String Length
---------------------
BASIC: ShortInt = LEN(sstring)
C: ShortInt = len(sstring);
PROTOTYPE: int len(char* sstring);
DETAILS: len() returns 0 if sstring is null.
2
Add Strings
-----------
BASIC: dstring = dstring + sstring
C: addstr(dstring, sstring);
PROTOTYPE: char* addstr(char* dstring, char* sstring);
BASIC: dstring = sstring + dstring
C: addstrr(dstring, sstring); /* Add string reverse */
PROTOTYPE: char* addstrr(char* dstring, char* sstring);
Get Characters from Left or Right of String
-------------------------------------------
BASIC: dstring = LEFT$(sstring, n)
C: left(dstring, sstring, n);
PROTOTYPE: char* left(char* dstring, char* sstring, int n);
BASIC: dstring = RIGHT$(sstring, n)
C: right(dstring, sstring, n);
PROTOTYPE: char* right(char* dstring, char* sstring, int n);
DETAILS: If n = 0 (an invalid value), both left() and right() set dstring to
null. If n >= len(sstring), both left() and right() return dstring = sstring.
Get Characters Embedded in String
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -