11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

188 • Chapter 4: Input and Outputwriteto( fileName )appendto( fileName )The fileName argument specifies the name of the file to which Maple isto redirect the output. If you call writeto, Maple truncates the file if itexists, and writes subsequent output to the file. The appendto commandappends to the end of the file if the file exists. If the file you specify is open(for example, it is in use by other file I/O operations), Maple generatesan error.The special fileName terminal (specified as a name, not a string)causes Maple to send subsequent default output to the original defaultoutput stream (the one that was in effect when you started Maple). Thecalls writeto(terminal) and appendto(terminal) are equivalent.Recommendation Issuing a writeto or appendto call directly from theMaple prompt is not recommended. When writeto or appendto is ineffect, Maple also writes any error messages that can result from subsequentoperations to the file. Therefore, you cannot see what is happening.Generally, use the writeto and appendto commands within proceduresor files of Maple commands that the read command is reading.4.7 Conversion CommandsConversion between Strings and Lists of IntegersThe readbytes and writebytes commands described in sections 4.5and 4.6 can work with either Maple strings or lists of integers. Youcan use the convert command to convert between these two formatsas follows.convert( string, bytes )convert( integerList, bytes )If you pass convert(...,bytes) a string, it returns a list of integers; ifyou pass it a list of integers, it returns a string.Due to the way strings are implemented in Maple, the character correspondingto the byte-value 0 cannot appear in a string. Therefore, ifintegerList contains a zero, convert returns a string of only those characterscorresponding to the integers preceding the occurrence of 0 in thelist.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!