Mike, It looks like using single quotes works. ts.Write ( line3a + '"' + line3b + '" ' + line3c );
In any case, would appreciate feedback on using function, var, writeline, write and overall approach to creating a text file as I plan to expand on this for some AmiBroker work. Thanks. --- In [email protected], "bistrader" <bistra...@...> wrote: > > Mike, > I am having problems creating a txt file via JavaScript for AmiBroker use so > I create the following simple example. I want the txt file to be exactly the > following, but can not get the quotes to be included. > > I pick x of y for today. > This is my final pick. > These are "My Winners" for the day. > > Here, x and y are variables and My Winners is in quotes. > > Plus, I want to expand on this so would appreciate feedback on whether my > approach to using a function, var, writeline and write, etc is a good way to > approach writing what is needed to a file. > > Here is my example code and thanks > ************************** > > // Attempt to do the following. > // 1. Set x to 5 and y to 8 for a function > // 2. Create a file to write to called myoutput.txt > // 3. Write the following to this file, where x is set to 5, y to 8. > // I pick x of y for today. > // This is my final pick. > // These are "My Winners" for the day. > > // I am having problems writing My Winners in quotes. > > // > ---------------------------------------------------------------------------- > // Create AmiBroker object and get Analysis object > // > ---------------------------------------------------------------------------- > var AB, AA; > > AB = new ActiveXObject("Broker.Application"); > AA = AB.Analysis; > > // > ---------------------------------------------------------------------------- > // Set x = 5 and y = 8 for function > // > ---------------------------------------------------------------------------- > var x = 5; > var y = 8; > > WLEmpty_Directory = "C:\\Amibroker\\Temp\\"; > WLEmpty_ExploreFileName = "myoutput.txt"; > WLEmpty_ExploreFile = WLEmpty_Directory + WLEmpty_ExploreFileName; > > VarAndQuotes.call(x,y); > > AA.ShowWindow(0); > > // > ---------------------------------------------------------------------------- > // Function to create an txt where x and y change and with > // some of the text in quotes > // > ---------------------------------------------------------------------------- > function VarAndQuotes(x1,y1) > { > var fso, f, ts; > var x1, y1; > var ForReading = 1, ForWriting = 2, ForAppending = 8; > var TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0; > > var line1a = "I pick ";// need to place 'x' after this > var line1b = " of ";// need to place 'y' after this. > var line1c = " for today."; > var line2 = "This is my final pick."; > var line3a = "These are "; > var line3b = "My Winners";// need to somehow place in double quotes > var line3c = "for the day.";// no carrage return after. > > fso = new ActiveXObject("Scripting.FileSystemObject"); > fso.CreateTextFile( WLEmpty_ExploreFile ); > f = fso.GetFile(WLEmpty_ExploreFile); > ts = f.OpenAsTextStream(ForWriting, TristateUseDefault); > > ts.WriteLine ( line1a + x + line1b + y + line1c ); > ts.WriteLine ( line2 ); > ts.Write ( line3a + " + line3b + " + line3c );// DOES NOT WORK > ts.Close( ); > AB.RefreshAll(); > } > > > > // Thanks for the help! > > // Bert >
