New topic: 

Create File Text in Console Application

<http://forums.realsoftware.com/viewtopic.php?t=46975>

         Page 1 of 1
   [ 5 posts ]                 Previous topic | Next topic          Author  
Message        fernandopm          Post subject: Create File Text in Console 
ApplicationPosted: Sat Feb 16, 2013 9:06 pm                         
Joined: Sat Jun 11, 2011 8:46 pm
Posts: 20                is the code example  work in option create project 
DESKTOP, but in CONSOLE Application NOT

  Dim f as FolderItem = GetSaveFolderItem("text/plain","CreateExample.txt")
  Dim linea1 as string
  
 linea1 = "PRUEBA"
  
  If f <> Nil then
  Try
  Dim t as TextOutputStream = TextOutputStream.Create(f)
  Try
    t.WriteLine(linea1)
  Finally
    t.Close
    t = nil
  End Try
  Catch e as IOException
  //handle error
  End Try
  End if

what is error? or GetSaveFolderItem no compatible with CONSOLA APPLICATION?   
                             Top                DaveS          Post subject: 
Re: Create File Text in Console ApplicationPosted: Sat Feb 16, 2013 9:13 pm     
                            
Joined: Sun Aug 05, 2007 10:46 am
Posts: 4562
Location: San Diego, CA                because GETSAVEFOLDER is a GUI Dialog 
box... something that by definition a CONSOLE app doesn't have (ie a GUI)      
_________________
Dave Sisemore
MacPro, OSX Lion 10.7.4 RB2012r1
Note : I am not  interested in any solutions that involve custom Plug-ins of 
any kind  
                             Top                fernandopm          Post 
subject: Re: Create File Text in Console ApplicationPosted: Sat Feb 16, 2013 
9:19 pm                         
Joined: Sat Jun 11, 2011 8:46 pm
Posts: 20                DaveS wrote:because GETSAVEFOLDER is a GUI Dialog 
box... something that by definition a CONSOLE app doesn't have (ie a GUI)

ok, GETSAVEFOLDER for Desktop, and Console what's commands?   
                             Top                DaveS          Post subject: 
Re: Create File Text in Console ApplicationPosted: Sat Feb 16, 2013 9:27 pm     
                            
Joined: Sun Aug 05, 2007 10:46 am
Posts: 4562
Location: San Diego, CA                Input
Method
Retrieves a line from the terminal in console applications.
Syntax
result=Input
Part
Type
Description
result
String The line retrieved from the terminal. Input does not return the Newline 
character as part of result.
Example

 Dim s as string
 .
 .
 s=Input
Notes
Input is equivalent to a call to the ReadLine method of the StandardInputStream 
class.      
_________________
Dave Sisemore
MacPro, OSX Lion 10.7.4 RB2012r1
Note : I am not  interested in any solutions that involve custom Plug-ins of 
any kind  
                             Top                charonn0          Post subject: 
Re: Create File Text in Console ApplicationPosted: Sat Feb 16, 2013 9:39 pm     
                            
Joined: Mon Apr 02, 2007 2:08 am
Posts: 1126
Location: San Francisco, CA, USA                In a console application your 
main inputs are the command line arguments passed into the App.Run event. The 
arguments are passed as an array of strings containing the entire commandline 
of your app, including the absolute path to the executable file as the first 
item in the array. Anything passed as arguments on the command line will appear 
at the second, third, etc. position in the array.

To set the command line that will be given to your app under the debugger, use 
the App.CommandLine property on the project tab.

To pass a file path to create, you might use a command line like this:
/path/to/target file.txt

In the App.Run event, the args() parameter would contain:

args(0) = "/path/to/your/app.exe"
args(1) = "/path/to/target file.txt"


So you could get a folderitem to the passed filepath by using GetFolderItem:
If args.Ubound >= 1 Then
  Dim f as FolderItem = GetFolderItem(args(1), FolderItem.PathTypeAbsolute)
  Dim linea1 as string
  
  linea1 = "PRUEBA"
  
  'etc...
Else
  Print("Not enough arguments.")
End If
      
_________________
Boredom Software  
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 5 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to