[Solved] Open with default text editor

Post your Gambas programming questions here.
Post Reply
User avatar
Philippe734
Posts: 20
Joined: Sunday 16th February 2020 7:37pm
Contact:

[Solved] Open with default text editor

Post by Philippe734 »

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: 518
Joined: Monday 20th March 2017 6:06pm

Re: Open with default text editor

Post by stevedee »

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: 20
Joined: Sunday 16th February 2020 7:37pm
Contact:

Re: Open with default text editor

Post by Philippe734 »

  Shell "xdg-open PathToMyFile.txt"
Or
  EXEC ["xdg-open", "PathToMyFile.txt"]
Linux & Android enthusiast - France
vuott
Posts: 262
Joined: Wednesday 5th April 2017 6:07pm
Location: European Union

Re: [Solved] Open with default text editor

Post by vuott »

...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
Europaeus sum !

Amare memorentes atque deflentes ad mortem silenter labimur.
User avatar
Quincunxian
Posts: 171
Joined: Sunday 25th June 2017 12:14am
Location: Western Australia

Re: [Solved] Open with default text editor

Post by Quincunxian »

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