Shoutbox

StuffPlug Talker - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: StuffPlug Talker (/showthread.php?tid=51029)

StuffPlug Talker by spokes on 09-27-2005 at 09:18 PM

Can anyone make me a quick talker that will make the first letter of every word upper case?

i'm not good with JS or VBS

thanx


RE: StuffPlug Talker by mwe99 on 09-27-2005 at 09:24 PM

So You Want Something Like This?


RE: StuffPlug Talker by CookieRevised on 09-27-2005 at 10:27 PM

You can't make it much quicker than this I think (in VBS at least)... In JS it can be made a bit more effecient as you can change parts of a string; in VBS you can only add to a string.


code:
Function Talker(Input)
   
   Dim i, j
   Dim Output
 
   i = 0
   Output = ""
   Do
     j = i + 1
     i = InStr(j, " " & Input, " ")
     If i <> 0 Then Output = Output & LCase(Mid(Input, j, i - j)) & UCase(Mid(Input, i, 1))
   Loop Until i = 0

   Talker = Output & LCase(Mid(Input, j))

End Function


Note: this does NOT take in acount _real_ words. This means textual words which are delimited by commas are other textual delimiters are not reconized. The only reconition done is by space:

"this sEntEnce will be cHanged.but this and ,that not;this neither."
=>
"This Sentence Will Be Changed.but This And ,that Not;this Neither."


-----------

To also have that you need to add the following (again VBS):

code:
Function Talker(Input)
   
   Dim i, j
   Dim Output
 
   i = 0
   j = 1
   Output = ""
   Do
     j = i + 1
     i = InstrFirst(j, " " & Input, " ,;.?!()")
     If i <> 0 Then Output = Output & LCase(Mid(Input, j, i - j)) & UCase(Mid(Input, i, 1))
   Loop Until i = 0

   Talker = Output + LCase(Mid(Input, j))

End Function

Function InstrFirst(Start, String, Delimiters)
  Dim iFirst, iDel, iSearch
  iFirst = Len(String) + 1
  For iDel = 1 To Len(Delimiters)
    iSearch = InStr(Start, String, Mid(Delimiters, iDel, 1))
    If (iSearch < iFirst) And (iSearch <> 0) Then iFirst = iSearch
  Next
  If iFirst = Len(String) + 1 Then
    InstrFirst = 0
  Else
    InstrFirst = iFirst
  End If
End Function

"this sEntEnce will be cHanged.also this and ,that;this also."
=>
"This Sentence Will Be Changed.Also This And ,That;This Also."





All this can be made a bit more efficient in JScript...
Also, if you use Regular Expressions it can be made even more efficient (both in JScript as in VBS)