Re: Mastering TS Net

2018-07-05 Thread Sannyasin Brahmanathaswami via use-livecode
With TSGetNet, is it possible to just get the "status code" ("200" is good, 
"404" it bad, among other things)

Of a file on a webserver, *before* you download it? If it is a 404 you "bail on 
the operation", in form the user "Not Found"  but if it is 200, continue to 
stream it?

Brahmanathaswami
 

On 7/2/18, 5:19 AM, "use-livecode on behalf of Sannyasin Brahmanathaswami via 
use-livecode"  wrote:

I looked at the lesson. Quite good!

I think one more lesson may be useful. 

In my case I will use a "slide show"  as a use case.

(But there others, thinking of streaming music playlist)

1) Assume you have the URLs for a slideshow; 
2) you fetch this by calling JSON/Text file with the urls for a slide show 
which exists on the server.
3) Let say you have 100 slides/URLs
4) Galleria (our web app jquery/html5) uses "lazyload 3" parameter, which 
asynchronously loads the next the 3 slides (besides the one you are viewing) in 
the background, then users view the next slide (already downloaded) -there is 
no delay.

So, with TSNetGet

How would set this up Livecode?

You don't want to "overwhelm" the phone with async calls to 100 
connections/slide. (Galleria suggests "3")

But there is the advantage of taking the call back message,  get 3 at a 
time, store them in the documents folder, finally the user has the slides show 
on his phone, later he can view it off line. 

At the retrieval of the 100th slide, then we informed the user "Slideshow 
is download complete."

It the user "bails" on slide 36, when he comes back again. TSNetGet starts 
over but the only which slide 37.

That last part may not want to part of your lessons. Though it would be 
easy enough to check "these is a file" and if it is true, then TSGetNet, so 
"next repeat" without downloading.

I could work this out myself, but is such a common use case, everyone would 
benefit from it.

Brahmanathaswami
 

On 7/1/18, 3:40 PM, "use-livecode on behalf of Charles Warwick via 
use-livecode"  wrote:

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

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your 
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Mastering TS Net

2018-07-02 Thread Andrew Bell via use-livecode
Like Jacque mentioned, I don't think you need to bother with tsNet for  
local files since they should be almost instantly loaded.


I too struggled with tsNet when I first tried to implement it, but  
this website helped me more than the LiveCode pages:  
https://www.techstrategies.com.au/tsnet-resources/


The problem you are encountering is that you can only have one unique  
ID referenced at a time (first parameter). If you try to make another  
call using that ID before the first call is returned then you'll get  
an error. Once a call with the ID has been finished (successful or  
not), that ID is recycled and available for use again.


The documentation doesn't explain well (in my initial understanding)  
that this doesn't have to be "1" or even a number. I experimented with  
random(1) as my pID before encountering that same "ID already in  
use" error and discovered that for most of my uses I could just  
hard-code a text based ID that made more sense to me when  
troubleshooting like "get new image" or "check for updates" or even  
some variable with a unique value (like your tFileName).


--Andrew Bell



Date: Sun, 1 Jul 2018 15:19:34 +
From: Sannyasin Brahmanathaswami 
To: How LiveCode 
Subject: Mastering TS Net
Message-ID: 
Content-Type: text/plain; charset="utf-8"

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:p...@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/") 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


Date: Sun, 01 Jul 2018 13:00:44 -0500
From: "J. Landman Gay" 
To: How to use LiveCode 
Subject: Re: Mastering TS Net
Message-ID:
<16457010ce0.285b.5e131b4e58299f54a9f0b9c05d4f0...@hyperactivesw.com>
Content-Type: text/plain; format=flowed; charset="us-ascii"

Does TSNet even work with local files? For local files use the read/write
commands or "get/put url".

With a commercial license you shouldn't need to deal with the lower level
functions for internet communication. The basic put, post, and get commands
should do it.

--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
On July 1, 2018 10:21:38 AM Sannyasin Brahmanathaswami via use-livecode
 wrote:



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/") 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
   

Re: Mastering TS Net

2018-07-02 Thread Sannyasin Brahmanathaswami via use-livecode
I looked at the lesson. Quite good!

I think one more lesson may be useful. 

In my case I will use a "slide show"  as a use case.

(But there others, thinking of streaming music playlist)

1) Assume you have the URLs for a slideshow; 
2) you fetch this by calling JSON/Text file with the urls for a slide show 
which exists on the server.
3) Let say you have 100 slides/URLs
4) Galleria (our web app jquery/html5) uses "lazyload 3" parameter, which 
asynchronously loads the next the 3 slides (besides the one you are viewing) in 
the background, then users view the next slide (already downloaded) -there is 
no delay.

So, with TSNetGet

How would set this up Livecode?

You don't want to "overwhelm" the phone with async calls to 100 
connections/slide. (Galleria suggests "3")

But there is the advantage of taking the call back message,  get 3 at a time, 
store them in the documents folder, finally the user has the slides show on his 
phone, later he can view it off line. 

At the retrieval of the 100th slide, then we informed the user "Slideshow is 
download complete."

It the user "bails" on slide 36, when he comes back again. TSNetGet starts over 
but the only which slide 37.

That last part may not want to part of your lessons. Though it would be easy 
enough to check "these is a file" and if it is true, then TSGetNet, so "next 
repeat" without downloading.

I could work this out myself, but is such a common use case, everyone would 
benefit from it.

Brahmanathaswami
 

On 7/1/18, 3:40 PM, "use-livecode on behalf of Charles Warwick via 
use-livecode"  wrote:

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

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Mastering TS Net

2018-07-02 Thread Sannyasin Brahmanathaswami via use-livecode
Charles: Mysteries

I booted Livecode fresh the morning, and used the same script. But I no longer 
get 

tResult  --tsneterr: ID already in use.

Dictionary script works as expected "File downloaded" 

local tHeaders, tResult

on mouseup
   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 ("/Users/brahmanathaswami/Desktop/") 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

># variable watcher
> 
> tResult  --tsneterr: ID already in use

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Mastering TS Net

2018-07-02 Thread Sannyasin Brahmanathaswami via use-livecode
@Charles: Thanks, I look into lessons.

But, using the dictionary example
Why do we get the 

> # variable watcher
> 
> tResult  --tsneterr: ID already in use

Even *before* the trace the script? I have break 

On mouseup

But it gives this error even before starting the trace?

@ Jacqueline: why use TSNet:
1) because the "libURLLastRHHeaders()" are only available to desktop. And I 
want to see them on mobile
2) because we are working with the "cloud" and async download means I can pass 
array to TSNet to open connection to download several files at once; like 
"load" but with more control... ( I think. I have yet to study it out) and get 
the headers.

Brahmanathaswami
 

On 7/1/18, 3:40 PM, "use-livecode on behalf of Charles Warwick via 
use-livecode"  wrote:

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 
 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:p...@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
>answer "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/") 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@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> 


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your 
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Mastering TS Net

2018-07-01 Thread Charles Warwick via use-livecode
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 
>  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:p...@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
>answer "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/") 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@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> 


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Mastering TS Net

2018-07-01 Thread J. Landman Gay via use-livecode
Does TSNet even work with local files? For local files use the read/write 
commands or "get/put url".


With a commercial license you shouldn't need to deal with the lower level 
functions for internet communication. The basic put, post, and get commands 
should do it.


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
On July 1, 2018 10:21:38 AM Sannyasin Brahmanathaswami via use-livecode 
 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:p...@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/") 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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your 
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-livecode





___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Mastering TS Net

2018-07-01 Thread Sannyasin Brahmanathaswami via use-livecode
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:p...@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/") 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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode