AutoHotkey Community

It is currently May 26th, 2012, 3:32 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: March 16th, 2009, 2:17 am 
Offline

Joined: February 29th, 2008, 12:11 pm
Posts: 943
What is that command that would allow me to know the contents of a string by a given position? For example, if I have this string (quotation marks are not included): " Hi Paul!" and submit number 2, it would return letter H, if I submit 3, it would return letter i, and if I submit 1 or 4, it would return a space.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 16th, 2009, 2:45 am 
SubStr(String, StartingPos [, Length])


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 16th, 2009, 6:12 am 
Offline

Joined: February 29th, 2008, 12:11 pm
Posts: 943
Thank YOU!!!
But it doesn't seem to return spaces in the beginning of the string:
Code:
line:= " milka"
msgbox, NNN%line%NNN
denj:= SubStr(String, 1 , 1 )
msgbox, NNN%denj%NNN
What should I do?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 16th, 2009, 6:22 am 
Help wrote:
By default, any spaces or tabs at the beginning and end of Value are omitted from Var. To prevent this, use AutoTrim Off beforehand. However, `t (the tab character) is unconditionally omitted. To prevent this, use %A_Tab% in place of `t.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 16th, 2009, 6:58 am 
Offline

Joined: November 4th, 2008, 9:23 am
Posts: 1045
You used "String" instead of "line" as the variable name:

Code:
line:= " milka"
msgbox, NNN%line%NNN
denj:= SubStr(String, 1 , 1 )
msgbox, NNN%denj%NNN


Should be:

Code:
line:= " milka"
msgbox, NNN%line%NNN
denj:= SubStr(line, 1 , 1 )
msgbox, NNN%denj%NNN


See SubStr for details.

_________________
As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 16th, 2009, 8:43 am 
Offline

Joined: February 29th, 2008, 12:11 pm
Posts: 943
animeaime wrote:
You used "String" instead of "line" as the variable name
How come I didn't notice it. Thank you animeaime


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 16th, 2009, 8:44 am 
Offline

Joined: February 29th, 2008, 12:11 pm
Posts: 943
Hello Z_Gecko!
Z_Gecko wrote:
Help wrote:
By default, any spaces or tabs at the beginning and end of Value are omitted from Var. To prevent this, use AutoTrim Off beforehand. However, `t (the tab character) is unconditionally omitted. To prevent this, use %A_Tab% in place of `t.
But now it seems to work fine even without using AutoTrim Off . Why is it so?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 16th, 2009, 8:46 am 
Offline

Joined: November 4th, 2008, 9:23 am
Posts: 1045
AutoTrim does not affect expression assignments such as Var := " string ". In other words, leading and trailing spaces and tabs are always retained in such cases.

_________________
As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 16th, 2009, 11:33 am 
Offline

Joined: February 29th, 2008, 12:11 pm
Posts: 943
I see. Thank you again.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Yahoo [Bot] and 15 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