User Tools

Site Tools


k15:k15.1:k15.1.5:start

15.1.5 Method Desktop.Open() - Class Desktop (gb. desktop)

Using this method enables you to open either a file or a URL in your preferred application:

Static Sub Open ( URL As String [ , Wait As Boolean ] )

This method supports URLs for the protocols: file, ftp, http and https. The specification of 'file://' is optional. It is not recommended to use the method as root!

When a file is hosted, the file opens in the preferred application for files of this type:

[1] Public Sub btnDesktopOpenFile_Click()
[2] 
[3]   Desktop.Open("file://" & User.Home &/ "apache_start.sh")  ' Editor gedit
[4] 
[5] ' Desktop.Open("file://" & User.Home &/ "Buchprojekt/Kapitel14/k14.23_MausRad.odt") ' → OpenLibre
[6] ' Desktop.Open(User.Home &/ "WebSite/CC/c.php")  ' → BlueFish (PHP-Counter) o.k.
[7] 
[8] End ' btnDesktopOpenFile_Click()

On the other hand, if a URL is provided for the protocols ftp, http or https, the URL is opened in the user's preferred Web browser.

Example 1

[1] Public Sub btnDesktopOpenURL1_Click()
[2]   
[3]   Desktop.Open("https://alfahosting.de/kunden/index.php/Benutzer:Login") ' o.k.
[4] 
[5] ' Desktop.Open("http://gambas-buch.de")               ' o.k.
[6] ' Desktop.Open("http://www.gambas-buch.de")           ' o.k.
[7] ' Desktop.Open("http://127.0.0.1/~hans/dw/doku.php")  ' lokale URI o.k.
[8]  
[9] End

Example 2

[1] Public Sub btnDesktopOpenURL2_Click()
[2]   Desktop.Open("ftp://ftp.fh-hannover.de/pub/dos/tcpip")
[3] End ' btnDesktopOpenURL2_Click()

The protocol must be explicitly specified, otherwise an error message will appear in the console of the IDE - as with the following two (faulty) calls:

(A)	Desktop.Open("gambas-buch.de")\\ 
(B)	Desktop.Open("www.gambas-buch.de")  

The error message in the console of the IDE for calling (A) - in case (B) it looks similar - is understandable. Since no allowed protocol (ftp, http or https) has been specified, the type 'file' is obviously assumed automatically:

gvfs-open: file:///home/hans/gambas-buch.de: Error opening the location: 
Error when retrieving the information for file "/home/hans/gambas-buch.de": File or directory not found

In practice, you do not see this error message. Since the error is intercepted internally, nothing else happens - in the true sense of the word.

The following call in a console obviously shows the error for case (B):

hans@linux:~$ gbx3 /home/hans/DesktopOpen
gvfs-open: file:///home/hans/www.gambas-buch.de: Error opening the location: 
Error when retrieving the information for file "/home/hans/gambas-buch.de": File or directory not found
hans@linux:~$ 

Download

The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k15/k15.1/k15.1.5/start.txt · Last modified: 28.09.2023 by emma

Page Tools