Jump to content

Recommended Posts

Here are pieces you will need and what they do:

  • FileOpen returns a file pointer to a file
  • FileReadLine reads a requested line from a file
  • While loops while a condition is true
  • ExitLoop escapes a loop
  • StringInStr finds a substring in a string
  • MsgBox display a message to the user
We can combine them like this:

$serach = "my serach string"
$file = FileOpen("C:\my_textfile.txt")
If $file = -1 Then;error opening file
  MsgBox(0, "Fatal error", "Unable to open file... quitting")
$i = 1;set the line counter variable
While 1
  $line = FileReadLine($file, $i);get the current line and store to a var
  If @error Then ExitLoop;EOF reached with no success
  If StringInStr($line, $search) Then;we found the text, so tell user and exit
    MsgBox(0, "Text found", "The requested text was found on line " & $i)
  $i = $i + 1
MsgBox(0, "Text not found", "Sorry, your requested text was not found on any line")

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

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

  • Recently Browsing   0 members

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