libUrlDownloadToFile: desktop ok, Android no

Nicolas Cueto niconiko at gmail.com
Thu Jan 11 23:37:55 EST 2018


Hello.

Below is the script used to download a text file. Which works on the
Windows desktop. But on my Nexus 5, "error" is returned by the  script
commands "log" and "logflushbuffer".

Why oh why ...

Help! please.

---------------------------

BUTTON SCRIPT

on mouseUp
   put empty into the last field
   libUrlDownloadToFile binURL(), specialFolderPath("documents") \
         & slash & "dictionary.txt", "urlDownloadStatus"
   log "started download of" && binURL()
end mouseUp

on urlDownloadStatus pUrl, pStatus
   log pStatus && pUrl
end urlDownloadStatus


CARD SCRIPT

local sLogBuffer
local sLogBuffering="false"

on log pMsg
   put pMsg & return after sLogBuffer
   if not sLogBuffering then logFlushBuffer
end log

on logFlushBuffer
   put sLogBuffer after field "logField"
   put empty into sLogBuffer
   set the vscroll of field "logfield" to 65536
end logFlushBuffer

on clearLog
   put empty into field "logField"
   put empty into sLogBuffer
end clearLog

on logStartBuffer
   put true into sLogBuffering
end logStartBuffer

on logEndBuffer
   logFlushBuffer
   put false into sLogBuffering
end logEndBuffer

--------

on preOpenCard
   if the environment is not "mobile" then
      libUrlSetStatusCallback "urlProgressCallback", the long ID of me
   end if
   pass preOpenCard
end preOpenCard

on closeCard
   if the environment is not "mobile" then
      libUrlSetStatusCallback
   end if
end closeCard

on urlProgressCallback pStatus, pURL
   urlProgress (item 1 of pStatus), pURL, (item 2 of pStatus), (item 3 of
pStatus)
end urlProgressCallback

on urlProgress pURL, pStatus, pRecieved, pTotal
   if pStatus is "loading" then
      logStartBuffer
   else
      logEndBuffer
   end if
   log pStatus && pURL && pRecieved && pTotal
end urlProgress

local sURL = "http://webserver.com/docs/UTF8_file.txt"

function binURL
   return sURL
end binURL



More information about the use-livecode mailing list