AutoHotkey Community

It is currently May 26th, 2012, 10:03 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: October 17th, 2009, 7:22 am 
Offline

Joined: June 12th, 2009, 11:36 pm
Posts: 1173
Location: Indianapolis IN, USA
I want to count how many characters there are in a variable, then store that number as it's own variable...

Is this possible?

What I was wanting to do, a rough idea to maybe help you understand. I'm 'StringSplit'ing a long sentence, to get each seperate word. Then I want a loop to run, the amount of words there are in that sentence... Is that possible?

_________________
www.AutoHotkey.net/~Eedis
I love my wife and daughter so much.
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 17th, 2009, 7:25 am 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Code:
var := StrLen(string)

:roll:

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 17th, 2009, 7:28 am 
Offline

Joined: June 12th, 2009, 11:36 pm
Posts: 1173
Location: Indianapolis IN, USA
I want to find how many words there are, not all characters.

_________________
www.AutoHotkey.net/~Eedis
I love my wife and daughter so much.
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 17th, 2009, 7:31 am 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Code:
string := "I want to find how many words there are, not all characters."
StringReplace, string, string, %A_Space%, %A_Space%, UseErrorLevel
var := ErrorLevel+1


Or, better yet:
Code:
RegExReplace(string, "\S+", "", var)

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 17th, 2009, 8:02 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Code:
; PhiLho www.autohotkey.com/forum/viewtopic.php?p=85660#85660
str = Recommended for new scripts due to its superior speed and reliability.
RegExReplace(str, "\w+", "", count)
MsgBox % count


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 17th, 2009, 8:06 am 
Offline

Joined: October 2nd, 2009, 12:43 pm
Posts: 283
Code:
StringSplit, OutputArray, InputVar
MsgBox % OutputArray0


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 17th, 2009, 8:06 am 
Quote:
Then I want a loop to run, the amount of words there are in that sentence...
why not using a parsing-loop right away?
http://www.autohotkey.com/docs/commands/LoopParse.htm


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: dra, hyper_, JSLover, Leef_me, patgenn123 and 63 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group