Jump to content

Recommended Posts

Posted

Hi,

For my script I want to get some information from notepad, so first take sentence 1 to a string, then line 2 to a second string, then line 3 to the third string etc. Of course I could select the information I want, but how to get this into a string?

(Sorry for asking this simple question, but I can't find the answer.)

Posted

Yes, I could use the Fileread(line) option for my problem, but this asks for the line etc, in my notepad not every parameter is on a new line, and not every line has the same number of characters.

I could always select the text without problems,

It's much easier for me if the selected text puts directly in a string. Isn't this possible?

Posted

You'd have to have some form of delimiter for a sentence.

Period would be used for a sentence of normal text, but there's other characters that are used as well. So maybe StringSplit() the text file and loop the array for each line of text.

#include <Array.au3>

$textfile = @ScriptDir & "\textfile.txt"

$FO = FileOpen($textfile, 0)
$FR = FileRead($FO)
FileClose($FO)
$SS = StringSplit(StringTrimRight(StringReplace($FR, @CRLF, ""), 1), ".")

_ArrayDisplay($SS, "Array Of Strings")

the text I used.

Here are some sentences in a text file.

But not all the lines will be the same. Maybe that's because you can put more then 1 sentence on a line.
Maybe the sentence could be
wrapped to the next line as well as more then 1 sentence on a line. So you need a delimiter of some
sort so you can destiguish where the sentence ends or the next starts.

Cheers

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