Jump to content
Sign in to follow this  

Splitting on spaces using StringSplit

Recommended Posts

Hi everyone,

2 things -

Question #1

Is there a way to redirect output from a program to an array instead of a file then reading the file into an array?

If I use a line like this:

Dim $array
$array = RunWait(@ComSpec & " /c " & 'c:\temp\check\psexec.exe \\' & $psiservers[$x] & ' -s -c process.exe -c |findstr -i powersi', 'c:\temp\check', @SW_HIDE)oÝ÷ Øw«z+ìZ^¡ûazËkxßÙ­¯(§Ú,¦X­¶¬¥§²­¡øì^ï^´ßÍ5óý=ÿm4ëm6×mÁ« ¢)à¶h¢a® Mú²b¶·¦¢ø§©e¶rzW¦z{+a²¶§X¤y«­¢+Ù½ÈÀÌØíÈôÄѼÀÌØíÍÁ±¥ÑlÁt(%ÀÌØíÍÁ±¥ÑlÀÌØíÉtôÅÕ½ÐìÅÕ½ÐìQ¡¸(}ÉÉå±Ñ ÀÌØíÍÁ±¥Ð°ÀÌØíȤ(¹%)9áÐ

This bombed with some "Array variable has incorrect number of subscripts or subscript dimension range exceeded" errors so then I tried using UBound($split)-1 instead of $split[0] but got the same errors.

I figured I must be doing something wrong as I'm sure many of you do this all the time; so here I am :).

Any help offered is appreciated.


Share this post

Link to post
Share on other sites

1. look at StdoutRead

2. you already have

$split = StringSplit("7160 3 8 0 18/09/2006 20:21:20"," ")
For $x = 1 To $split[0]
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs


Don't argue with an idiot; people watching may not be able to tell the difference.


Share this post

Link to post
Share on other sites

1. Thanks for the StdoutRead tip, I'm checking into that.

2. When I pasted in the line I was splitting to the forum post earlier it cut out all the reoccurring spaces for some reason. So, while StringSplit may remove some of the spaces it does not remove them all. I still end up with many spaces in $split. Here is an example of what the array looks like after I do the StringSplit:








[7]= gen.exe


[9]= 7160


...empty elements to 16

[16] = 3

...empty elements to 24

[24] = 8

[25] =

[26] =

[27] = 0

[28] =

[29] = 18/09/2006

[30] = 20:21:20

The problem is these empty elements change on me from iteration to iteration, [30] may not contain the time but instead will contain an empty element or no element at all. :)

Share this post

Link to post
Share on other sites


$split = StringSplit(StringStripWS("7160       3           8 0 18/09/2006 20:21:20",4)," ")
For $x = 1 To $split[0]

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...