[Solved] Open with default text editor

Post

Posted
Rating:
#1 (In Topic #388)
Avatar
Regular
Philippe734 is in the usergroup ‘Regular’
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

xdg-open myfile.txt

 Linux & Android enthusiast - France
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Regular
stevedee is in the usergroup ‘Regular’

Philippe734 said

In my app, I wish to open a text file…

As an alternative, take a look at "TextEditor" in the component: gb.form.editor
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Regular
Philippe734 is in the usergroup ‘Regular’

Code (gambas)

  1.   Shell "xdg-open PathToMyFile.txt"
Or

Code (gambas)

  1.   EXEC ["xdg-open", "PathToMyFile.txt"]

 Linux & Android enthusiast - France
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
vuott is in the usergroup ‘Regular’
…but if you are writing a graphic program, you can activate "gb.desktop" Component and then use "Desktop" Class:

Code (gambas)

  1. Public Sub Button1_Click()
  2.  
  3.   Desktop.Open("/path/to/myFile.txt")
  4.  

or by using "DesktopFile" Class of "gb.desktop" Component:
   Aprire un file mediante la Classe 'DesktopFile' con il programma al quale è associato - Gambas-it.org - Wikipedia

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Expert
Quincunxian is in the usergroup ‘Expert’
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:

Code (gambas)

  1. 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.
<LIST>
  • <LI>lobase</LI>
</LIST>
<LIST>
  • <LI>localc</LI>
</LIST>
<LIST>
  • <LI>lodraw</LI>
</LIST>
<LIST>
  • <LI>lofromtemplate</LI>
</LIST>
<LIST>
  • <LI>loimpress</LI>
</LIST>
<LIST>
  • <LI>lomath</LI>
</LIST>
<LIST>
  • <LI>loweb</LI>
</LIST>
<LIST>
  • <LI>lowriter</LI>
</LIST>

Code (gambas)

  1. EXEC["localc","example.csv"]

Full command line list can be found here.

Cheers - Quin.
I code therefore I am
Online now: No Back to the top
1 guest and 0 members have just viewed this.