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 

Last array element??

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





PostPosted: Sun Jun 27, 2004 5:20 am    Post subject: Last array element?? Reply with quote

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

PostPosted: Sun Jun 27, 2004 7:35 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Guest
Guest





PostPosted: Sun Jun 27, 2004 8:19 am    Post subject: Reply with quote

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

PostPosted: Sun Jun 27, 2004 12:42 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Guest






PostPosted: Sun Jun 27, 2004 1:03 pm    Post subject: Reply with quote

Yes,nice.
I am starting to learn when/where i must use the "%" and when not.
Thanks,Chris.
Back to top
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