| View previous topic :: View next topic |
| Author |
Message |
Benny-D
Joined: 29 Feb 2008 Posts: 434
|
Posted: Mon Mar 16, 2009 1:17 am Post subject: getting string's contents by position number |
|
|
| 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 |
|
 |
Z_Gecko Guest
|
Posted: Mon Mar 16, 2009 1:45 am Post subject: |
|
|
| SubStr(String, StartingPos [, Length]) |
|
| Back to top |
|
 |
Benny-D
Joined: 29 Feb 2008 Posts: 434
|
Posted: Mon Mar 16, 2009 5:12 am Post subject: |
|
|
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 |
|
 |
Z_Gecko Guest
|
Posted: Mon Mar 16, 2009 5:22 am Post subject: |
|
|
| 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
|
Posted: Mon Mar 16, 2009 5:58 am Post subject: |
|
|
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 |
|
 |
Benny-D
Joined: 29 Feb 2008 Posts: 434
|
Posted: Mon Mar 16, 2009 7:43 am Post subject: |
|
|
| 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 |
|
 |
Benny-D
Joined: 29 Feb 2008 Posts: 434
|
Posted: Mon Mar 16, 2009 7:44 am Post subject: |
|
|
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 |
|
 |
animeaime
Joined: 04 Nov 2008 Posts: 1046
|
Posted: Mon Mar 16, 2009 7:46 am Post subject: |
|
|
| 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 |
|
 |
Benny-D
Joined: 29 Feb 2008 Posts: 434
|
Posted: Mon Mar 16, 2009 10:33 am Post subject: |
|
|
| I see. Thank you again. |
|
| Back to top |
|
 |
|