AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

getting string's contents by position number

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Benny-D



Joined: 29 Feb 2008
Posts: 434

PostPosted: Mon Mar 16, 2009 1:17 am    Post subject: getting string's contents by position number Reply with quote

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.
Back to top
View user's profile Send private message
Z_Gecko
Guest





PostPosted: Mon Mar 16, 2009 1:45 am    Post subject: Reply with quote

SubStr(String, StartingPos [, Length])
Back to top
Benny-D



Joined: 29 Feb 2008
Posts: 434

PostPosted: Mon Mar 16, 2009 5:12 am    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
Z_Gecko
Guest





PostPosted: Mon Mar 16, 2009 5:22 am    Post subject: Reply with quote

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.
Back to top
animeaime



Joined: 04 Nov 2008
Posts: 1046

PostPosted: Mon Mar 16, 2009 5:58 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Send e-mail
Benny-D



Joined: 29 Feb 2008
Posts: 434

PostPosted: Mon Mar 16, 2009 7:43 am    Post subject: Reply with quote

animeaime wrote:
You used "String" instead of "line" as the variable name
How come I didn't notice it. Thank you animeaime
Back to top
View user's profile Send private message
Benny-D



Joined: 29 Feb 2008
Posts: 434

PostPosted: Mon Mar 16, 2009 7:44 am    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
animeaime



Joined: 04 Nov 2008
Posts: 1046

PostPosted: Mon Mar 16, 2009 7:46 am    Post subject: Reply with quote

AutoTrim docs wrote:
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.
Back to top
View user's profile Send private message Send e-mail
Benny-D



Joined: 29 Feb 2008
Posts: 434

PostPosted: Mon Mar 16, 2009 10:33 am    Post subject: Reply with quote

I see. Thank you again.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group