Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Examples
#1
Hi. Happy new year.

I've looked into examples folder but don't see nothing about downloading files to local folder. In fact, i just see few examples like get text, fill form, and little more.
where can i find examples for downloading files?
TIA
Regards.


Attached Files Thumbnail(s)
   

CYZ
Reply
#2
Hi,

Happy New Year to you too.
There's more examples, but it might be easy to miss I guess?
From the top of my head, an example on how-to handle New Windows, another one on how-to do bidirectional communication between a host application and a web page, handling of basic authentication and more.
The documentation also has code examples (some in DataFlex, but most of those examples have been rewritten in VB6 as you'll see in the next update). Obviously with documentation and code examples, there's always room for improvement.

re. a VFP9 example to show how-to download files.
I had send you one by email on 24 November.

Let me post it again here in public.

Code:
&& this part is in a button or wherever you want to invoke a download
LOCAL lsURL0
LOCAL lcURL1
LOCAL IsSuccess as Boolean
LOCAL ErrStat as Integer
LOCAL Err as Integer

lcURL1 = ''
lcURL2 = ''
lcURL0 = ''
IsSuccess = .F.
ErrStat = 0
lcURL0 = 'https://antwise.com/'
downloadFileName = ''
&& dummy get (navigates to the antwise site)
Err = thisform.oantView.object.NavigateWithWebResourceRequestSync(lcURL0,'GET','','',IsSuccess,ErrStat)

IsSuccess = .F.
ErrStat = 0
downloadItem = 1
lcURL1 = 'https://antwise.com/download/testEfi.iso.zip'
downloadFileName = 'testURL1.zip'
Wait Window "" timeout 0.01      && ... helps at times
DOEVENTS
thisform.oantView.object.NavigateWithWebResourceRequest(lcURL1,'GET','','')
DOEVENTS

&& this part is in the onDownloadStarting event, see also: https://doc.antwise.com/antview2/hs117.htm

LPARAMETERS cancel, handled, downloadoperation, resultpath, resultfilename
LOCAL lcURL2

handled = .T.
resultpath = 'C:\exe\'
resultfilename = downloadFileName
downloadItem = downloadItem + 1


IF downloadItem = 2 THEN
      lcURL2 = 'https://antwise.com/download/mfc42u.zip'
      downloadFileName = 'testURL2.zip'
thisform.oantView.object.NavigateWithWebResourceRequest(lcURL2,'GET','','')
ENDIF

DOEVENTS && Required for external COM events!

For testing this you need to have a folder: C:\exe
It will download 2 files to the C:\exe folder and it does this silently, so it might look like that nothing is happening!

It uses the predetermined filenames "testURL1.zip" and "testURL2.zip".

Hope this helps,
--
Wil
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)