PDA

Click to See Complete Forum and Search --> : Saving files of whatever I want,...


PunK
Jan 8th, 2001, 06:18 PM
How do I save files of my OWN?

I.E: Saving a file that ONLY runs in my prog...

plenderj
Jan 9th, 2001, 10:00 AM
Well,

You can save the file in your own proprietary format, with your own file extension.

- jamie

KingDavid
Jan 12th, 2001, 10:30 PM
from http://www.msdn.microsoft.com/




Close Statement
See Also Example Specifics

Concludes input/output (I/O) to a file opened using the Open statement.

Syntax

Close [filenumberlist]

The optional filenumberlist argument can be one or more file numbers using the following syntax, where filenumber is any valid file number:

[[#]filenumber] [, [#]filenumber] . . .

Remarks

If you omit filenumberlist, all active files opened by the Open statement are closed.

When you close files that were opened for Output or Append, the final buffer of output is written to the operating system buffer for that file. All buffer space associated with the closed file is released.

When the Close statement is executed, the association of a file with its file number ends.
============================================================
Open Statement
See Also Example Specifics

Enables input/output (I/O) to a file.

Syntax

Open pathname For mode [Access access] [lock] As [#]filenumber [Len=reclength]

The Open statement syntax has these parts:

Part Description
pathname Required. String expression that specifies a file name — may include directory or folder, and drive.
mode Required. Keyword specifying the file mode: Append, Binary, Input, Output, or Random. If unspecified, the file is opened for Random access.
access Optional. Keyword specifying the operations permitted on the open file: Read, Write, or Read Write.
lock Optional. Keyword specifying the operations restricted on the open file by other processes: Shared, Lock Read, Lock Write, and Lock Read Write.
filenumber Required. A valid file number in the range 1 to 511, inclusive. Use the FreeFile function to obtain the next available file number.
reclength Optional. Number less than or equal to 32,767 (bytes). For files opened for random access, this value is the record length. For sequential files, this value is the number of characters buffered.


Remarks

You must open a file before any I/O operation can be performed on it. Open allocates a buffer for I/O to the file and determines the mode of access to use with the buffer.

If the file specified by pathname doesn't exist, it is created when a file is opened for Append, Binary, Output, or Random modes.

If the file is already opened by another process and the specified type of access is not allowed, the Open operation fails and an error occurs.

The Len clause is ignored if mode is Binary.

Important In Binary, Input, and Random modes, you can open a file using a different file number without first closing the file. In Append and Output modes, you must close a file before opening it with a different file number.

===========================================================

Write # Statement
See Also Example Specifics

Writes data to a sequential file.

Syntax

Write #filenumber, [outputlist]

The Write # statement syntax has these parts:

Part Description
filenumber Required. Any valid file number.
outputlist Optional. One or more comma-delimited numeric expressions or string expressions to write to a file.


Remarks

Data written with Write # is usually read from a file with Input #.

If you omit outputlist and include a comma after filenumber, a blank line is printed to the file. Multiple expressions can be separated with a space, a semicolon, or a comma. A space has the same effect as a semicolon.

When Write # is used to write data to a file, several universal assumptions are followed so the data can always be read and correctly interpreted using Input #, regardless of locale:

Numeric data is always written using the period as the decimal separator.


For Boolean data, either #TRUE# or #FALSE# is printed. The True and False keywords are not translated, regardless of locale.


Date data is written to the file using the universal date format. When either the date or the time component is missing or zero, only the part provided gets written to the file.


Nothing is written to the file if outputlist data is Empty. However, for Null data, #NULL# is written.


If outputlist data is Null data, #NULL# is written to the file.


For Error data, the output appears as #ERROR errorcode#. The Error keyword is not translated, regardless of locale.
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. Write # inserts a newline character, that is, a carriage return–linefeed (Chr(13) + Chr(10)), after it has written the final character in outputlist to the file.

Note You should not write strings that contain embedded quotation marks, for example, "1,2""X" for use with the Input # statement: Input # parses this string as two complete and separate strings.

==========================================================
Input # Statement
See Also Example Specifics

Reads data from an open sequential file and assigns the data to variables.

Syntax

Input #filenumber, varlist

The Input # statement syntax has these parts:

Part Description
filenumber Required. Any valid file number.
varlist Required. Comma-delimited list of variables that are assigned values read from the file — can't be an array or object variable. However, variables that describe an element of an array or user-defined type may be used.


Remarks

Data read with Input # is usually written to a file with Write #. Use this statement only with files opened in Input or Binary mode.

When read, standard string or numeric data is assigned to variables without modification. The following table illustrates how other input data is treated:

Data Value assigned to variable
Delimiting comma or blank line Empty
#NULL# Null
#TRUE# or #FALSE# True or False
#yyyy-mm-dd hh:mm:ss# The date and/or time represented by the expression
#ERROR errornumber# errornumber (variable is a Variant tagged as an error)


Double quotation marks (" ") within input data are ignored.

Note You should not write strings that contain embedded quotation marks, for example, "1,2""X" for use with the Input # statement: Input # parses this string as two complete and separate strings.

Data items in a file must appear in the same order as the variables in varlist and match variables of the same data type. If a variable is numeric and the data is not numeric, a value of zero is assigned to the variable.

If you reach the end of the file while you are inputting a data item, the input is terminated and an error occurs.

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.
===========================================================
Print # Statement
See Also Example Specifics

Writes display-formatted data to a sequential file.

Syntax

Print #filenumber, [outputlist]

The Print # statement syntax has these parts:

Part Description
filenumber Required. Any valid file number.
outputlist Optional. Expression or list of expressions to print.


Settings

The outputlist argument settings are:

[{Spc(n) | Tab[(n)]}] [expression] [charpos]

Setting Description
Spc(n) Used to insert space characters in the output, where n is the number of space characters to insert.
Tab(n) Used to position the insertion point to an absolute column number, where n is the column number. Use Tab with no argument to position the insertion point at the beginning of the next print zone.
expression Numeric expressions or string expressions to print.
charpos Specifies the insertion point for the next character. Use a semicolon to position the insertion point immediately after the last character displayed. Use Tab(n) to position the insertion point to an absolute column number. Use Tab with no argument to position the insertion point at the beginning of the next print zone. If charpos is omitted, the next character is printed on the next line.


Remarks

Data written with Print # is usually read from a file with Line Input # or Input.

If you omit outputlist and include only a list separator after filenumber, a blank line is printed to the file. Multiple expressions can be separated with either a space or a semicolon. A space has the same effect as a semicolon.

For Boolean data, either True or False is printed. The True and False keywords are not translated, regardless of the locale.

Date data is written to the file using the standard short date format recognized by your system. When either the date or the time component is missing or zero, only the part provided gets written to the file.

Nothing is written to the file if outputlist data is Empty. However, if outputlist data is Null, Null is written to the file.

For Error data, the output appears as Error errorcode. The Error keyword is not translated regardless of the locale.

All data written to the file using Print # is internationally aware; that is, the data is properly formatted using the appropriate decimal separator.

Because Print # writes an image of the data to the file, you must delimit the data so it prints correctly. If you use Tab with no arguments to move the print position to the next print zone, Print # also writes the spaces between print fields to the file.

Note If, at some future time, you want to read the data from a file using the Input # statement, use the Write # statement instead of the Print # statement to write the data to the file. Using Write # ensures the integrity of each separate data field by properly delimiting it, so it can be read back in using Input #. Using Write # also ensures it can be correctly read in any locale.

===================================================
© 2000 Microsoft Corporation. All rights reserved