Jump to content
Sign in to follow this  
mud409

Write array to same line

Recommended Posts

mud409

How do I write an entire array to the same line of a file? Since I've posted this I've gotten the below code to work, but this doesn't seem like the right way to do this.

;$file is a file containing multiple xml entries containing <genre>

$genre = _StringBetween($file, "<genre>", "</genre>"
$array = Ubound($genre)
$i = 0  
FileWriteLine("genres.xml", "<genres>")
 Do
    $file = FileOpen("genres.xml")
    $read = FileReadLine($file, 1)
    _FileWriteToLine("genres.xml", 1, $read & $genre[$i] & " / ",1)
    FileClose($file)
    $i = $i + 1
Until $i = $array
Edited by mud409

Share this post


Link to post
Share on other sites
JLogan3o13

Try FileWrite instead of FileWriteLine. Something like this:

#include <File.au3>

Local $aArray[5]
    $aArray[0] = "Jim"
    $aArray[1] = "Joe"
    $aArray[2] = "Bob"
    $aArray[3] = "Nancy"
    $aArray[4] = "Martha"

For $element in $aArray
    FileWrite(@DesktopDir & "\Test.txt", $element & " ")
Next

√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
mud409

Worked perfect. Thanks!

Share this post


Link to post
Share on other sites
jdelaney

_ArrayToString could work also, but it's the same deal :)...(not the writing, but the loop)

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

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  

×