Jump to content

Recommended Posts

Posted (edited)

Hello,

I have a Text file ( file.txt) with website urls.

What is the command to search if it exist an url in this text file ?

Another question, is it possible to list in a Gui window the lines of this txt in a Select (option) to select url and remove url from file...

Thank's a lot ! :D

Edited by sambalec
  • Developers
Posted (edited)

i don't find good commands in helpfile...

You could not find a command to read a file?

.. and you forgot to comment on the second part in my post.

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted (edited)

I tried to use fileread, but how to list lines in GUI windows ? and how to delete a line through the GUI

CODE
$file = FileOpen("test.txt", 0)

; Check if file opened for reading OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

; Read in lines of text until the EOF is reached

While 1

$line = FileReadLine($file)

If @error = -1 Then ExitLoop

MsgBox(0, "Line read:", $line)

Wend

FileClose($file)

Edited by sambalec
Posted

Hello,

I have a Text file ( file.txt) with website urls.

What is the command to search if it exist an url in this text file ?

Another question, is it possible to list in a Gui window the lines of this txt in a Select (option) to select url and remove url from file...

Thank's a lot ! :D

Fastest way I can think of:

#include <Array.au3>
$fHandle = FileOpen("file.txt",0)
$fContents = FileRead($fHandle)
$fLines = StringSplit($fContents,chr(10))

;Following portion taken from the _ArraySearch help page.
$Input = InputBox("Search", "URL?")
If @error Then Exit
$Pos = _ArraySearch ($fLines, $Input, 0, 0, 0, True)
Select
    Case $Pos = -1
        MsgBox(0, "Not Found", '"' & $Input & '" was not found in the array.')
    Case Else
        MsgBox(0, "Found", '"' & $Input & '" was found in the array at pos ' & $Pos & ".")
EndSelect
FileClose($fHandle)

Blah, blah, blah... lip service... lip service.Working on a number of projects right now, just waiting for my time to post them here on AutoIt forums.

Posted

Nice way ! And how to list on a Gui Window all lines ( in a select option for example ) and delete line from gui ?

Can't help with that, I'm a console type guy, sorry. However there should be some GUI tutorials around here on the forums somewhere.

Blah, blah, blah... lip service... lip service.Working on a number of projects right now, just waiting for my time to post them here on AutoIt forums.

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
×
×
  • Create New...