Page 3 of 3

Posted: Wed Nov 08, 2006 7:10 pm
by techjunkie
AND51 wrote:Better:

Code: Select all

ProcedureReturn Mid(temp.s, 1, Len(temp.s) - 1) ; no, this is too slow

;Better: Right()
Procedurereturn Right(temp, Len(temp)-1)

; The best way: PeekS() [unicode-compatible!!!)
ProcedureReturn PeekS(@temp+1+#PB_Compiler_Unicode)
I know... :wink: The whole procedure was just a "funny thing" - nothing serious... :D If we want speed, we can also replace FindString with other solutions.

Posted: Wed Nov 08, 2006 7:13 pm
by Xombie
@techjunkie - doesn't seem to work?

Code: Select all

Procedure.s CapString(st.s) 
    For i= 1 To FindString(st.s, " ", 1) + 1 
      temp.s = temp.s + UCase(Left(StringField(st.s, i, " "), 1)) + LCase(Mid(StringField(st.s, i, " "), 2, Len(StringField(st.s, i, " ")))) + " " 
    Next 
    ProcedureReturn Mid(temp.s, 1, Len(temp.s) - 1) 
EndProcedure 
  Procedure.s CapString2(st.s) 
    For i= 1 To FindString(st.s, " ", 1) + 1 
      temp.s = temp.s + UCase(Left(StringField(st.s, i, " "), 1)) + LCase(Mid(StringField(st.s, i, " "), 2, Len(StringField(st.s, i, " ")))) + " " 
    Next 
    ProcedureReturn temp.s 
  EndProcedure 
string.s = "the QUICK bRoWn fOx jUMPs ovER thE Lazy dog." 
Debug CapString(string)
Debug CapString2(string)
That's using both of your procedures. Cuts off at "jumps".

Posted: Wed Nov 08, 2006 7:17 pm
by techjunkie
Xombie wrote:@techjunkie - doesn't seem to work?
Strange, it works with my PB 4.01... :?: :shock: What result do you get?

Posted: Wed Nov 08, 2006 7:26 pm
by Xombie
I'm running 4.01 as well - from the update tool.

Code: Select all

The Quick Brown Fox Jumps
The Quick Brown Fox Jumps 
That's what I get. That's weird. I don't have unicode or anything else enabled.

Posted: Wed Nov 08, 2006 7:32 pm
by techjunkie
Xombie wrote:I'm running 4.01 as well - from the update tool.

Code: Select all

The Quick Brown Fox Jumps
The Quick Brown Fox Jumps 
That's what I get. That's weird. I don't have unicode or anything else enabled.
Hmmm... Same result with that string here too, but this works better...

Code: Select all

Procedure.s CapString(st.s)
  For i = 1 To CountString(st.s, " ") + 1
    temp.s = temp.s + UCase(Left(StringField(st.s, i, " "), 1)) + LCase(Mid(StringField(st.s, i, " "), 2, Len(StringField(st.s, i, " ")))) + " "
  Next
  ProcedureReturn Mid(temp.s, 1, Len(temp.s) - 1)
EndProcedure
  
Debug CapString("the QUICK bRoWn fOx jUMPs ovER thE Lazy dog.")
My misstake, you can't use FindString... *lol*