System_ComObject error when sorting with Javascript Gatherer

Here you can ask anything related to JavaScript as applied to Helium Scraper.
Post Reply
cj-a-min
Posts: 4
Joined: Tue Aug 30, 2011 10:58 pm

System_ComObject error when sorting with Javascript Gatherer

Post by cj-a-min » Tue Aug 30, 2011 11:18 pm

Your article on Minimal JavaScript for non programmers tutorial, was very informative. But, I don't believe it addressed my issue in sorting the variables.

I am extracting names like this, Doe, John. I need to convert this to John Doe:

My JavaScript gatherer, with limited knowledge on Javascript. And using your built in text-gatherer feature I was able to code this:

Code: Select all

//returns the first name, using the space as the delimiter
var step0_result = element.innerText.replace(/\r\n/g, "\n");
var step1_slices = step0_result.split(" ");
var step1_result = step1_slices[1];
//returns the last name, using the comma as the delimiter
var step2_result = element.innerText.replace(/\r\n/g, "\n");
var step3_slices = step2_result.split(",");
var step3_result = step3_slices[0];
//Now I need sorted, on the return like so, but this doesn't work
return [step1_result,step3_result];
With above code I get System_ComObject error.

However, when using :

Code: Select all

return step1_result;
Instead of:

Code: Select all

return [step1_result,step3_result];
It works, but only gives me first name.

How do I code this to work , and return John Doe? Or maybe i'm on the wrong track altogether. Or maybe there is a another solution using a different javascript?

cj-a-min
Posts: 4
Joined: Tue Aug 30, 2011 10:58 pm

Re: System_ComObject error when sorting with Javascript Gath

Post by cj-a-min » Wed Aug 31, 2011 5:00 am

OK using your "Minimal JavaScript for non programmers tutorial", I solved it.

In case anyone needs it:

Code: Select all

return step1_result + " " + step3_result;
I am always learning...Thanks for facilitating this... :D

Post Reply