Sam Paulson was speaking to All about Need 2 functions
SP> I need a couple functions that maybe someone can provide me
SP> with. I need one to trim the spaces off the beginning and
SP> end of a string,
That's easy in PowerBASIC:
a$ = LTRIM$(RTRIM$(TextString$))
SP> and I need one that will properly capitalize
SP> a persons name. Something along these lines:
IF you assume a space between each component of the name this will
work. (It won't help with names like "deVille", though.)
SUB Captilize(TextString$) 'a PowerBASIC Procedure with 1 parameter
Length = LEN(TextString$) 'find the length of the name
NewName$ = "" 'initialize 2 local variables
Flag = 1
FOR x = 1 TO Length 'loop to look at each character
a$ = MID$(TextString$, x, 1) 'one character at a time
IF Flag = 1 THEN a$ = UCASE$(a$) : Flag = 0 'if the last character
'was a space then make
'this one a capital
NewName$ = NewName$ + a$ 'add character to new variable
IF a$ = CHR$(32) THEN Flag = 1 'if this character is a space
'then set the Flag to make next
'character a capital
NEXT x 'end loop
TextString$ = NewName$ 'set return parameter
END SUB 'end of the procedure
I hope this helps. What sort of project are you working on?
Stan Helton
CompuSleuth
... Alabama Rule #25: If a man's word is good he'll sign the contract
___ Blue Wave/QWK v2.12
--- PCBoard (R) v15.22/10
---------------
* Origin: (1:373/10)
|