home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Zodiac Super OZ
/
MEDIADEPOT.ISO
/
FILES
/
13
/
N_B_V203.ZIP
/
PIECES.DMO
< prev
next >
Wrap
Text File
|
1996-07-04
|
5KB
|
94 lines
$if 0
┌──────────────────────────╖ PowerBASIC v3.20
┌──┤ DASoft ╟──────────────────────┬──────────────────╖
│ ├──────────────────────────╢ Copyright 1995 │ DATE: 1995-10-01 ╟─╖
│ │ FILE NAME PIECES .DMO ║ by ╘════════════════─ ║ ║
│ │ ║ Don Schullian, Jr. ║ ║
│ ╘══════════════════════════╝ ║ ║
│ A license is hereby granted to the holder to use this source code in ║ ║
│ any program, commercial or otherwise, without receiving the express ║ ║
│ permission of the copyright holder and without paying any royalties, ║ ║
│ as long as this code is not distributed in any compilable format. ║ ║
│ IE: source code files, PowerBASIC Unit files, and printed listings ║ ║
╘═╤═════════════════════════════════════════════════════════════════════╝ ║
│ .................................... ║
╘═══════════════════════════════════════════════════════════════════════╝
$endif
'.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
$INCLUDE "DAS-NB01.INC"
COLOR 7,0
CLS
? "┌─────────────────────────────────────────────────────────────────────────────
? "│ fGetPiece$ ( ANY, Sep?, PieceNo% )
? "│ fLastPiece$ ( ANY, Sep? )
? "│ fPiecePOS% ( ANY, Sep?, PieceNo% )
? "│ fGetPieces$ ( V$, Sep?, First%, Last% )
? "│ SetPiece ( V$, Sep?, PieceNo%, NewPiece$ )
? "├─────────────────────────────────────────────────────────────────────────────
? "│ These routines bring to PowerBASIC one of the most powerful functions of
? "│ the language MUMPS (M): the ability to parse a string into segments by using
? "│ a known separator (character). The concept is so innovative that it really
? "│ takes some time to get used to it but data is filled with natural separators
? "│ (eg: the spaces in this text) and they can be put to use in many, many ways
? "│ that allow your programs to flow smoother while providing greater power and
? "│ flexibility to your users. In the example, below, I use an address. As each
? "│ country has it's own idea of how long, how many lines, etc. their addresses
? "│ are, you either have to allow massive space to fit all address and waste a
? "│ lot of disk space storing chr$(32)s or put a max length on the data and let
? "│ the users determine how it is to be used.
? "└─────────────────────────────────────────────────────────────────────────────
Sep? = 124 ' "|"
A1$ = "234 Main Street|Quincy, Il.|62301"
A2$ = "482 High Queen's Road|Upper Londondary|Lower Essex|12W348-2"
FOR P% = 1 TO 4
PRINT fGetPiece$( A1$, Sep?, P% )
NEXT
SetPiece A2$, Sep?, 2, "London-Darry"
FOR P% = 1 TO 4
LOCATE P% + 19, 40
PRINT fGetPiece$( A2$, Sep?, P% )
NEXT
LOCATE 25, 60 : PRINT "Thump a button...";
fAnyKey
CLS
? "┌──────────────────────────────────────────────────────────────────────────────
? "│ Another good use for these functions (and we'll get deeper into this later)
? "│ is with names. Right now, in the USA, a FirstName Initial LastName is an
? "│ average of 17 characters. But which of those 17 characters are first/middle
? "│ and which are last? Well, most programs allow one long field for the name,
? "│ force the user to input a name in a particular format, and Katie bar the door
? "│ if it isn't correct! I've found it better to allow my users separate fields
? "│ for the last name, first/middle, and honorifics (Mr.,PhD. etc.) and restrict
? "│ them to a total length of the 3. This way Mr. Rob Robinowitzski, M.D.,PhD.
? "│ is allowed the same opportunity of having his full, correct name/title(s) as
? "│ Ms. Jane Doe and our users CAN'T MAKE A MISTAKE! (well.........:)
? "│ As I've said, I'll get back to all of this name stuff later but for now
? "│ just a quickie!
? "└──────────────────────────────────────────────────────────────────────────────
FullName$ = "Schullian|Donald A.|Mr.,Jr.,PhD.,MD,BS"
LastName$ = fGetPiece$ ( FullName$ , 124, 1 )
FirstName$ = fGetPiece$ ( FullName$ , 124, 2 )
Honorific$ = fGetPiece$ ( FullName$ , 124, 3 )
LHonors$ = fGetPiece$ ( Honorific$, 44, 1 )
THonors$ = fGetPieces$( Honorific$, 44, 2, 0 ) ' all the rest
PRINT
PRINT LHonors$; " "; FirstName$; " "; LastName$; ", "; THonors$
PRINT
Dyte$ = DATE$
Jdate$ = fGetPiece$ ( Dyte$, 45, 3 ) + "." +_
fGetPieces$( Dyte$, 45, 1, 2 )
REPLACE "-" WITH "." IN Jdate$
PRINT Jdate$