[Gambas-devel] Gambas 1.9.46 Help

Fabien Bodard gambas.fr at ...176...
Tue Nov 14 22:35:58 CET 2006


this is the corrected Functions.

There were three errors
First one is the env variable name (it miss _DESKTOP_)
Second one: ubuntu and some other distrib not have epiphany so i've added
firefox in second case in the gnomedesktop select.

Third one was That the which program don't return anything when the required
program not exist in debian like distribs.

I've done some cleaning on the data receipt (use of the TO key with SHELL


PUBLIC FUNCTION CheckProgram(sProg AS String) AS Boolean

  DIM bError AS Boolean
  DIM iPos AS Integer
  DIM sVal AS String

  iPos = InStr(sProg, " ")
  IF iPos THEN sProg = Left(sProg, iPos - 1)

  SHELL "which " & sProg TO sVal

  bError = sVal LIKE "which: *" OR IsNull(sVal)

  RETURN bError

END


PUBLIC SUB OpenWebPage(sLink AS String)

  DIM sExec AS String
  DIM aTest AS String[]
  DIM bCheck AS Boolean

  IF NOT Browser THEN

    SELECT CASE Settings["/Browser"]

      CASE "konqueror"
        aTest = ["konqueror"]

      CASE "epiphany"
        aTest = ["epiphany"]

      CASE "firefox"
        aTest = ["firefox", "mozilla-firefox"]

      CASE "seamonkey"
        aTest = ["seamonkey"]

      CASE ELSE

        aTest = [Application.Env["BROWSER"]]

        IF Application.Env["KDE_FULL_SESSION"] THEN
          aTest.Add("konqueror")
        ELSE IF Application.Env["GNOME_DESKTOP_SESSION_ID"] THEN
          aTest.Add("epiphany")
          aTest.Add("firefox")
        ENDIF

    END SELECT

    aTest.Add("konqueror")
    aTest.Add("mozilla-firefox")
    aTest.Add("firefox")
    aTest.Add("mozilla")
    aTest.Add("seamonkey")
    aTest.Add("opera")

    FOR EACH sExec IN aTest
      bCheck = NOT CheckProgram(sExec)
      IF bCheck THEN BREAK
    NEXT

    IF NOT bCheck THEN RETURN

    Browser = sExec

  ENDIF

  IF Left(sLink) = "/" THEN
    sLink = "file://" & Replace(sLink, "?", "%3F")
  ENDIF

  SHELL Browser & " " & Chr$(34) & sLink & Chr$(34)

CATCH

  Message.Error(Error.Text)

END

Regards,

Fabien Bodard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/devel/attachments/20061114/0f75dc23/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Project.module
Type: application/octet-stream
Size: 67513 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/devel/attachments/20061114/0f75dc23/attachment.obj>


More information about the Devel mailing list