Sign in to follow this  
Followers 0
danny0

String Trouble

7 posts in this topic

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.

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

$array = StringSplit('123456789', '')
Oh. I didn't know you could split it like that. I thought you had to split it using a character. Thanks!

Share this post


Link to post
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

Share this post


Link to post
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!

It works. It's more good then my example.

When the words fail... music speaks

Share this post


Link to post
Share on other sites

CODE
Local $array[stringLen($string)+1]

For $a = 1 to StringLen($string)

$array[$a] = StringMid ($string, $a, 1)

Next

Share this post


Link to post
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!

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  
Followers 0