Console App Opening a Text File

Hi everyone.

I curious if Xojo has a way that you can create a text file, append data to it, then open that text file all in a console application?

So far i have all the code to generate a text file with data in it, now im trying to open that file for verification that the data was inserted properly.

All of this is done on a Window’s machine but im willing to see the code for any operating system if it is Windows compatible.

Thanks should open the file with the default app for txt. Usually Notepad in Windows and TextEdit in OS X.

did you even attempt to look in the LangRef?

  dim f as FolderItem=SpecialFolder.Desktop.child("mytest.txt")
  dim txt_out as TextOutputStream
  txt_out.writeline "data"

i did and none of it is working for me. Again i want to point out that i am using a CONSOLE application and when i use the FolderItem.Launch i get the error message of: “Type FolderItem has no member named ‘Launch’”

As for if i looked into the LangRef, again, yes i did and yes the TextInput and Output streams work for reading in the data i want to physically open the text file for viewing. i want Xojo to use the computer’s default program to open a text file.

So in this instance i want my console application to write data to a txt document. then open that very txt document in NotePad.

Use shell

dim s as new shell s.execute('Open /Users/Mitch/Desktop/myTextFile.txt")

You must use the full path of myTextFile.

In Windows replace “Open” by “Start”

As noted in the LangRef, FolderItem.Launch is not available for Console apps. But Michel’s code above should work fine.

FUNCTION launch(extends f as folderitem)
  Dim cmd As String
  Dim sh As New shell
  #If TargetMacOS Then 
  #ElseIf TargetWindows Then
    Print "Launch feature not available for this OS"
  sh.Execute cmd+" "+f.shellpath

Only for CONSOLE apps…