TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: SAM PAULSON
from: FRANK COX
date: 1995-12-17 11:05:00
subject: Need 2 functions

 > I need a couple functions that maybe someone can provide me
 > with.  I need one to trim the spaces off the beginning and
 > end of a string, and I need one that will properly capitalize
 > a persons name.  Something along these lines:
' flip$ turns SMITH, JOHN Q to JOHN Q SMITH
FUNCTION FLIP$(ARG$)
        REPLACE "," WITH " " IN ARG$
        DO:REPLACE "  " WITH " " IN ARG$:LOOP WHILE INSTR("  ",ARG$)
        A$=RTRIM$(LTRIM$(ARG$))
        A%=INSTR(A$," ")
        IF A% THEN A$=MID$(A$,A%+1)+" "+LEFT$(A$,A%-1)
        FLIP$=A$
END FUNCTION
' cap$ turns JOHN Q SMITH to John Q Smith
FUNCTION CAP$(ARG$)
        A$=LCASE$(RTRIM$(LTRIM$(ARG$)))
        IF LEN(A$) THEN
        DO : REPLACE "  " WITH " " IN A$ : LOOP WHILE INSTR("  ",A$)
        REPLACE " " WITH CHR$(1) IN A$
        A$=UCASE$(LEFT$(A$,1))+MID$(A$,2)
        DO
         A%=INSTR(A$,CHR$(1)):IF A%=0 THEN EXIT LOOP
         MID$(A$,A%) = " " + UCASE$(MID$(A$,A%+1,1))
        LOOP
        CAP$=A$
        END IF
END FUNCTION
(No, I didn't write this code; I just happen to have it stashed away....)
--- Msgedsq 2.2e
---------------
* Origin: THE BIG ELECTRIC CAT Melville Sask *SDS* *PDN* (1:140/53)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.