Jump to content
Sign in to follow this  

Write array to same line

Recommended Posts

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>")
    $file = FileOpen("genres.xml")
    $read = FileReadLine($file, 1)
    _FileWriteToLine("genres.xml", 1, $read & $genre[$i] & " / ",1)
    $i = $i + 1
Until $i = $array
Edited by mud409

Share this post

Link to post
Share on other sites

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 & " ")

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...