home *** CD-ROM | disk | FTP | other *** search
- JMString - A supplemental string unit for Turbo Pascal
- 02-SEP-89 John G. Morony
-
- Written in Turbo Pascal v5.0
-
-
- JMString is a very tiny unit that implements some handy string
- functions. There are only four routines (hey I said it was tiny
- didn't I ?) in the unit, but they can be of great value by
- relieving some grunt work for you. The documentation that
- follows is not great, but source code is included to help
- you better understand what each function does. Everything here
- is released to the public domain, use as it as you wish. You can
- send questions, compliments or complaints to me via CompuServe
- (76220,3452) or Prodigy (MRMD03A).
-
- Packing List for JMSTRING.ZIP
- JMSTRING.DOC - the file you're reading now.
- JMSTRING.TPU - Turbo Pascal v5.0 compiled unit
- JMSTRING.PAS - Turbo Pascal v5.0 source code for the unit
- JMDEMO.PAS - demonstration program source code
- JMDEMO.EXE - a truly unexciting demo of the functions in
- the JMSTRING unit. It does, however, give you
- an excellent idea of what each function in the
- unit does.
-
- Brief descriptions:
-
- function compact (s:string):string ;
-
- 'Compact' will remove multiple, contiguous spaces from 's'
- leaving at most, one space. For example:
-
- " The Quick Brown F ox jumped over the"
-
- gets compacted to:
-
- " The Quick Brown F ox jumped over the"
-
-
- function toUpper (s:string):string ;
-
- 'toUpper' converts all alphabetic characters in 's' to their
- uppercase form.
-
-
- function toLower (s:string):string ;
-
- 'toLower' converts all alphabetic characters in 's' to their
- lowercase form.
-
-
- function isType (s:string; c:charSet):boolean ;
-
- * charSet is defined as a set of char
-
- 'isType' returns 'TRUE' if all characters of 's' are in the
- set 'c'. Thus you can check to see if a string is numeric by
- using the following code fragment
-
- if isType('1 - 2 buckle my shoe',numerics)
- then writeln ('The string contains only numbers')
- else writeln ('The string does not contain only numbers') ;
-
- * There are five predefined sets :
-
- UpperAlphas - 'A'..'Z'
- LowerAlphas - 'a'..'z'
- Alphas - UpperAlphas + LowerAlphas
- Numerics - '0'..'9'
- Reals - numerics + radixPoint ( or period ".")
-
- You could define your own set and use isType to determine if all
- characters in the input are members of your set.
-
-
- You are more than welcome to modify/optimize/lobotmize my code as
- you wish, however, if you redistribute modified code, I ask that
- you include the original version as well.