[Solved] Open with default text editor

Post Reply
User avatar
Philippe734
Posts: 15
Joined: Sunday 16th February 2020 7:37pm
Contact:

[Solved] Open with default text editor

Post by Philippe734 » Tuesday 24th March 2020 1:10pm

Hello,
In my app, I wish to open a text file with the default text editor of the system. Please, how to do ? I know with bash, but is there a native Gambas command ?

Code: Select all

xdg-open myfile.txt
Last edited by Philippe734 on Tuesday 24th March 2020 3:18pm, edited 1 time in total.
Linux & Android enthusiast - France

User avatar
stevedee
Posts: 203
Joined: Monday 20th March 2017 6:06pm

Re: Open with default text editor

Post by stevedee » Tuesday 24th March 2020 2:59pm

Philippe734 wrote:
Tuesday 24th March 2020 1:10pm
In my app, I wish to open a text file...
As an alternative, take a look at "TextEditor" in the component: gb.form.editor

User avatar
Philippe734
Posts: 15
Joined: Sunday 16th February 2020 7:37pm
Contact:

Re: Open with default text editor

Post by Philippe734 » Tuesday 24th March 2020 3:18pm

  Shell "xdg-open PathToMyFile.txt"
Or
  EXEC ["xdg-open", "PathToMyFile.txt"]
Linux & Android enthusiast - France

vuott
Posts: 28
Joined: Wednesday 05th April 2017 6:07pm

Re: [Solved] Open with default text editor

Post by vuott » Tuesday 24th March 2020 6:17pm

...but if you are writing a graphic program, you can activate "gb.desktop" Component and then use "Desktop" Class:
Public Sub Button1_Click()

  Desktop.Open("/path/to/myFile.txt")

End
or by using "DesktopFile" Class of "gb.desktop" Component:
https://www.gambas-it.org/wiki/index.ph ... _associato

User avatar
Quincunxian
Posts: 71
Joined: Sunday 25th June 2017 12:14am
Location: Western Australia

Re: [Solved] Open with default text editor

Post by Quincunxian » Tuesday 24th March 2020 10:42pm

if you want more than just a simple text document, you can also use Libre Office to open documents if you have it installed
Either method works:
EXEC["libreoffice","--writer example.txt"]
Command line applications for the various formats of Libre Office.
LibreOffice is shortened to lo with the addition of the various document type.
  • lobase
  • localc
  • lodraw
  • lofromtemplate
  • loimpress
  • lomath
  • loweb
  • lowriter
EXEC["localc","example.csv"]
Full command line list can be found here.
Cheers - Quin.
I code therefore I am

Post Reply