Replace new line character

Discussions and Tech Support related to automating the iMacros Browser or Internet Explorer from any scripting and programming language, such as VBS (WSH), VBA, VB, Perl, Delphi, C# or C++.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
techimac
Posts: 482
Joined: Fri Feb 20, 2015 9:27 pm

Replace new line character

Post by techimac » Wed Jul 18, 2018 12:59 pm

https://www.y8.com/games/penthouse_pool

Code: Select all

iimPlay('Code:'
	+ 'SET !ERRORIGNORE YES\n'
	+ 'TAG POS=1 TYPE=DIV ATTR=CLASS:keys-for-game<SP>centered-list EXTRACT=TXT \n'
	+ 'SET CONTROLS EVAL("var x=\'{{!EXTRACT}}\'.trim();x=x.replace(/[\\n\\r]/g, \'\');x=x.replace(\'                                \',\', \');x=x.replace(\'                                \',\', \');x=x.replace(\'                                \',\', \');x;") \n'
	+ 'PROMPT {{CONTROLS}} \n'
)
Can some fix code to replace new line characters?
and I am replacing same text 3 times. Can it be done in FOR loop inside EVAL?

This code works but without replacing new line character

Code: Select all

iimPlay('Code:'
	+ 'SET !ERRORIGNORE YES\n'
	+ 'TAG POS=1 TYPE=DIV ATTR=CLASS:keys-for-game<SP>centered-list EXTRACT=TXT \n'
	+ 'SET CONTROLS EVAL("var x=\'{{!EXTRACT}}\'.trim();x=x.replace(\'                                \',\', \');x=x.replace(\'                                \',\', \');x=x.replace(\'                                \',\', \');x;") \n'
	+ 'PROMPT {{CONTROLS}} \n'
)
Available for custom iim, javascript iMacros scripts
techimac
Posts: 482
Joined: Fri Feb 20, 2015 9:27 pm

Re: Replace new line character

Post by techimac » Wed Jul 18, 2018 1:18 pm

SOLVED

Code: Select all

iimPlay('Code:'
	+ 'SET !ERRORIGNORE YES \n'
	+ 'TAG POS=1 TYPE=DIV ATTR=CLASS:keys-for-game<SP>centered-list EXTRACT=TXT \n'
	+ 'SET CONTROLS EVAL("var x=\'{{!EXTRACT}}\'.trim();x=x.replace(/\\\\n+/g, \' \');for(var i=1;i<=2;i++){x=x.replace(\'                                   \',\', \')};x") \n'
	+ 'PROMPT {{CONTROLS}} \n'
)

Available for custom iim, javascript iMacros scripts
Post Reply