Jump to content

String Trouble


 Share

Recommended Posts

I know there is a simple answer to my question but I just can't find it. I have a string, "123456789" but because there are no delimiters, I can't split the string. I need each number in the string to be put into an array. I know there is an easy way to do this. Thanks for your help.

Link to comment
Share on other sites

I know there is a simple answer to my question but I just can't find it. I have a string, "123456789" but because there are no delimiters, I can't split the string. I need each number in the string to be put into an array. I know there is an easy way to do this. Thanks for your help.

$array = StringSplit('123456789', '')
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

I know there is a simple answer to my question but I just can't find it. I have a string, "123456789" but because there are no delimiters, I can't split the string. I need each number in the string to be put into an array. I know there is an easy way to do this. Thanks for your help.

#include <Array.au3>

$STRING = "123456789"
Dim $ARRAY[StringLen($STRING)+1]
$ARRAY[0] = StringLen($STRING)  ;length of the string
For $INDEX = 1 To StringLen($STRING)
    $ARRAY[$INDEX] = StringMid($STRING,$INDEX,1)
Next

_ArrayDisplay($ARRAY)

When the words fail... music speaks.

Link to comment
Share on other sites

Oh. I didn't know you could split it like that. I thought you had to split it using a character. Thanks!

You should consider adding 2 as the third parameter. It removes that retarded $Array[0] element that stores how many elements there are in the array.

Broken link? PM me and I'll send you the file!

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...