[jawsscripts] Re: Piping a string variable to a txt file as part of a script

  • From: Soronel Haetir <soronel.haetir@xxxxxxxxx>
  • To: jawsscripts@xxxxxxxxxxxxx
  • Date: Tue, 19 Jan 2010 06:26:28 -0900

Oh man, jaws scripting is automation aware?  I hadn't realized that.
That opens so many possibilities.  I had thought the object type was
just another opaque value type.  I don't think either of FSDN or the
basics of scripting manual mention that it can actually make calls to
automation objects.

Although that does make me wonder why they bothered writing their own
script language rather than re-using windows script host.  Oh well,
probably a historical decision and next to impossible to change now.

On 1/19/10, Paul Magill <magills@xxxxxxxxxxx> wrote:
> Hi Logan,
>
> - this is not as straight forward as it might seem.  There are no FS built
> in functions that write to text type files other than the INI functions,
> such as IniWriteString etc.
>
> These do not provide for appending, other than creating additional keys etc.
>
> Fortunately, especially for me, Jamal Masrui provided to the list, a set of
> functions that do that task very well.
>
> Below are those functions, only slightly modified to suit my needs.
>
> * The last one is what you are looking for.  It, and the other 2 file
> accessing functions need the first function. I included the other 2 as you
> may need them at some time.
>
> Note 1: The read function reads the entire file into a string variable, &
> the Write function writes a file which will contain only the contents of the
> string variable passed to it.  i e. anything already in the file will be
> overwritten. The append function adds to any text already in the file, but
> the file must already exist.
> Note 2: you need to look after any linebreaks that you may need, as none are
> provided by the functions. - this is very useful in most situations
>
>
> Object Function ObjectCreate (string S_Object)
>
> Var
>
> Object o_return
>
> Let o_return =CreateObjectEx (s_object, True)
>
> ;SayString ("first")
>
> If !o_return Then
>
> Let o_return =CreateObjectEx(s_object, False)
>
> ;SayString ("second")
>
> EndIf
>
> If !o_return Then
>
> Let o_return =GetObject(s_object)
>
> ;SayString ("third")
>
> EndIf
>
> Return o_return
>
> EndFunction
>
>
>
> String Function ReadStringFromFile (string S_File)
>
> Var
>
> Object Null,
>
> Object o_system,
>
> Object o_file,
>
> String s_return
>
> Let o_system =ObjectCreate("Scripting.FilesystemObject")
>
> Let o_file =o_system.OpenTextFile(s_file, 1, 0)
>
> Let s_return =o_file.ReadAll()
>
> o_file.close()
>
> Let o_file =Null
>
> Let o_system =Null
>
> Return s_return
>
> EndFunction
>
>
>
> Int Function WriteFileFromString (string S_Text, string S_File)
>
> Var
>
> Object Null,
>
> Object o_system,
>
> Object o_file
>
> Let o_system =ObjectCreate("Scripting.FilesystemObject")
>
> Let o_file =o_system.CreateTextFile(s_file, 1, 0)
>
> o_file.write(s_text)
>
> o_file.close()
>
> Let o_file =Null
>
> Let o_system =Null
>
> EndFunction
>
>
>
>
>
> Int Function AppendStringToFile (string S_Text, string S_File)
>
> ; *** this function *ONLY* appends to already existing files. use
> WriteFileFromString to create the file
>
> ; each append adds to the previous record without line breaks etc
>
> Var
>
> Object Null,
>
> Object o_system,
>
> Object o_file
>
> Let o_system =ObjectCreate("Scripting.FilesystemObject")
>
> Let o_file =o_system.OpenTextFile (s_file, 8, 0)
>
> o_file.write (s_text)
>
> o_file.close()
>
> Let o_file =Null
>
> Let o_system =Null
>
> EndFunction
>
>
>
>
> ----- Original Message -----
> From: "Logan McMullen" <loganmcmullen@xxxxxxxxxxxxxxx>
>
>
> Hi everyone,
>
> I'd like to use an input box to get some content from a user and to then
> have the variable that is returned by the box save/piped to a txt file that
> the script also creates.
>
> The process would go like this(** note keystrokes are not what I'm using in
> the actual script)
>
> 1. User hits ctrl+p and gets presented  with the  input box
> 1(a) A text file with a filename  of the current system time is created.
> 2. User inputs  content(text) in the box and hits enter(string variable is
> then created by the input box
> 3.  String variable is appended to a txt file that has been created.
>
> I have the time variable already sorted and could use a batch file to create
> the txt file  but would rather use all script functions to achieve this if
> possible to remove the need for the batch file to be on the users machine.
>
> Thoughts appreciated.
>
> Logan.
>
> __________
> Visit and contribute to The JAWS Script Repository http://jawsscripts.com
>
> View the list's information and change your settings at
> http://www.freelists.org/list/jawsscripts
>
>


-- 
Soronel Haetir
soronel.haetir@xxxxxxxxx
__________ 
Visit and contribute to The JAWS Script Repository http://jawsscripts.com

View the list's information and change your settings at 
http://www.freelists.org/list/jawsscripts

Other related posts: