Read line from opened window...

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
brahama
Newbie
Posts: 4
Joined: Thu Apr 26, 2007 2:28 am

Read line from opened window...

Post by brahama » Fri Apr 27, 2007 6:59 pm

Hi...i was wondering if there is a way to read line by line from an opened Notepad window....

i saw that readln does this but from a filename....

thanks...

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Apr 27, 2007 7:52 pm

ReadLn *does* read from a filename:

ReadLn>FILENAME,LINE_NUM,VAR_TO_STORE_LINE_IN
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Fri Apr 27, 2007 10:10 pm

Hi brahama,

Do you mean you want to write a script that can read the text inside a Notepad window before Notepad has saved the text to a file? If so, read about the GetControlText> command in the Help file then, enter and save this script:

Code: Select all

GetControlText>Untitled - Notepad,Edit,1,npEdit

MDL>Here's the text in your Notepad window:%CRLF%%CRLF%%npEdit%

StringReplace>npEdit,%CRLF%,~,npEdit

MDL>Here's that text again only we've replaced all the CRLF pairs with a ~%CRLF%%CRLF%%npEdit%
- open a new Notepad window, type in 3 or 4 short lines of text but don't save the file
- run the above macro
- It will read all the text from Notepad and display it
- Click OK and it will display the text again, only CRLF (Carriage Return and Linefeed pairs) have been replaced with ~ characters. Did this just to prove that the CRLF pairs are there.

I don't think there is a convenient command or structure to just read in say... just the 3rd line... but since you can read the whole mess into a variable, you can then setup a loop to search through that variable, building lines as you go. Every time you hit a CRLF, you've read in another line so you could save that line in an array variable and when you had processed it all, you'd have all the lines loaded into the array. Want line three, its in linearray[3] or whatever you called it.

Hope this helped, take care.
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

brahama
Newbie
Posts: 4
Joined: Thu Apr 26, 2007 2:28 am

Post by brahama » Fri Apr 27, 2007 11:35 pm

thats exactly what i wanted jpuziano....i will try it now....great explanation...thanks a lot....

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Sat Apr 28, 2007 11:48 pm

brahama wrote:thats exactly what i wanted jpuziano....i will try it now....great explanation...thanks a lot....
Glad to hear. If you're willing to share your finished script, please post it here as it may be just the thing others are looking for. Also, quite often someone else may suggest an improvement that you may not have thought of.

Take care :)
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts