 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Guest Guest
|
Posted: Sun Jun 27, 2004 5:20 am Post subject: Last array element?? |
|
|
Hello,my english is very poor but i will do my best.
Using StringSplit, OutputArray, InputVar , Delimiters we can split strings
like "element1,element2,element3,element4" with easy,but how to get the last array element? Something like %OutputArray%OutputArrray0%%.
I did things like var = %OutputArray0%...%OutputArray%%var%,and
other things like this with no results.
Can someone help me,please. |
|
| Back to top |
|
 |
beardboy
Joined: 02 Mar 2004 Posts: 444 Location: SLC, Utah
|
Posted: Sun Jun 27, 2004 7:35 am Post subject: |
|
|
Are you looking for something like this?
| Code: | fruits = apples,oranges,peach,pear
StringSplit, fruit, fruits, `, ; Split variabe "fruits" into "fruitX" variables
Loop, %fruit0% ; Loop 4 times due to 4 fruits.
{
StringTrimLeft, current_fruit, fruit%a_index%, 0 ; Get the current fruit
MsgBox, Current Fruit = %current_fruit%
} |
thanks,
beardboy |
|
| Back to top |
|
 |
Guest Guest
|
Posted: Sun Jun 27, 2004 8:19 am Post subject: |
|
|
Hi,beardboy.
Yes,it is what i was looking for.Just with small change.
Because i want just the last array string.
Thanks very much.
[/code]fruits = apples,oranges,peach,pear
StringSplit, fruit, fruits, `, ; Split variabe "fruits" into "fruitX" variables
Loop, %fruit0% ; Loop 4 times due to 4 fruits.
{
StringTrimLeft, current_fruit, fruit%a_index%, 0 ; Get the current fruit
}
MsgBox, Current Fruit = %current_fruit% |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Sun Jun 27, 2004 12:42 pm Post subject: |
|
|
Since you only want the last element, you can simplify it even further:
| Code: | fruits = apples,oranges,peach,pear
StringSplit, fruit, fruits, `,
StringTrimLeft, last_fruit, fruit%fruit0%, 0 ; Get the last fruit
MsgBox Last Fruit = %last_fruit% |
|
|
| Back to top |
|
 |
Guest
|
Posted: Sun Jun 27, 2004 1:03 pm Post subject: |
|
|
Yes,nice.
I am starting to learn when/where i must use the "%" and when not.
Thanks,Chris. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|