BinaryFile.ReadContainer
------------------------

Read some data and interpret them as container.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [BinaryFile](component_BinaryFile.md) | [7.3](newinversion73.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "BinaryFile.ReadContainer"; BinaryFileRef; ByteCount; FileName ) 

**MBS**( **"BinaryFile.ReadContainer";** /\* Read some data and interpret them as container. \*/  
**$BinaryFileRef**; /\* The reference number for the open file.e.g. $FH \*/   
**$ByteCount**; /\* The number of Bytes to read.e.g. 1000 \*/   
**$FileName**) /\* File name to use for container value.  
This is used to detect type of container.e.g. "test.pdf" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| BinaryFileRef | The reference number for the open file. | $FH |
| ByteCount | The number of Bytes to read. | 1000 |
| FileName | File name to use for container value.   This is used to detect type of container. | "test.pdf" |

### Result

Returns value or error.

### Description

Read some data and interpret them as container.  
Depending on given file name, you get back a PDF, image, video or data container.  
See also [BinaryFile.WriteContainer](BinaryFileWriteContainer.md) for writing.  
### Examples

Read a JPEG:

 Set Variable \[ $fh ; Value: MBS ( "[BinaryFile.Open](BinaryFileOpen.md)"; "/Users/cs/Desktop/test.jpg" ) \]   
Set Variable \[ $len ; Value: MBS ("[BinaryFile.Length](BinaryFileLength.md)"; $fh ) \]   
Set Variable \[ $image ; Value: MBS ( "BinaryFile.ReadContainer"; $fh ; $len ; "test.jpg" ) \]   
Set Field \[ test::ContainerField ; $image \]   
Set Variable \[ $r ; Value: MBS ( "[BinaryFile.Close](BinaryFileClose.md)"; $fh ) \]  
### See also

- [BinaryFile.Close](BinaryFileClose.md)
- [BinaryFile.Length](BinaryFileLength.md)
- [BinaryFile.Open](BinaryFileOpen.md)
- [BinaryFile.WriteContainer](BinaryFileWriteContainer.md)

### Blog Entries

- [FileMaker 18 File Script Steps vs. BinaryFile functions](https://www.mbsplugins.de/archive/2019-06-03/FileMaker_18_File_Script_Steps/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 12nd June 2017 , last changed 12nd June 2017

  
[BinaryFile.ReadByte](BinaryFileReadByte.md) - [BinaryFile.ReadFloat](BinaryFileReadFloat.md)

[HTML Version](BinaryFileReadContainer.shtml)