October 17, 2021, 09:35:36

Author Topic: [bb] Capitalization by dna [ 1+ years ago ]  (Read 526 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Capitalization by dna [ 1+ years ago ]
« on: June 29, 2017, 00:28:40 »
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.


Code :
Code: BlitzBasic
  1. Function CFLOW$(W$)
  2.         While Instr(W$," ")
  3.                 C$=Upper$(Left$(W$,1)):V$=V$+C$+Mid$(W$,2,Instr(W$," ")-1):W$=Mid$(W$,Instr(W$," ")+1)
  4.         Wend
  5.         V$=V$+Upper$(Left$(W$,1))+Mid$(W$,2)
  6.         Return V$
  7. 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]


SimplePortal 2.3.6 © 2008-2014, SimplePortal