AutoHotkey Community

It is currently May 27th, 2012, 3:17 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: May 15th, 2010, 4:46 pm 
Offline

Joined: October 21st, 2006, 5:13 pm
Posts: 23
I was wondering if steps 1 & 2 and 3 & 4 could be combined somehow.

Thanks for any info.

Code:
string= abc,123,def,456                 ; etcetera
MyFn(string)

MyFn(string){
   StringSplit,split,string, `,
   Loop, % (split0/2){
      str:= "split" . (A_Index * 2 - 1) ; step 1
      str:= %str%                       ; step 2
      int:= "split" . (A_Index * 2)     ; step 3
      int:= %int%                       ; step 4
      MsgBox,, LOOP %A_Index%, String = `"%str%`"`nInteger = `"%int%`", 5
   }
   Return
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 15th, 2010, 7:20 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
:D
Code:
string= abc,123,def,456
Loop,Parse,String,`,,%A_space%
   If Mod(A_Index,2) || (%var%:=A_LoopField)
      var:=A_LoopField
ListVars
MsgBox

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 16th, 2010, 12:55 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3330
Location: Simi Valley, CA
Code:
string= abc,123,def,456                 ; etcetera
While pos := RegexMatch( string, "(?<" ( A := A_Index * 2 - 1 ) ">[^,]*),(?<" ( B := A_Index * 2 ) ">[^,]*),?", split, A_Index = 1 ? 1 : pos + StrLen( split ) )
   MsgBox,, LOOP %A_Index%, % "String = """ split%A% """`nInteger = """ split%b% """", 5
:?:

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 16th, 2010, 12:58 am 
Offline

Joined: June 12th, 2009, 11:36 pm
Posts: 1173
Location: Indianapolis IN, USA
I always love seeing VxE post ridiculously obfuscated code on topics like these. :D

_________________
www.AutoHotkey.net/~Eedis
I love my wife and daughter so much.
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 16th, 2010, 1:03 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3330
Location: Simi Valley, CA
I only posted that Regex abomination because it technically fits the OP's question regarding how to condense code. It also reproduces the MsgBox text exactly as seen in the OP's code.

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher, rbrtryn and 21 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