write an integer to a file - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Input and Output : File Manipulation : FileTools : FileTools/Text/WriteInteger

FileTools[Text][WriteInteger] - write an integer to a file

Calling Sequence

WriteInteger(file, integer, opt1, opt2, ...)

Parameters

file

-

file descriptor or filename

integer

-

integer to write to the file

opt1, opt2, ...

-

(optional) argument of the form, name or name=string where name is one of delim, leftdelim, or rightdelim

Description

• 

The WriteInteger(file, integer) command writes integer to the file specified by file.

• 

The WriteInteger function can place delimiters around integer while writing.  Without delimiters the characters of two consecutive calls to WriteInteger are continuous in the file and it is impossible to determine the correct location to separate the two integers. Delimiters can be added around the integer by specifying, delim, leftdelim, or rightdelim.

• 

The delim option adds delimiters on both sides of the integer. The delimiter can be specified by passing delim=string.  If a string is not specified, then the delimiter is a single space.

• 

The leftdelim option adds a delimiter before the integer. The rightdelim option adds a delimiter after the integer. The delimiter can be specified by passing leftdelim=string or rightdelim=string.  If a string is not specified then the delimiter is a single space. The leftdelim and rightdelim options can be used together to specify asymmetric delimiters.  If used in conjunction with delim, the delimiters specified by leftdelim or rightdelim take precedence.

• 

If file is the name of an open file, the file descriptor is obtained automatically.  If file is the name of a file that is not open, it is opened automatically.  If file is an invalid descriptor, an error is raised.

Examples

FileTools[Text]WriteIntegertestfile,1234

4

(1)

FileTools[Text]WriteCharactertestfile, :

FileTools[Text]WriteIntegertestfile,1213121

7

(2)

FileTools[Text]Closetestfile:

FileTools[Text]ReadIntegertestfile

1234

(3)

FileTools[Text]ReadIntegertestfile

1213121

(4)

FileTools[Remove]testfile

FileTools[Text]WriteIntegertestfile,1234,'delim':

FileTools[Text]WriteIntegertestfile,1213121,'delim'=::

FileTools[Text]Closetestfile:

FileTools[Text]ReadCharactertestfile

(5)

FileTools[Text]ReadIntegertestfile

1234

(6)

FileTools[Text]ReadCharactertestfile

(7)

FileTools[Text]ReadCharactertestfile

:

(8)

FileTools[Text]ReadIntegertestfile

1213121

(9)

FileTools[Text]ReadCharactertestfile

:

(10)

FileTools[Remove]testfile

FileTools[Text]WriteIntegertestfile,1,'rightdelim'=::

FileTools[Text]WriteIntegertestfile,2:

FileTools[Text]WriteIntegertestfile,3,'leftdelim'=::

FileTools[Text]Closetestfile:

FileTools[Text]ReadIntegertestfile

1

(11)

FileTools[Text]ReadCharactertestfile

:

(12)

FileTools[Text]ReadIntegertestfile

2

(13)

FileTools[Text]ReadCharactertestfile

:

(14)

FileTools[Text]ReadIntegertestfile

3

(15)

FileTools[Text]ReadCharactertestfile

FileTools[Remove]testfile

See Also

file, FileTools[AtEndOfFile], FileTools[Remove], FileTools[Text], FileTools[Text][Close], FileTools[Text][Open], FileTools[Text][ReadCharacter], FileTools[Text][ReadInteger], FileTools[Text][ReadNextInteger], FileTools[Text][ReadString], IO_errors


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam