Manual Error: HTTP.Download Example Callback Function broken

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Bl4ckSh33p
    Indigo Rose Customer
    • Jun 2010
    • 248

    Manual Error: HTTP.Download Example Callback Function broken

    Hi! I just tried to use a callback function to update some progress indicator (because animated gifs in a web object or slideshows and even a timer set to add a text every 0.5sec is stuck when you do something like HTTP.Download for an update check. (is there no way to make an animated progress while something is working in the background?)

    The CallBack function needs to return true or false to let the download know if it shoul dcontinue (says the helpfile). But the example has no return value and the app is not responding anymore when I use it. When I add "return true;" its working.

    http://www.indigorose.com/webhelp/am...d_Examples.htm > Example #3
    -- Callback function for HTTP.Download
    Bl4ckSh33p-Soft - Custom Software and Indie Games
  • Shrek
    Forum Member
    • Jul 2012
    • 723

    #2
    Modify this to suite your needs.
    Attached Files

    Comment

    • Bl4ckSh33p
      Indigo Rose Customer
      • Jun 2010
      • 248

      #3
      Thank you. I will take a look at it.

      I found another error in the manual on the Callback Function Examples page with the title "Create a Custom Callback Function" (the online help search seems broken).
      The last line says "Note: ShowStatusWindow() shows the status window and sets the title. DownloadStatus() is the custom callback function, and is called by HTTP.Download." but the example above does not modify or set any title.
      Bl4ckSh33p-Soft - Custom Software and Indie Games

      Comment

      • Bl4ckSh33p
        Indigo Rose Customer
        • Jun 2010
        • 248

        #4
        and when I use this example from the helpfile I get a message about 0KB downloaded almost instantly and downloading fails.

        --DownloadStatus is the callback function to be used.
        function DownloadStatus (BytesRead, FileSize, TransferRate, SecondsLeft, SecondsLeftFormat, Message)
        -- Set the status meter's range
        StatusDlg.SetMeterRange(0, Math.Floor(FileSize/1024));
        -- Set the meter position
        StatusDlg.SetMeterPos(Math.Floor(BytesRead/1024));

        -- Check if the cancel button was pressed
        if StatusDlg.IsCancelled() then
        -- Cancel button was pressed. Hide status dialog and terminate download
        StatusDlg.Hide();
        return false;
        else
        -- Cancel button was not pressed, determine message to be displayed
        if FileSize == 0 then
        -- Display 'size unknown' message
        StatusDlg.SetStatusText("Size Unknown (" .. Math.Floor(BytesRead/1024) .. "kb downloaded so far)");
        elseif FileSize > 0 then
        -- Display 'downloaded of total' message
        StatusDlg.SetStatusText("Downloaded " .. Math.Floor(BytesRead/1024) .. " kb of " .. Math.Floor(FileSize/1024) .. " kb");
        end
        --######START####################################### ######
        -- Determine if end of download was reached:
        -- Message will = "", the end of the download is a 'busy' state
        -- BytesRead will be > 0, because more than 1 byte will have been transferred
        -- BytesRead will = FileSize, unless FileSize is unknown (0)
        if (Message == "") and (BytesRead > 0) and (BytesRead == FileSize or FileSize == 0) then
        -- The download has completed, hide the status dialog and display complete message
        StatusDlg.Hide();
        Dialog.Message("Download Complete", Math.Floor(BytesRead/1024) .. " kb have been downloaded");
        return false;
        else
        -- The download has not ended, continue to download
        return true;
        end
        --######END######################################### ####
        end
        end
        It works if I remove the part between the "########################" and just "return true;".



        When I try to use "SetTitle" for the StatusDialog it does not seem to work in the callback function or before showing the window, only right after showing it. Some examples mentioned setting/changing the title in the callback function. Is this a bug or why does it not update when I put it in the function?
        Bl4ckSh33p-Soft - Custom Software and Indie Games

        Comment

        Working...
        X