
FRAGE:

Gibt es die Möglichkeit in Gambas direkt (!) zu ergründen, ob ein bestimmtes Programm auf dem System installiert ist - und bei negativem Ergebnis die Installation anschiebt? Ich glaube da gibt es Neuigkeiten - finde aber nichts. Ein Gambas-Schnipsel wäre schön.


ANTWORT:

Seit Gambas 3.6 gibt es in der System-Klasse (gb) die beiden Methoden 

(a) System.Exist(sPrg)
(b) System.Find(sPrg). 

Erstere gibt zurueck, ob ein Programm sPrg (z.B. sPrg = "svn") in den Pfaden in der PATH-Umgebungsvariable gefunden werden kann. 
Letztere gibt den absoluten Pfad zum gefundenen Programm zurueck (oder Null, wenn es nicht gefunden wurde).

Ich würde auch ein Programm nur dann als "installiert" bezeichnen, wenn man es über PATH finden kann. Das sollten wir an entsprechender Stelle so definieren. Sonst kommt einer daher und sagt: "Ich habe doch aber Programm xy in $HOME/meineprogramme/findestmichnicht/ installiert. Warum kann euer Programm das nicht finden?".

Zum zweiten Teil: 
Die Installation müsste man wirklich einem externen Programm (nämlich dem jeweiligen Paket-Manager auf dem System) überlassen und gesondert initiieren.


..............................




hans@linux:~$ whereis linphone
linphone: /usr/bin/linphone /usr/bin/X11/linphone /usr/share/linphone /usr/share/man/man1/linphone.1.gz
hans@linux:~$ whereis -b linphone
linphone: /usr/bin/linphone /usr/bin/X11/linphone /usr/share/linphone
hans@linux:~$ which linphone
/usr/bin/linphone
hans@linux:~$ 


hans@linux:~$ whereis gambas3
gambas3: /usr/bin/gambas3 /usr/bin/gambas3.gambas /usr/lib/gambas3 /usr/bin/X11/gambas3 /usr/bin/X11/gambas3.gambas /usr/share/gambas3 /usr/share/man/man1/gambas3.1.gz
hans@linux:~$ whereis -b gambas3
gambas3: /usr/bin/gambas3 /usr/bin/gambas3.gambas /usr/lib/gambas3 /usr/bin/X11/gambas3 /usr/bin/X11/gambas3.gambas /usr/share/gambas3
hans@linux:~$ which gambas3
/usr/bin/gambas3
hans@linux:~$ 




Hinweise:
-----------------------------------------------------------------------------------------------------------------------

System.Find (gb)
Since 3.6

Static Function Find ( Program As String ) As String

Search for a specific program through the PATH environment variable, and return its ***full path***.

If you use the EXEC command with an absolute path, the PATH is not searched, and so the program startup is faster.




System.Exist (gb)
Since 3.6

Static Function Exist ( Program As String ) As Boolean
Return if a specific program is available or not.

The program is searched through the *PATH environment* variable.

