Jump to content
Sign in to follow this  

Reading line from file then matching it to a variable.

Recommended Posts

Hello folks,
I have stopped writing anything in Autoit for more than 4 years now and am getting back into it to do some stuff for my son's lacrosse team. Any help for this forgetful old fart would be very helpful.
How do you read a line of text from a file and if it matches a set variable, copy it to a new file and repeat till end of file?
For instance lets say there is a lacrosse team and each boy has a list of equipment.
John Doe
Helmet - CascadeR
Stick - Dpole
Chest - Warrior
Bob Pham
Helmet - STX
Stick - Attack
Chest - Brine
I want to make a new file that shows just the sticks
Stick - Dpole
Stick - Attack
Edited by Zingzi

Share this post

Link to post
Share on other sites


Non-SRE way...

local $inFile = @scriptdir & '\lacross_team_data.txt'
local $outFile = @scriptdir & '\sticks.txt'

local $aData = stringsplit(fileread($inFile),@CRLF,3)

for $1 = 0 to UBound($aData) - 1
    if stringinstr($aData[$1],'stick') then filewrite($outfile, $aData[$1] & @CRLF)


This is the input filelacross_team_data.txt




Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...