Jump to content

FileRead return line#


Recommended Posts

Is there a way to use the fileread command to read a particular line of text then return the line number.

In the case of the text below, I would like a command to find "[daterange]" then return a line number in that file.

Then I can take the line number and add one to use the FileReadLine("filename", line) command to effectively read the next line of text which is the actual date range.

[daterange]

18000101-20380101

;

Link to comment
Share on other sites

Is there a way to use the fileread command to read a particular line of text then return the line number.

In the case of the text below, I would like a command to find "[daterange]" then return a line number in that file.

Then I can take the line number and add one to use the FileReadLine("filename", line) command to effectively read the next line of text which is the actual date range.

[daterange]

18000101-20380101

;

You might try _FileReadToArray instead of filereadline, then just search the array

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

  • Moderators

I agree on the array, but for sh**s and giggles, I decided to try this (will work only if it's the first word of the line you are looking for):

$Fread = StringStripCR(FileRead(@DesktopDir & '\MyOwnWorkBreather.txt'))
StringReplace(StringLeft($Fread, StringInStr($Fread, @LF & '[daterange]')), @LF, '')
If @extended Then MsgBox(64, 'Info', 'Found on line: ' & @extended + 1)

Edit:

File Content:

18000101-20380101

18000101-20380101

;

18000101-20380101

;

[daterange]18000101-20380101

;

18000101-20380101

;

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

In the case of the text below I would like to open the text file and search for the text string "Number of marc records processed: " then extract the rest of the line.

Can autoit do something like this?

Building catalog file

To : Tue Oct 10 16:08:24 2006

Time Elapsed : 0 hr. 5 min. 23 sec

Number of marc records processed: 350054

Largest input marc record: 12936

Largest input marc data size: 12501

Largest uncompressed data portion: 11776

Fields with no entry in the DDF: 6163876

Largest output marc record size: 12936

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...