Jump to content

Troubled with _FileReadToArray


Go to solution Solved by Melba23,

Recommended Posts

Posted

I am trying to make a slave and a master system, however they are doing my head in!

Look at these two, for some reason, PrintaPC works with this line:

_FileReadToArray($file, $name, Default, ":")

But Mother does not! Reasons, that I can tell, is because PrintaPC had nothing yet in the questions and return. Giving me an error 3 and if I activate "$FRTA_INTARRAYS" as it desires, it leaves blank arrays. Can someone explain? This is beyond my comprehension!

Mother.txt

PrintaPC.txt

  • Moderators
  • Solution
Posted

Sodari,

The Mother file has 2 trailing @CRLF - these are interpreted as lines which do not contain the delimiter and so the function fails as all lines do not have an equal number of parts. :)

You can test this using the $FRTA_INTARRAYS and looking at the arrays contained within the returned array:

#include <File.au3>
#include <Array.au3>

Local $aLines

$sFile = @ScriptDir & "\Mother.txt"

_FileReadToArray($sFile, $aLines, $FRTA_INTARRAYS, ":")

_ArrayDisplay($aLines, "", Default, 8)    ; Returned array of arrays
_ArrayDisplay($aLines[0], "", Default, 8) ; Content of array within first element of returned array

$sFile = @ScriptDir & "\PrintaPC.txt"

_FileReadToArray($sFile, $aLines, Default, ":")

_ArrayDisplay($aLines, "", Default, 8)    ; Returned array as all lines have the delimiter
So you either have to remove the surplus @CRLF from the file or use the internal arrays. Please ask if you have any further questions. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

I do have another question, but I think you are not the one to answer that; How to remove gremlins from your bloody PC? >.< I did notice them at first, and removed them promptly!! And yet, here they are. But they are not in my Mother file... I don't know. Been such a long day it seems! Ty Melba, you old creature!

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...