Sign in to follow this  
Followers 0
primer

Simple Array Question

3 posts in this topic

Hey guys,

I have two Array variables that get assigned values, and then I would like to write all of the data in each array to a file (not just one array node at a time). So my question is how do I target the entire Array data instead of one particular node?

For example:

Do
$ind = $ind + 1
$str1[$ind] = $someVar
$str2[$ind] = $anotherVar
While blahblah

$file = FileOpen("test.txt", 1)
FileWrite($file, $str1 + @CRLF + $str2)
FileClose($file)

doesn't write anything. I've tried $str1[], etc but I cant figure it out.

Share this post


Link to post
Share on other sites



Hey guys,

I have two Array variables that get assigned values, and then I would like to write all of the data in each array to a file (not just one array node at a time). So my question is how do I target the entire Array data instead of one particular node?

For example:

Do
$ind = $ind + 1
$str1[$ind] = $someVar
$str2[$ind] = $anotherVar
While blahblah

$file = FileOpen("test.txt", 1)
FileWrite($file, $str1 + @CRLF + $str2)
FileClose($file)

doesn't write anything. I've tried $str1[], etc but I cant figure it out.

I don't think there is a way to save an array the way you want in Autoit. I think you will have to save every element, and read every element back. If I'm wrong then apologies and I'd be interested to know.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

this way works

$newstr = "[" & $str1[0]
    $newstr2 = "[" & $str2[0]
    For $i = 1 to 64 
        $newstr = $newstr & "," & $str1[$i] 
        $newstr2 = $newstr2 & "," & $str2[$i]   
    Next
    $newstr = $newstr & "]"
    $newstr2 = $newstr2 & "]"
    MsgBox(0, '', $newstr, 1)
    $file = FileOpen("test.txt", 1)
    FileWrite($file, $newstr & @CRLF & $newstr2)
    FileClose($file)
Edited by primer

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