Re: Open, Close, & Freefile



LurfysMa wrote:
On Tue, 10 Jul 2007 15:30:47 +1000, "Michael C" <nospam@xxxxxxxxxx>
wrote:

"LurfysMa" <invalid@xxxxxxxxxxxxxxx> wrote in message news:i736931vqdsdfpa5ujbm3l2q3t9ovdoi6p@xxxxxxxxxx
Can someone please confirm that my understanding of the use of Open,
Close, & Freefile is correct?

....

3. The Print statement writes the data "as is", whereas the Write
statement adds characters such as quotes around string data.

Write #fnum, "This is some text..."
xx = "This is some text..."
Write #fnum, xx

VB writes out the quotes whether a literal or in a variable.
Not sure about this one but sounds correct. You'd need to try it.

I tried it and I eventually found it in the help. It does it so that
when you read it back it, it's a literal.

Don't know why it should have to have been "eventually", it's in the section describing the Write # Statement... :)

"Unlike the Print # statement, the Write # statement inserts commas between items and quotation marks around strings as they are written to the file. You don't have to put explicit delimiters in the list."

Earlier in the description it also says "Data written with Write # is usually read from a file with Input #." and under Input # one finds--
"Note To be able to correctly read data from a file into variables using Input #, use the Write # statement instead of the Print # statement to write the data to the files. Using Write # ensures each separate data field is properly delimited."


As a side note, the "#" on the file number is consistent w/ the history of BASIC and as someone else noted, is required to remove ambiguity in some circumstances. The use is, in general, good practice simply for consistency and ease of reading source later whether it can be dispensed with in a particular instance or not. That, of course, comes w/ the "imo, ymmv, $0.02, etc., ..." caveat. :)

It is imo on the same line as using the trailing "$" on string intrinsics to ensure the character version is returned as opposed to Variant when that is what is intended, etc., ...

--

--


.



Relevant Pages

  • Mandis Quotes (aka retiring """ and )
    ... arbitrary textual matter called "Mandis quotes". ... surround the string by a pair of doubled single quotes. ... of ASCII or Unicode characters, but instead as a sequence of lines ...
    (comp.lang.python)
  • Re: Commodore 128 Basic 7.0 One Liner Competition 2008
    ... the characters in the string and put them into memory. ... You could put a REM statement at the end of the line with a bunch ... of characters in quotes and have a SYS command at the beginning of the ...
    (comp.sys.cbm)
  • Re: list or not a list?
    ... grouping character of quotes inside a string, that is used as a list. ... I thought, that the blank-separated characters in the string, treated ... as list, will be recognized as list elements, but I can't really ...
    (comp.lang.tcl)
  • RE: Replacing "illegal characters" in html
    ... > in a string. ... > The characters I need to replace come from MS Word copy & ... > Double Right quotes ... and 2) regular expressions. ...
    (comp.lang.python)
  • Re: Error in reading large csv file
    ... The max size of each line is about 30 characters. ... Open file_name For Input As fnum ... If i = 25 Then Exit For 'Do ... with 6 fields separated with commas) using a string. ...
    (microsoft.public.vb.general.discussion)