AnswerList of Questions
If you have an action requiring a status dialog, but the standard status dialog (StatusDlg) is not sufficient, it is possible to create a custom callback function for those actions requiring a status dialog.
As an example, we will use a custom callback function to show the progress of a file download:
Add the following code to the On Click event of a button:
ShowStatusWindow(); --calls a Global Function (Project > Global Functions)
HTTP.Download("http://www.cisiontech.com/videos/video.rm", "c:\\video.rm", MODE_BINARY, 20, 80, nil, nil, DownloadStatus);
Add the following code to your Global Functions (Project > Global Functions):
--ShowStatusWindow shows the status window, and sets the title
function ShowStatusWindow()
StatusDlg.Show(MB_ICONINFORMATION, false);
StatusDlg.ShowCancelButton(true, "Stop Download");
end
--DownloadStatus is the callback function to be used.
function DownloadStatus (Dled, Total)
StatusDlg.SetMeterRange(0, Math.Floor(Total/1024)); --set the status meter range
StatusDlg.SetMeterPos(Math.Floor(Dled/1024)); --set the current position of the meter
if StatusDlg.IsCancelled() then --if the canceled button is pressed
StatusDlg.Hide(); --hide the status dialog window
Dialog.Message("", "Download canceled with " .. Math.Floor((Total-Dled)/1024) .. " kb left to go"); --display a dialog message
return false; --tell the download to stop
else
if Total == 0 then --if the total is unknown, Total will equal zero
StatusDlg.SetStatusText("Size Unknown (" .. Math.Floor(Dled/1024) .. "kb downloaded so far)");
elseif Total > 0 then --otherwise, the total will be greater than zero
StatusDlg.SetStatusText("Downloaded " .. Math.Floor(Dled/1024) .. " kb of " .. Math.Floor(Total/1024) .. " kb");
end
if Math.Floor(Dled) == Math.Floor(Total) then --once the download is complete, downloaded will equal total
StatusDlg.Hide(); --hide the dialog window
Dialog.Message("Download Complete", Math.Floor(Dled/1024) .. " kb have been downloaded"); --display a dialog message
return false;
else
return true;
end
end
end
Note: ShowStatusWindow() shows the status window and sets the title. DownloadStatus() is the custom callback function, and is called by HTTP.Download.
Applies to:
Professional Edition