[bb] Capitalization by dna [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:40

Previous topic - Next topic

BlitzBot

Title : Capitalization
Author : dna
Posted : 1+ years ago

Description : The algorithm does exactly that.

Just pass your string and the function capitalizes the first letter of each word in the string.

I first wrote an algorithm that worked but which used Dim a(50) for counting the location of the spaces.
This worked but it limited the use of the routine.

The routine below works without the array and is one fifth the size.

I have not checked the limits of the routine. There may be one but it may not be necessary unless someone wants to use it on a large amount of information at once.

Like an Encyclopedia or something similar.

Enjoy


Code :
Code (blitzbasic) Select
Function CFLOW$(W$)
While Instr(W$," ")
C$=Upper$(Left$(W$,1)):V$=V$+C$+Mid$(W$,2,Instr(W$," ")-1):W$=Mid$(W$,Instr(W$," ")+1)
Wend
V$=V$+Upper$(Left$(W$,1))+Mid$(W$,2)
Return V$
End Function


Comments :


BlitzSupport(Posted 1+ years ago)

 Hi dna, you posted your explanation into the code box, so I've edited this entry a little -- you might want to just check I haven't messed up the function! BTW You don't need to use
[code] tags inside the code box.


xlsior(Posted 1+ years ago)

 Just for clarification: This function capitalizes the first letter of each word, not the entire string!(dna: you may want to consider also looking for TAB in addition to spaces)


dna(Posted 1+ years ago)

 Thanks for notifying  me of it needing clarification.


Hardcoal(Posted 1+ years ago)

 How do i post to code archive? [/i]