WriteInteger - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

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 $\mathrm{delim}=\mathrm{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 $\mathrm{leftdelim}=\mathrm{string}$ or $\mathrm{rightdelim}=\mathrm{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

 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{WriteInteger}\right]\left("testfile",1234\right)$
 ${4}$ (1)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{WriteCharacter}\right]\left("testfile",""\right):$
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{WriteInteger}\right]\left("testfile",1213121\right)$
 ${7}$ (2)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{Close}\right]\left("testfile"\right):$
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadInteger}\right]\left("testfile"\right)$
 ${1234}$ (3)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadInteger}\right]\left("testfile"\right)$
 ${1213121}$ (4)
 > $\mathrm{FileTools}\left[\mathrm{Remove}\right]\left("testfile"\right)$
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{WriteInteger}\right]\left("testfile",1234,'\mathrm{delim}'\right):$
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{WriteInteger}\right]\left("testfile",1213121,'\mathrm{delim}'=":"\right):$
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{Close}\right]\left("testfile"\right):$
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadCharacter}\right]\left("testfile"\right)$
 ${""}$ (5)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadInteger}\right]\left("testfile"\right)$
 ${1234}$ (6)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadCharacter}\right]\left("testfile"\right)$
 ${""}$ (7)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadCharacter}\right]\left("testfile"\right)$
 ${":"}$ (8)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadInteger}\right]\left("testfile"\right)$
 ${1213121}$ (9)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadCharacter}\right]\left("testfile"\right)$
 ${":"}$ (10)
 > $\mathrm{FileTools}\left[\mathrm{Remove}\right]\left("testfile"\right)$
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{WriteInteger}\right]\left("testfile",1,'\mathrm{rightdelim}'=":"\right):$
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{WriteInteger}\right]\left("testfile",2\right):$
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{WriteInteger}\right]\left("testfile",3,'\mathrm{leftdelim}'=":"\right):$
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{Close}\right]\left("testfile"\right):$
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadInteger}\right]\left("testfile"\right)$
 ${1}$ (11)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadCharacter}\right]\left("testfile"\right)$
 ${":"}$ (12)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadInteger}\right]\left("testfile"\right)$
 ${2}$ (13)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadCharacter}\right]\left("testfile"\right)$
 ${":"}$ (14)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadInteger}\right]\left("testfile"\right)$
 ${3}$ (15)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadCharacter}\right]\left("testfile"\right)$
 > $\mathrm{FileTools}\left[\mathrm{Remove}\right]\left("testfile"\right)$