Re: errors in ex.err

new topic     » goto parent     » topic index » view thread      » older message » newer message

Kat wrote:
> 
> I've been getting less than useful error msgs lately, from an app that has run
>
> for years fairly flawlessly (except for the strange errors i reported and got 
> laughed at here, and so i restart the app when i detect them), but this one i 
> don't see how i can detect in advance:
> 
> <from ex.err>
> ================
> u:\newsgetter\Eu webgetter tcp4u\Getabcnews4.exw:478
> slice lower index is less than 1 (-4) 
> 
> u:\newsgetter\Eu webgetter tcp4u\Getabcnews4.exw:478	        if length(href) 
> and not equal(href,"") and
> 
>  href = {47'/'}
> 
> ===========================
> </from>
> 
> The entire if-then code is:
> }}}
<eucode>
>         if length(href) and not equal(href,"") and
>            (not match("/REUTERS",upper(href))) and
>            (not match("/AP",upper(href))) and
>            (
>            (not match(".HTML",upper(href[length(href)-5..length(href)]))) and
>            (not match(".HTM", upper(href[length(href)-4..length(href)])))
>            )
>           then href = ""
>         end if
> </eucode>
{{{

> 
> As you can see, i FIRST test to see if there is anything at all in href, and
> that
> is where Eu is reporting i made a mistake. Naturally, i am now testing to see 
> if (length(href) > 5) .

Consider mastering regular expressions. If you are going to work
with text (especially in the Internet world), they are more than
worth the effort. Learn PERL compatible regular expressions,
such as, in the PCRE library which Bochert has provided as a
user contribution, in Javascript, in many other apps, and of
course in PERL.

I understand that href, in your code, will always be a
sequence/string.

One if statement using a regular expression match and a pattern
like the following one will work better than your large compound
if statement, and you don't have to worry about the length of
href.

Example regular expression pattern to use:
  "(/REUTERS)|(/AP)|(.HTML$)|(.HTM$)"

I would set the case sensitivity option/switch to do being case
insensitive. Then (using Bochert's library) use RGXscan() (or
RGXfind()) with the pattern and RGXcnt in a single if statement.

I know this is not a quick fix/help. But, in the long term, you would
have a much more useful and powerful tool at your disposal. One
that will save your hours of programming time and many headaches.

If you want some help getting started with regular expressions, 
email me individually.

Terry Constant

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu