Sign in to follow this  
Followers 0
Realm

[Solved]_ArrayToString is not converting back to string

11 posts in this topic

#1 ·  Posted (edited)

I have a large CSV file that collects stats, and adds to the first stat option, for some reason, It will not convert the $data array back into a string. I have tried a few options with no avail. Maybe some1 can find what is wrong here. this is a the snip from the larger script, I do have all the proper includes. _arraydisply() will properly show the $data as an array before attempting to convert into a string.

While 1
    $r=_ArraySearch($statArray, $name, $sr, 0, 0, 1)
    If @error Then
        _ArrayAdd($statArray, $name&";1;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0")
    Else
        $data=StringSplit($statArray[$r],";")
        If $data[1]=$name Then
            $data[2] +=1
            _ArrayDisplay($data)
            _ArrayToString($data,";",1);<<===Is not converting $data back to string
            MsgBox(0,"$data",$data)
            $statArray[$r]=$data
            MsgBox(0,"$statArray[$r]",$statArray[$r])
        Else
            $sr=$r+1
            ContinueLoop
        EndIf
    EndIf
WEnd
Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.  

Share this post


Link to post
Share on other sites



What error are you getting? It always helps to throw in some consolewrites along the way to help debug the code.... you can always comment them out as you move forward towards the end of the code.

Share this post


Link to post
Share on other sites

It's not throwing an error, its just not converting the array, $data, back in to a string where I pointed., I noticed it in a later _arraydisplay() as a blank line


My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.  

Share this post


Link to post
Share on other sites

$data=StringSplit($statArray[$r],";")

what does $data look like right after this?....

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

an array from $data with 0 showing number of elements, and 32 elements as it should read, than it shows the same right after

$data[2] +=1

with the new stat correction.

Edit:corrected typo

Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.  

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

_ArrayToString($data,";",1)

shouldn't that one be like $data[1]

I haven't used arraytostring before, so I am taking a stab out there.

Edited by targeter

Share this post


Link to post
Share on other sites

No, read the helpfile. It works in other parts of my script, for some reason it does not in this section


My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.  

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

My fault... just looked at the wiki. Do you need to spec the end index if you spec the start?

Just started plugging away at some test code... you don't need to spec end...

And I assume the _arraydisply($data) is just a typo in your code...

Edited by targeter

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Just started plugging away at some test code

First of All this is my 'test code'. Secondly, I had been 'plugging away' for over an hour. Third, I only ask for help here when I am truly stuck. Now, What kicks me in the butt, is that you have clearly pointed out that you have no clue how the functions in my code work, and somehow you believe you are the one that can help me. I do appreciate you wanting to help, and I encourage you to help as many as you can, but I suggest skipping the ones, that have a problem or code that you don't understand yourself.

Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.  

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Pretty harsh words against someone trying his best to help you.

It clearly states in the help file that _ArrayToString returns a string, rather than converting the array into one. You're just trying to display the original array in a messagebox.

Edited by Tvern

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Nvm, solved it on my own, I forgot to assign it to a variable.

$data=_ArrayToString($data,";",1)
Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.  

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