Jump to content

Help with StringSplit Arrays..


Recommended Posts

Hey all! :P

I'll start by saying, first post here on the forums.. yay!

I've been looking for a while now and can't seem to find a way to do this. I read from a file which has these contents:

1234;5678
8765;4321

I need an array called $command to StringSplit the ; in the file, then show in a messagebox $command[0][0], $command[0][1], $command[1][0] and $command[1][1].

If it is set out like this:

MsgBox(0, "Command", $command[0][0] & ', ' & $command[0][1] & ', ' & $command[1][0] & ', ' & $command[1][1])

It will say:

1234, 5678, 8765, 4321

But the problem is, when $command was dimmed, it was dimmed like so:

Dim $command[2][2]

But when it is StringSplit, it is split like this:

$command[0] = StringSplit($line[$i], ';')

it will show an error (not enough substrings etc.)

I've tried doing this:

$command[0][0] = StringSplit($line[$i], ';')

it won't show up in the messagebox :unsure:

Thanks in advance!

JetlagJad :D

Link to comment
Share on other sites

#include <Array.au3> ;Just so you can see the $Command array at the end

Dim $Command[1][2]   ;Declare the Command Array
Dim $string = "1234;5678" & @CR & _   ;the string as it would appear in the file. @CR is just like hitting return.
               "8765;4321"
Dim $Temp ;a temp variable. 
Dim $aLines = StringSplit($string, @CR) ;Will split the string whenever there is a line break (@CR). 

;Loop through each line of the file and split the contents then add them to the $Command array. 
For $I = 1 To $aLines[0]
    $Temp = StringSplit($String, ";")
    $Command[$I-1][0] = $Temp[1]
    $Command[$I-1][1] = $Temp[2]
    If $I <> $aLines[0] Then ReDim $Command[$I+1][2]
Next

_ArrayDisplay($Command) ;Non important line, just shows you the array at the end.

Edited by Marlo
Click here for the best AutoIt help possible.Currently Working on: Autoit RAT
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...