Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can i link or access a file present

Status
Not open for further replies.

tanveerhabib

Programmer
Dec 8, 2015
27
PK
can i link or access a file present at some website like suppose abc.com/file.txt ??? if yes how can i do it in VFP
 
You cannot directly link to or directly access the remote file.

But you can download a remote file (FTP, HTTP GET, etc.), use it in some manner and then, if needed, upload it back to the remote site.

Or, depending on how the remote website presents the file contents, you could 'read' a website page that was displaying the file contents.
Then after 'reading' the page, you could work on its contents.

Good Luck,
JRB-Bldr
 
There are several ways of doing this. One option is to use the Internet Trasfer Control, which is one of the ActiveX controls that comes with VFP:

Code:
lox = CREATEOBJECT("InetCtls.Inet.1")
lcPage = lox.OpenURL("[URL unfurl="true"]http://www.example.com/index.htm")[/URL]
  && lcPage will now contain the contents of the specified file

Be sure to pass the complete URL to the OpenURL method, including the protocol (" in this example) and the filename ("index.htm" in this example).

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hello @MikeLewis i just want to link a file present at don't want to read any thing present in its content so that is my actual question thanks and waiting for your reply dear.
 
Do you mean providing a hyperlink to a URL? That depends on where you want the hyperlink to appear and then would open up the question of what should happen when clicking that hyperlink.

The simplest way to provide hyperlinked texts is to embed a webbrowser control and let it display a html page. It'll work like a browser also in regard of displaying file.txt when the link to it is clicked.

You have the capability to show hyperlinks in source code with editor options (_VFP.Editoroptions), but besides code editors this only applies to memos and so doesn't affect text with URLs displayed in edit boxes or text boxes, they are not "Editors".

You have the ffc hyperlink classes, see hyperlink button/image/label foundation classes, these are separate and not embedded in text paragraphs like eg mail bodies.

Bye, Olaf.
 
I just want to link a file present at don't want to read any thing present

It is not clear what you mean by "linking to a file".

If you want to display a hyperlink in your VFP form, start by dropping a label on the form; set its caption to any suitable text, set its Forecolor to blue, set its MousePointer to 15, and set its FontUnderline to .T. That will give you a label that looks like a hyperlink.

So the next question is: what do you want to happen when the user clicks on it? If you want to open the relevant page in a web browser, then you can use ShellExecute(), passing the URL as a parameter:

Code:
DECLARE INTEGER ShellExecute IN shell32.dll ; 
  INTEGER hndWin, ; 
  STRING cAction, ; 
  STRING cFileName, ; 
  STRING cParams, ;  
  STRING cDir, ; 
  INTEGER nShowWin
    && you only need to execute above command once per session

cFileName = "[URL unfurl="true"]http://abc.com/file.txt"[/URL]
cAction = "open"
ShellExecute(0,cAction,cFileName,"","",1)

You would put the above code in the Click event of the label.

But if you want to diplay the contents of the page in your own form, then you will have to retrieve the file (as in my first post), and display that in a suitable control. What control you use depends on the nature of the file (text, image, or whatever).

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top