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:~$
Der Einsatz dieser Methode versetzt Sie in die Lage entweder eine Datei oder eine URL in der von Ihnen bevorzugten Anwendung zu öffnen:
Static Sub Open ( URL As String [ , Wait As Boolean ] )
Diese Methode unterstützt URLs für die Protokolle: file, ftp, http und https. Die Angabe von 'file://' ist optional. Es wird nicht empfohlen, die Methode als Root zu benutzen.
Wenn eine Datei bereitgestellt wird, wird die Datei in der bevorzugten Anwendung für Dateien dieses Typs geöffnet:
[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()
Wird dagegen eine URL für die Protokolle ftp, http oder https zur Verfügung gestellt, dann wird die URL in dem vom Benutzer bevorzugten Web-Browser geöffnet.
Beispiel 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 ' btnDesktopOpenURL1_Click()
Beispiel 2
[1] Public Sub btnDesktopOpenURL2_Click() [2] Desktop.Open("ftp://ftp.fh-hannover.de/pub/dos/tcpip") [3] End ' btnDesktopOpenURL2_Click()
Das Protokoll muss explizit angegeben werden, weil sonst eine Fehlermeldung in der Konsole der IDE erscheint – wie bei den beiden folgenden (fehlerhaften) Aufrufen:
(A) Desktop.Open("gambas-buch.de")\\ (B) Desktop.Open("www.gambas-buch.de")
Die Fehlermeldung in der Konsole der IDE für den Aufruf (A) – für den Fall (B) sieht sie ähnlich aus – ist verständlich. Da kein zulässiges Protokoll (ftp, http oder https) angegeben worden ist, wird offensichtlich automatisch der Typ 'file' angenommen:
gvfs-open: file:///home/hans/gambas-buch.de: Fehler beim Öffnen des Ortes: Fehler beim Holen der Informationen für Datei »/home/hans/gambas-buch.de«: Datei oder Verzeichnis nicht gefunden
In der Praxis sehen Sie diese o.a. Fehlermeldung nicht. Da der Fehler intern abgefangen wird, passiert nichts weiter – im wahren Sinne der Bedeutung.
Der folgende Aufruf in einer Konsole zeigt selbstverständlich den Fehler für den Fall (B):
hans@linux:~$ gbx3 /home/hans/DesktopOpen gvfs-open: file:///home/hans/www.gambas-buch.de: Fehler beim Öffnen des Ortes: Fehler beim Holen der Informationen für Datei »/home/hans/www.gambas-buch.de«: Datei oder Verzeichnis nicht gefunden hans@linux:~$