Hi, have problem with function calls, rather they pass the compiler. Here is the code for a small program, which queries the map-server coordinates houses in Moscow, from the server receives a response in XML format.
Next is to parse this response, operators and operands. When there is an operator <pos>, the following operand is the coordinates of the house. They are perfectly extracted and converted to their corresponding latitude and longitude of type float, to the condition " if (twostr$ = "pos")". In this condition, the pause Sleep(5000) works great, but the extraction and prepaymania and print - no. That is not happening. Help to understand why what I'm doing wrong
type t_Location
t_LocationA as float
t_LocationL as float
endtype
SetDisplayAspect( 4.0/3.0 )
MainLoop()
end
function MainLoop()
point as t_Location
point = PositionExtract()
do
print( point.t_LocationA )
print( point.t_LocationL )
if getpointerpressed()=1 then exit
Sync()
loop
endfunction
function PositionExtract()
tLpoint as t_Location
numxmloperators as integer
xmlAnswer$ = GetGEO()
numxmloperators = CountStringTokens(xmlAnswer$,"<")
global dim xmlDescription$[numxmloperators+1] as string
global dim operands$[numxmloperators+1] as string
global dim xmlLevel[numxmloperators+1] as integer
level = -1
for i=1 to numxmloperators
onestr$ = GetStringToken( xmlAnswer$, "<", i )
twostr$ = GetStringToken( onestr$, ">", 1 )
three$ = GetStringToken( onestr$, ">", 2 )
if (asc(three$) <> 10)
operands$[i] = three$
endif
//twostr$ = Left( onestr$, Len( onestr$)-2 )
xmlDescription$[i] = twostr$
if Left( xmlDescription$[i], 1) = "/"
xmlLevel[i] = level
dec level
else
inc level
xmlLevel[i] = level
endif
do
print(onestr$)
print(xmlDescription$[i])
print(three$)
tLpoint.t_LocationA = ValFloat(GetStringToken( three$, " ", 1 ))
tLpoint.t_LocationL = ValFloat(GetStringToken( three$, " ", 2 ))
// Print to test a getstring token
print( tLpoint.t_LocationA )
print( tLpoint.t_LocationL )
Sync()
// !!!!!!!!!! the problem here
if (twostr$ = "pos")
tLpoint.t_LocationA = ValFloat(GetStringToken( three$, " ", 1 ))
tLpoint.t_LocationL = ValFloat(GetStringToken( three$, " ", 2 ))
// Print to test a getstring token
print( tLpoint.t_LocationA )
print( tLpoint.t_LocationL )
Sleep(5000)
endif
exit
loop
next i
undim xmlDescription$[]
undim operands$[]
undim xmlLevel[]
endfunction
/* get XML
requested from map-server coordinates of the house specified in the string szServerFile$
*/
function GetGEO()
iSecure=0
szHost$="geocode-maps.yandex.ru"
iHTTP= CreateHTTPConnection()
ret=SetHTTPHost(iHTTP, szHost$, iSecure )
szServerFile$ = "1.x\?geocode=Moscow,+Ozyurnaya+street,+house+10"
szPostData$ = ""
SendHTTPRequestASync( iHTTP, szServerFile$, szPostData$ )
while GetHTTPResponseReady( iHTTP ) = 0
print("Not answer, waiting...")
Sync()
endwhile
request$ = GetHTTPResponse( iHTTP )
CloseHTTPConnection( iHTTP )
DeleteHTTPConnection( iHTTP )
endfunction request$