Mastering TS Net

Charles Warwick charles at techstrategies.com.au
Sun Jul 1 21:40:13 EDT 2018


Hi BR,

There are a series of lessons on tsNet on the LiveCode website:

http://lessons.livecode.com/m/4071/c/235433

If you are looking for an example of how to download something direct to a file, the lesson called “How to asynchronously download via SFTP directly a file” should help.

The same concepts apply for downloading to a file regardless of the protocol being used.

If you can’t quite find an example lesson that answers what you need, let me know and I will get one organised.

Regards,

Charles

> On 2 Jul 2018, at 1:19 am, Sannyasin Brahmanathaswami via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> I really need to get my head around TSNet, so began experiments.
> 
> This is the documentation for tsNetGetFile
> 
> " local tHeaders, tResult
> 
> put tsNetGetFile("1", "/path/to/downloaded/file.dat", \
> "ftp://user:pass@ftp.example.com/file.dat", tHeaders, \
> "transferComplete") into tResult
> 
> on transferComplete pID, pResult, pBytes, pCurlCode
>    local tData, tHeaders
>    if pCurlCode is not 0 then
>        answer tsNetRetrError(pID)
>    else
>    a    nswer "File has been downloaded"
>    end if
>    tsNetCloseConn pID
> end transferComplete
> 
> # but my first attempt to "get it" ... ran into this error. 
> 
> Are there any good lessons on all TSNet functions?
> I am not looking forward to wading into this blind as a bat.
> 
> # variable watcher
> 
> tResult      --        tsneterr: ID already in use
> 
> what is strange is this, the IDE gives the error even before tracing the mouseup.
> 
> So I did not even get off home plate.
> 
> ############
> local tHeaders, tResult
> 
> on mouseup 
> # put a break here... the IDE show an error *before* stepping into the next statement
> # I can't even close the connection with:
>   tsNetCloseConn "1"
>   put empty into tResult
>   put fld aURL into pURL
>   put empty into fld "fldHTTPHeader"
>   put empty  into fld "tHTMLfield"
>   set the itemDel to "/" 
>   put item -1 of pURL into tFileName
>   put ("~/Desktop/"&tFileName) into tLocalFile
>   put tsNetGetFile("1",tLocalFile,pURL,tHeaders,"transferComplete") into tResult
> 
>   --  put libURLLastHTTPHeaders() into fld "fldHTTPHeader" 
> end mouseup
> 
> on transferComplete pID, pResult, pBytes, pCurlCode
>   if pCurlCode is not 0 then
>      answer tsNetRetrError(pID)
>   else
>      answer "File has been downloaded"
>      put tHeaders into fld "fldHTTPHeader"
>   end if
>   tsNetCloseConn pID
> end transferComplete
> 
> BR
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> 





More information about the use-livecode mailing list