Using AT on a Return on Url

This forum is for eXpress++ general support.
Post Reply
Message
Author
omni
Posts: 540
Joined: Thu Jan 28, 2010 9:34 am

Using AT on a Return on Url

#1 Post by omni »

Roger,

We do a lot of url interfaces to import data. On one in particular where there are normally 4-5 pages involved, since they max out on their side, they send the next link part for the next page. We import these all day long, every 5 minutes or so.
There is also an option to start where it left off, but we have found that bypasses some of the data, just FYI.

Anyway, when it downloads a page it looks for the characters that stipulate there are more pages, checked each time.
//this part of the code

cResult := loadfromUrl(cUrl,,,,,"GET",,cHeader)
//dc_winalert(cResult)
xfile := '\\10.0.102.21\Omni\oiswin\vehiclelog'+str(n,1)+'.xml'

KEYIN=INKEY(5)

nLogHandle := FOpen(xfile,FO_READWRITE)
IF nLogHandle <= 0
nLogHandle := FCreate(xfile)
ENDIF


fwrite(nLogHandle, cResult )
FClose(nLogHandle)
//now see if another page
//"hasNextPage":false}

anotherpage=at(":true",cresult)

this may work for hundreds of times without an issue and we also have similar downloads of multi-pages (they limit to max characters)

Then we get this error.
oError:args :
-> VALTYPE: C VALUE: :true
-> VALTYPE: U VALUE: NIL
oError:canDefault : N
oError:canRetry : N
oError:canSubstitute: Y
oError:cargo : NIL
oError:description : Parameter has a wrong data type
oError:filename :
oError:genCode : 2


i think that means it downloaded nothing, or the result was nil. So if that is correct, we need to check for a nil result before going any further.

Do not know how to do that, although think I have seen it somewhere.

Probably simple to you, but I am getting old..

thanks,
Fred
Omni

Wolfgang Ciriack
Posts: 481
Joined: Wed Jan 27, 2010 10:25 pm
Location: Berlin Germany

Re: Using AT on a Return on Url

#2 Post by Wolfgang Ciriack »

if .not. empty(cresult)
or
if ValType(cresult) == "C"
_______________________
Best Regards
Wolfgang

skiman
Posts: 1191
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Using AT on a Return on Url

#3 Post by skiman »

Hi,

maybe sometimes there is a 'page not found' or another error.

You could test on the lenght of cResult as 'if (len(cResult)<500' then it can't be correct.

Sometimes I also check for a specific text in the file. If there should be a specific tag in the result (xml), you could test 'if 'specific tag' $ cResult'. If not, there is a problem.
Best regards,

Chris.
www.aboservice.be

omni
Posts: 540
Joined: Thu Jan 28, 2010 9:34 am

Re: Using AT on a Return on Url

#4 Post by omni »

The valtype is what I was looking for, just could not remember it.

Thanks

Post Reply