blantek212

Write few array to one file

7 posts in this topic

#1 ·  Posted

Hello everyone.

I need help with scripts. I have some code which creates array, and next writes this array to a file (function _FileWriteFromArray).

In the next step it creates second array. I would like to add this array to previous file, but function _FileWriteFromArray repleaces only content in the file.
Is there any other way to solve this problem?

Share this post


Link to post
Share on other sites



#2 ·  Posted

Try  using FileOpen with the append before writing second array

$sFilePath = "Path to your file"
FileOpen($sFilePath, $FO_APPEND)
_FileWriteFromArray(Your options Here)

 

1 person likes this

Share this post


Link to post
Share on other sites

#3 ·  Posted

This is exactly what I need, works great:D
Thanks

Share this post


Link to post
Share on other sites

#4 ·  Posted

blantek212,

Do not forget to close the file handle when you have written the last array.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

I'm not sure what _FileWriteFromArray does, but the simplest thing you can do is something like this:

$file = FileOpen("FILENAME.txt", 1)

For Local $i = 0 To $array1Size
    FileWrite($file, $array1[$i], " ") ;Log to file.
Next

FileWrite($file, @CRLF) ;Newline.

For Local $i = 0 To $array2Size
    FileWrite($file, $array2[$i], " ") ;Log to file.
Next

FileWrite($file, @CRLF) ;Newline.

;Etc...

FileClose($file)

 

Share this post


Link to post
Share on other sites

Pured,

Quote

I'm not sure what _FileWriteFromArray does

Then I suggest opening the Help file and reading about the function rather then making inane and unhelpful comments like the above.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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

  • Similar Content

    • johnmcloud
      By johnmcloud
      Hi guys, i have made this script:


      $File = _RecFileListToArray("C:\Test", "*.*", 1, 0, 0, 2, "", "") If IsArray($File) Then For $i = 1 To $File[0] $Time = FileGetTime($File[$i]) $dmyyyy = $Time[2] & "/" & $Time[1] & "/" & $Time[0] MsgBox(0,"FileDate", $File[$i] & " - " & $dmyyyy) Next EndIf
      The script working with MsgBox, so i have try to write the result on a txt like this:


      $ToWrite = $File[$i] & " - " & $dmyyyy $Log = @TempDir & "\log.txt" $LogCreate = FileOpen(@TempDir & "\log.txt", 1) _FileWriteFromArray($LogCreate, $ToWrite) FileClose($LogCreate)
      But not working, i have only the filename but not the date. What is the problem?
      Thanks for support