Recently Browsing 0 members
No registered users viewing this page.
I've noticed that for the task of "reading a file row by row into an array" FileReadToArray is consistently slower than a FileRead + StringSplit.
The following script:
Results in the following output for me:
And the output with switched call sequence:
This surprises me, since I first assume that the native function offers more optimization possibilities than having to create an array in AutoIt via an intermediate string.
So I thought that maybe FileReadToArray is more economical with memory. But again FileReadToArray seems to consume more memory than the StringSplit variant. For this I got the PeakWorkingSetSize after the call of the respective function.
After FileReadToArray the Size is always higher than with StringSplit. Since this is not the case if one changes the order of the two functions (see above), one can assume that FileReadToArray actually has this difference. The difference is mostly the double file size. Which would make sense if the file is completely saved internally as a UTF-16 string.
Can anyone explain to me why FileReadToArray performs so unexpectedly poor - or am I missing something?
A programme I wrote for the organisation for which I work has been in use for a number of years with no issue. One of the things that it does is allow for attachments to be selected (Word docs, Excel sheets, etc) which it then writes away as a BLOB in MySQL.
This was all working fine until recently, when suddenly, on the odd occasion, Word would advise that the file was corrupt on retrieval of the BLOB from MySQL.
Upon further examination it appears that the issue is not with the retrieval of the data from MySQL, but reading in the data from the disk by AutoIT. It seems that on occasions that AutoIT will only read half the file.
I have no idea why this is, as the whole function is very simple. I have included a sanitised vesion of it below in the hope that someone can tell me where to look next, as this one has me beat (again). 😋
I have put some comments in to show what I have done to try and solve the problem, but am getting no closer to the truth. @error is the strangest one - it should return -1 when it reaches end of file but is returning zero.
Func _AttachAttachment() local $file,$chars,$fsize If $RFC_Retrieved = False Then msgbox(0,"Error","Must have a RFC active first") Else $file=FileOpenDialog("Attach to RFC",".","All (*.*)",1) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; FileClose($file) These two lines are my attempt to open the file in binary mode. Made no difference ; FileOpen($file,16) ; Read in the File $fsize = FileGetSize($file) ConsoleWrite("File size is " & $fsize & @CRLF) ; the size comes back as what it say in Windows properties ; $chars = FileRead($file,$fsize) ; I was using this, then tried the line following this. It didn't help $chars = FileRead($file) ; This is showing a figure $chars/2 - 1 I don't understand this ConsoleWrite("Number of chars read is " & @extended & " error code is " & @error & @crlf) ; @error is coming back with 0. I don't understand this as I thought it would be -1 FileClose($file) EndIf EndIf EndFunc Thanks in advance for looking at this
Is it possible , and how can I read and write txt files from Icloud (apple service) ?
Let me try to explain my application.
On my Ipad and Iphone I create txt files. On my windows computer it is possible to read and modify these files manually, by logging in on www.icloud.com.
What I want to make is an auto-it script who reads the txt file and create an new txt file on www.icloud.com, so I can acces these on my ipad and/or phone.
Attempting to extract data from CSV file to display in _ExtMsgBox, sometimes it works fine but mostly it fails with Error:
3 - File lines have different numbers of fields (only if $FRTA_INTARRAYS flag not set) I have tried all the available $iFlags combinations without success.
The CSV file format is fixed for any data collected, sample attached. The two CSV MsgBox() show correct file name
$sText = "" Global $aLines, $fFile, $fLine, $fFcopy $fFile = FileOpen ( "QuickPlotData.dat", 0 ) ; find current CSV file $fLine = FileReadLine ( $fFile ) ; read correct CSV file name MsgBox(0,"CSV file: ", $fLine) ; Read file to 2D array MsgBox(0,"CSV file: ", $fLine) ; _FileReadToArray($fLine, $aLines) ; 'simple' call _FileReadToArray($fLine, $aLines,$FRTA_NOCOUNT+$FRTA_ENTIRESPLIT,',') If @error Then MsgBox($MB_SYSTEMMODAL, "ERROR!", "CSV read error " & @error) exit(0) EndIf _ArrayDisplay($aLines)
I've made a program that relies on IniReadSectionNames. It reads (~3K) Autorun.inf files in the working folder and creates a GUI based on their contents.
I made sure to revert to a default GUI upon @error.
But someone (with Windows XP SP3 32-bit) reported to me he always gets the default menu.
I sent him a FileRead command instead and it works! So seemingly there's no access problem to AutoRun.inf.
In the following demo code, I always hit success, but he always ends up with semi-success:
Local $hIniLocation = "Autorun.inf" Local $aSections = IniReadSectionNames($hIniLocation) If @error Then $aSections = FileRead($hIniLocation) if @error then msgbox(48, "Double error", "Alternative access failed too due to:" & @crlf & @error & @crlf & @extended) else msgbox(0, "Semi-success", "IniReadSectionNames failed, but alternativaly this file contains:" & @crlf & @crlf & $aSections) endif else msgbox(0, "Success", "IniReadSectionNames worked!") endif Why is that? Is there something further to check with him?