| View previous topic :: View next topic |
| Author |
Message |
Lusein
Joined: 08 Jul 2009 Posts: 5 Location: St. Louis, Mo.
|
Posted: Wed Jul 08, 2009 5:41 pm Post subject: Having an issue clearing StringSplit OutputArray |
|
|
I have searched the forums looking for a way to clear the OutputArray for StringSplit. My issue with my hotkey is sometimes I need to only grab 1 output and sometimes I need to grab multiple outputs. the issue I have is that when I switch from grabbing 4 to grabbing 1 it outputs the new output and the previous outputs from positions 2-4.
| Code: |
!F2::
clipboard =
Send ^c
ClipWait
StringSplit, Split, Clipboard, %A_Tab%
sleep, 500
Msgbox, %Split23%`n%Split37%`n%Split51%`n%Split65%
return
|
[ Moderator!: Moved from General Chat ] |
|
| Back to top |
|
 |
keyboardfreak
Joined: 09 Oct 2004 Posts: 216 Location: Budapest, Hungary
|
Posted: Wed Jul 08, 2009 6:02 pm Post subject: |
|
|
| Split0 contains the number of outputs, so you know how much to show. |
|
| Back to top |
|
 |
Lusein
Joined: 08 Jul 2009 Posts: 5 Location: St. Louis, Mo.
|
Posted: Wed Jul 08, 2009 6:18 pm Post subject: |
|
|
Some times I need to grab all 4 outputs, and I would rather not have two separate hotkey's or reload the hotkey every time I need to grab less variables then the previous time. Basically I would like to clear the variables at the end of the script.
Ok so I figured this out but if anyone has a better way please let me know.
| Code: |
!F2::
Split23 =
Split37 =
Split51 =
Split65 =
clipboard =
Send ^c
ClipWait
StringSplit, Split, Clipboard, %A_Tab%
sleep, 500
Msgbox, %Split23%`n%Split37%`n%Split51%`n%Split65%
return
|
|
|
| Back to top |
|
 |
jethrow
Joined: 24 May 2009 Posts: 1907 Location: Iowa, USA
|
Posted: Wed Jul 08, 2009 10:19 pm Post subject: |
|
|
| Quote: | | I have searched the forums looking for a way to clear the OutputArray for StringSplit. |
| Code: | StringSplit, Split, Clipboard, %A_Tab%
Loop, % Split0
Split%A_Index% = |
|
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5043 Location: the tunnel(?=light)
|
Posted: Wed Jul 08, 2009 11:08 pm Post subject: |
|
|
Alternately I think this will work also:
| Code: | StringSplit, Split, Clipboard, %A_Tab%
Loop, % Split0
VarSetCapacity(Split%A_Index%,0) |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
Lusein
Joined: 08 Jul 2009 Posts: 5 Location: St. Louis, Mo.
|
Posted: Thu Jul 09, 2009 12:05 pm Post subject: |
|
|
Thank you all with your help is was able to get it to work.
| Code: |
!F2::
Loop, % Split0
VarSetCapacity(Split%A_Index%,0)
clipboard =
Send ^c
ClipWait
StringSplit, Split, Clipboard, %A_Tab%
sleep, 500
clipboard = %Split23%
Msgbox, %Split23%`n%Split37%`n%Split51%`n%Split65%
return
|
|
|
| Back to top |
|
 |
|