blockValue: Extract the Value of a Binary Block

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/rawBlock.R

Description

The blockValue function returns the interpreted value of a block of binary data (a "rawBlock" object).

The blockString function returns a null-terminated string from a block of binary data that is interpreted as a character data.

Usage

1
2
3
blockValue(block)

blockString(block)

Arguments

block

A "rawBlock" object.

Details

The type of the value returned is determined when the binary block is created (e.g., by readRaw) not when the value is extracted by the blockValue function.

The blockString function is useful for extracting a value from a binary block which is a string padded with null characters.

The blockString function throws an error if the block is not interpreted as a character value.

Value

Either a character, or numeric vector depending on how the binary block should be interpreted.

Author(s)

Paul Murrell

See Also

readRaw readFormat

Examples

1
2
3
4
5
6
charBlock <- readRaw(hexViewFile("rawTest.txt"), width=8)
blockValue(charBlock)
blockString(charBlock)

intBlock <- readRaw(hexViewFile("rawTest.int"), human="int")
blockValue(intBlock)

Example output

 [1] "t" "e" "s" "t" " " "p" "a" "t" "t" "e" "r" "n" "."
[1] "test pattern."
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
[26] 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

hexView documentation built on May 2, 2019, 7:02 a.m.