See text returned from a tsNetCustom TCP call
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
See text returned from a tsNetCustom TCP call
When I issue a TCP call using tsNetCustom, the server sends a response as text. How can I put the returned text into a variable so it can be shown either as an "answer" (dialog box) or set as the text of a display field?
Re: See text returned from a tsNetCustom TCP call
I never used tsNetCustom, but this is a function, so doesn't it (or "the result") return something useful?
Or the params your "callback" handler comes with? In case you use a callback message.
Or the params your "callback" handler comes with? In case you use a callback message.
Re: See text returned from a tsNetCustom TCP call
I'm not familiar with tsNetCustom, but looking the documentation:
This basically means it returns errors if they are present as as string, and you run this comment but putting it into a variable, eg:The tsNetCustom function returns empty on success. On error, the return value will be a string containing the error starting with "tsneterr:".
Code: Select all
get tsNetCustom (parameters) --> the returned value is in the 'it' variable
// or
put tsNetCustom (parameters) into tError --> the returned value is in the tError variable.
I'm guessing this is not what you're after though... I'm guessing you want to use data that may be returned.
In that case you'd probably needs to use the callback function that manages this. for example in the code below, pCallBack is the name of the handler to call on completion.
Code: Select all
tsNetCustom(<pConnectionID>, <pURL>, <pRequest>, <pHeaders>, <pCallback>)
Code: Select all
on transferComplete pConnectionID, pResult, pData, pBytesTransferred
if pResult is not 200 then -- 200 is the HTTP success code
-- Handle error cases here
answer "Error: " & pResult
else
-- Process the returned data
put pData into field "Output"
end if
-- Clean up the connection
tsNetCloseConn pConnectionID
end transferComplete