Jump to content

Need some tips with parsing a text file. - (Moved)


 Share

Recommended Posts

Apologies as I am new to Autoit. 

I'm looking to copy/paste text to notepad, parse it line by line, search if a substring exists in the line and if it does, save the entire line to clipboard to append to a url.

Below is what I have so far and I'm not sure what I'm missing...

#include <file.au3>

$sStart = "https://"
$sEnd = "/static/directory/path/"

send(^a)
send(^c)
run("notepad.exe")
send(^v)

While 1
    $line = FileReadLine("Untitled - Notepad")
    If StringInStr ($line, $sEnd) > 0 Then ClipPut($line)
    If @error = -1 Then ExitLoop
    MsgBox(0,'',$line)
WEnd
FileClose($file)
Link to comment
Share on other sites

  • Moderators

Moved to the appropriate forum.

Moderation Team

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

21 hours ago, Skysnake said:

Why put it in Notepad?

because the OP is making his first steps into scripting, and unaware of the difference between AutoIt capabilities of automating an external program, and AutoIt programming capabilities.

@Astray71, Skysnake is correct, of course. if the file is not too large, use _FileReadToArray() to read the entire file into an array, then loop the array and do what you want with every line.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

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