Advanced Parsing Help

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Advanced Parsing Help

Post by kpassaur » Sat Sep 20, 2008 10:28 am

I am trying to extract numbers from an page acquired with HTTPRequest and have run into issues

If I place the number in a variable (the number being 8 characters long) and test it with


IF>{(%CN% > 0) AND (%CN% < 30000000)}

When there is puncutation in the variable it fails with a message
Line:33 e not appropriate

So I decided to use a sub routine that I have in the past with VBScript which tests for ASCII Characters and that locks up as there is something in the page it does not like, it displays as little boxes in notepad.

Now for the kicker, if I copy the text from the downloaded page from Notepad to Word and then back to Notepad the VBScript option will work. However, this is not an acceptable option

Does anyone have any ideas as to what else to try?

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Sat Sep 20, 2008 1:17 pm

Hi kpassaur,
Will this work?

Code: Select all

let>CN=300.0000
StringReplace>CN,.,,CN
IF>{(%CN% > 0) AND (%CN% < 30000000)}
MessageModal>True
else
MessageModal>False
endifModal>False
endif

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Parsing Number

Post by kpassaur » Sat Sep 20, 2008 2:56 pm

I have sort of a fix, what seems to be causing it to hang up is when it comes to a " if I place a line before it

StringReplace>%CN%,",,CN

It will not get hung up. However, there is still major issues. When using HTTPRequest the data has extra characters of some kind, it is not just the text. But if I write the response to a file then read it line by line and write it back it removes some of it. (but not all of it)

Since I am just trying to parse out numbers I have resorted to using StringReplace on all letters and puncuation. It takes a 32K text file down to 3K in less than a second, but the script never seems to finnish. I have stepped through it and it does the process but something in the file is causing it to just run and run.

This is the page I am trying to get

HTTPRequest>http://www.jokeswarehouse.com/cgi-bin/c ... MLResponse

Anyone know of another way?

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Sat Sep 20, 2008 3:36 pm

If you see "boxes" and Notepad -> Word -> Notepad fixes it then you most likely have control (unprintable) ascii characters in there. Have you tried the vbscript posted by support in this thread http://www.mjtnet.com/forum/viewtopic.p ... hlight=asc

If you see "boxes" then it helps to use a HEX editor to take a look. There are a lot of free ones available.

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Sat Sep 20, 2008 11:31 pm

Here is a simple filter you can use within Macro Script.

let>validchar=0123456789
let>Str2Chk=123%456
let>Pos2Chk=0
len>Str2Chk,LenOfStr
let>CleanStr=
label>StartCheck
let>Pos2Chk=Pos2Chk+1
if>Pos2Chk>LenOfStr
goto>EndCheck
endif
midstr>Str2Chk,Pos2Chk,1,Char2Chk
pos>Char2Chk,validchar,1,Found
if>Found>0
con>CleanStr,Char2Chk
goto>StartCheck
else
goto>StartCheck
endif
label>EndCheck

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