How to trim whitespace with EVAL

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
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
Tom, Tech Support
Posts: 3834
Joined: Mon May 31, 2010 4:59 pm

Re:How to trim whitespace with EVAL

Post by Tom, Tech Support » Wed Jan 11, 2023 1:43 pm

Blakero wrote:
Fri Dec 02, 2022 5:50 am
Hello,
I'm extracting data that contains spaces, and so I use the trim() function to removes the spaces.
But It doesn't work!
Here's a sample code :

Code: Select all

VERSION BUILD=11.5.499.3066
TAB T=1
TAB CLOSEALLOTHERS

SET !VAR0 <SP><SP><SP><SP><SP><SP>Hi<SP>
SET someVar EVAL("var some='{{!VAR0}}'.trim(); some;")
PROMPT {{someVar}}
The code above should work normally but it returns this error :
Error -1250: JScript statement in EVAL contains the following error: Objects of type 'System.String' do not have such a member. Line 6: SET someVar EVAL("var some='{{!VAR0}}'.trim(); some;")
JavaScript does have trim() function and it works on IE and all browsers!

Hi Blakero,

Support for the trim() function is dependent on the version of the Javascript engine in use. It looks like you recorded your macro with an older version of the iMacros browser, and hence trim() is not available. However, you can use the replace() function with a regular expression to achieve the same result. An example is provided under the Manipulate extraction section on the EVAL command reference page.
Last edited by Tom, Tech Support on Mon Jan 16, 2023 10:26 am, edited 1 time in total.
Reason: Removed original post due to being a copy-and-paste of https://forum.imacros.net/viewtopic.php?f=7&t=27582&p=89487
Regards,

Tom, iMacros Support
Post Reply