Hi,
In the Automating Windows for Beginners video, it demonstrates sending text to Notepad using a Send> & Press Enter pair for each line. Is there a way of sending a block of text (and building a string variable) all at once using something like the heredoc method of delimiting multi-line strings in PHP?:
$str = <<<EOD
Example of string
spanning multiple lines
using heredoc syntax.
EOD;
Regards,
Sending Blocks of Text
Moderators: JRL, Dorian (MJT support)
- Dorian (MJT support)
- Automation Wizard
- Posts: 1416
- Joined: Sun Nov 03, 2002 3:19 am
Re: Sending Blocks of Text
I'm not a php programmer so am unfamiliar with that. Others here may be able to comment specifically. ReadFile will read an entire text file as one variable, which can then be parsed afterwards.
But you can build strings in a number of ways. For example :
Of course your vars could have been taken from a variety of sources - reading Excel, reading a text file, scraping, user entry etc etc.
Now let's say we want to enter a block of text but we don't want to use Send to send the characters one at a time. Sometimes this is actually necessary, as occasionally websites or applications won't like having a lot of text send to them that way.
Here's the way I do that : put the created string into Windows clipboard, then paste it.
If you have a sample string we'd be happy to give more specific advice.
But you can build strings in a number of ways. For example :
Code: Select all
Let>var1=cat
Let>var2=dog
Let>var3=fish
Let>combinedvars=%var1% %var2% %var3%
messagemodal>combinedvars
Now let's say we want to enter a block of text but we don't want to use Send to send the characters one at a time. Sometimes this is actually necessary, as occasionally websites or applications won't like having a lot of text send to them that way.
Here's the way I do that : put the created string into Windows clipboard, then paste it.
Code: Select all
//Your block of text
Let>var1=In the Automating Windows for Beginners video, it demonstrates sending text to Notepad using a Send> & Press Enter pair for each line. Is there a way of sending a block of text (and building a string variable) all at once using something like the heredoc method of delimiting multi-line strings in PHP?:
//Put it in the clipboard
put>%var1%
//Le Notepad so we have somewhere to paste the block
Run>Notepad
WaitWindowOpen>Untitled*
SetFocus>Untitled*
WaitWindowFocused>Untitled*
//Paste it as one block (once you've set focus and have the cursor where you want it
Press Ctrl
Send>v
Release Ctrl
Re: Sending Blocks of Text
Thanks for the quick reply, Dorian.
Inserting the system variable %CRLF% in the var1 text achieved what I wanted, perfectly. Many thanks.
By the way, do string variables have a maximum length and can/do you specify a numeric variable type as an integer, double, long, etc?
Regards,
Inserting the system variable %CRLF% in the var1 text achieved what I wanted, perfectly. Many thanks.
Code: Select all
Let>var1=In the Automating Windows for Beginners video, it demonstrates sending text to Notepad using a Send> & Press Enter pair for each line.%CRLF%%CRLF%Is there a way of sending a block of text (and building a string variable) all at once using something like the heredoc method of delimiting multi-line strings in PHP?:%CRLF%%CRLF%In the Automating Windows for Beginners video, it demonstrates sending text to Notepad using a Send> & Press Enter pair for each line.%CRLF%%CRLF%Is there a way of sending a block of text (and building a string variable) all at once using something like the heredoc method of delimiting multi-line strings in PHP?:%CRLF%%CRLF%In the Automating Windows for Beginners video, it demonstrates sending text to Notepad using a Send> & Press Enter pair for each line.%CRLF%%CRLF%Is there a way of sending a block of text (and building a string variable) all at once using something like the heredoc method of delimiting multi-line strings in PHP?:%CRLF%%CRLF%In the Automating Windows for Beginners video, it demonstrates sending text to Notepad using a Send> & Press Enter pair for each line.%CRLF%%CRLF%Is there a way of sending a block of text (and building a string variable) all at once using something like the heredoc method of delimiting multi-line strings in PHP?:%CRLF%%CRLF%
Regards,
- Dorian (MJT support)
- Automation Wizard
- Posts: 1416
- Joined: Sun Nov 03, 2002 3:19 am
Re: Sending Blocks of Text
There's no variable length limit in Macro Scheduler, but there may be one in Windows, or we may run out of system resources. Curiosity got the better of me so I wrote this script which simply builds a very long string.
Letting it loop 25 times pops the message "var1 is 167772160 chars long". Looping it 26 times gave me an out of memory error. So it seems for my system at least, my strings can only be a mere 167.7 million characters.
The help article on type should answer your other question.
Letting it loop 25 times pops the message "var1 is 167772160 chars long". Looping it 26 times gave me an out of memory error. So it seems for my system at least, my strings can only be a mere 167.7 million characters.
Code: Select all
let>k=0
let>var1=hello
repeat>k
let>k=k+1
let>var1=%var1%%var1%
Until>k,25
len>var1,lenvar1
mdl>var1 is %lenvar1% chars long