Page 1 of 1

Using AT on a Return on Url

Posted: Thu Sep 05, 2024 11:37 am
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

Re: Using AT on a Return on Url

Posted: Thu Sep 05, 2024 10:57 pm
by Wolfgang Ciriack
if .not. empty(cresult)
or
if ValType(cresult) == "C"

Re: Using AT on a Return on Url

Posted: Thu Sep 05, 2024 11:33 pm
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.

Re: Using AT on a Return on Url

Posted: Fri Sep 06, 2024 2:06 pm
by omni
The valtype is what I was looking for, just could not remember it.

Thanks

Re: Using AT on a Return on Url

Posted: Sun Sep 22, 2024 9:03 am
by rdonnay
The ValType() you want for a NIL is this:

IF Valtype(cSomeValue) = 'U' // It's a NIL