Jump to content

Issues with FileReadLine()


Recommended Posts

I am openning a file as a $handle and reading it. This file is opened by another program(also belongs to it as its log file). I need some data from this log for automation help.

What i am usually doing is using FileReadLine() to get what this app is constantly writting in this log file BUT

sometimes FileReadLine() will return -1 (end of line?!) even i am 100% sure that there is more data to read but my filereadline() somehow skipped that data?!

This normally works fine but happens rarely.

So its like

while 1

$line = filereadline($loghandle)

;sometimes filereadline wont read the data even its there and it will keep returning -1

wend

Link to comment
Share on other sites

  • Moderators

Aktonius,

It is obvious that the problem is in line #2345. :)

Seriously, how on earth can we offer any advice without sight of the code you are using? FileReadLine is not the easiest of functions to use - without any code to work on we cannot offer more than very basic suggestions. :D

My first thought is that you are calling the function so often that you are advancing the internal line counter faster than the other app is adding lines. That would explain why you are getting the -1 (end of file, not line) error. But show us the code and we will see if we can do better. ;)

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:

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

 

Link to comment
Share on other sites

Aktonius,

It is obvious that the problem is in line #2345. :)

Seriously, how on earth can we offer any advice without sight of the code you are using? FileReadLine is not the easiest of functions to use - without any code to work on we cannot offer more than very basic suggestions. :D

My first thought is that you are calling the function so often that you are advancing the internal line counter faster than the other app is adding lines. That would explain why you are getting the -1 (end of file, not line) error. But show us the code and we will see if we can do better. ;)

M23

Sorry for not much code but this example is just to huge to post all details, i thought it would just add confusion but i will post something up later.

Also since you said that filereadline() could advance line counter, wouldnt this be impossible if the end of file(nothing was written) is detected?

So basically if it reads that nothing was written or -1 doesnt it continue reading from the same line when something actually is written?

like...

readline = -1 (position 2345)

readline = -1 (position 2345)

readline = -1 (position 2345)

readline = -1 (position 2345)

readline = -1 (position 2345)

readline = (something is written) (position increases)

isnt this correct?

Link to comment
Share on other sites

  • Moderators

Aktonius,

I have no idea - I did say that the suggestion was only my initial thought. ;)

Please try and get some form of reproducer script - without it we are really just stumbling around in the dark as anything I might code is very unlikely to look like what you are using. :)

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:

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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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