FileTools[Binary] - Maple Programming Help

Home : Support : Online Help : Programming : Input and Output : File Manipulation : FileTools : Binary Subpackage : FileTools/Binary/Read

FileTools[Binary]

 read binary data from a file

 Calling Sequence Read(file, type, num, opt1, opt2, ...)

Parameters

 file - file descriptor or filename type - type of data to read num - number of elements to read byteorder = opt - (optional) byte order specification output = identical(list,Vector,Array) - (optional) output format

Description

 • The Read(file, type, num) command reads num elements in type format from a file and returns them in the form of a list.
 • The following are valid values for type: integer, integer, integer, integer, float, float.  These types represent hardware data types. The integer[n] is an n byte integer, and float[n] is an n byte float.
 • The byteorder argument can have one of four values: big, little, network, and native.  This effects the order in which bytes are written for multi-byte data types.
 - big and little specify big endian and little endian respectively
 - network specifies network ordering (big endian)
 - native uses the native byte ordering
 If byteorder is not specified, it defaults to network.
 • The output argument lets you specify the return-value data structure used to store the binary data.  Using output=Array or output=Vector can be more efficient as these data structures will keep the data in the specified hardware format without requiring any conversion.  The default is output = list in order to be compatible with previous versions of Maple.
 • If file is the name of a file that has not been opened, Maple attempts to open the file before attempting to read the data.
 • An error is raised if file is not a valid descriptor or if it is the name of a file that does not exists.

Examples

 > $\mathrm{num}≔1{256}^{3}+2{256}^{2}+3\cdot 256+4$
 ${\mathrm{num}}{≔}{1690960}$ (1)
 > $\mathrm{num2}≔4{256}^{3}+3{256}^{2}+2\cdot 256+1$
 ${\mathrm{num2}}{≔}{67305985}$ (2)
 > ${{\mathrm{FileTools}}_{\mathrm{Binary}}}_{\mathrm{Write}}\left("testfile",{\mathrm{integer}}_{4},\left[\mathrm{num}\right]\right)$
 ${4}$ (3)
 > ${{\mathrm{FileTools}}_{\mathrm{Binary}}}_{\mathrm{Close}}\left("testfile"\right):$
 > ${{\mathrm{FileTools}}_{\mathrm{Binary}}}_{\mathrm{Read}}\left("testfile",{\mathrm{integer}}_{4}\right)$
 $\left[{16909060}\right]$ (4)
 > ${{\mathrm{FileTools}}_{\mathrm{Binary}}}_{\mathrm{Close}}\left("testfile"\right):$
 > ${{\mathrm{FileTools}}_{\mathrm{Binary}}}_{\mathrm{Read}}\left("testfile",{\mathrm{integer}}_{4},'\mathrm{byteorder}'='\mathrm{little}'\right)$
 $\left[{67305985}\right]$ (5)
 > ${\mathrm{FileTools}}_{\mathrm{Remove}}\left("testfile"\right)$

Compatibility

 • The FileTools[Binary][Read] command was updated in Maple 2016.
 • The output parameter was updated in Maple 2016.
{"ft_lang_label":"__label__en","ft_lang_prob":0.6554443,"math_prob":0.9630627,"size":2290,"snap":"2019-43-2019-47","text_gpt3_token_len":587,"char_repetition_ratio":0.12992126,"word_repetition_ratio":0.024767801,"special_character_ratio":0.23231441,"punctuation_ratio":0.11057692,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97882396,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-10-19T04:51:50Z\",\"WARC-Record-ID\":\"<urn:uuid:bf44c9b0-aa58-45b4-8fc0-898256ffeb5d>\",\"Content-Length\":\"200781\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:2ee80155-935b-47ef-be75-c8c66febf90a>\",\"WARC-Concurrent-To\":\"<urn:uuid:456cf083-e193-45bd-b816-a5d78b9592fc>\",\"WARC-IP-Address\":\"199.71.183.28\",\"WARC-Target-URI\":\"https://www.maplesoft.com/support/help/Maple/view.aspx?path=FileTools%2FBinary%2FRead\",\"WARC-Payload-Digest\":\"sha1:EKBY5VXH76LSHF3Z3UFBJZWXIAS2IEDR\",\"WARC-Block-Digest\":\"sha1:UZFYEE76I6L2NYUOVOGWPYKNTPH5UMA3\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-43/CC-MAIN-2019-43_segments_1570986688826.38_warc_CC-MAIN-20191019040458-20191019063958-00444.warc.gz\"}"}