read_int32
result = read_int32(f, [endian=])
Input: f, endian · Output: result
What it is
Reads a signed 32-bit integer from f (file handle, opened readable). endian (string, optional, default "little", or "big") selects byte order.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = read_int32(f, [endian=]) | f —Reads a signed 32-bit integer from f (file handle, opened readable).endian string, optionalendian (string, optional, default "little", or "big") selects byte order. | result number | Returns a number, or Nothing if fewer than 4 bytes remain. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
f = fopen("record.bin", "wb")
write_int32(f, 12345)
write_float(f, 3.5)
close(f)
g = fopen("record.bin", "rb")
n = read_int32(g)
x = read_float(g)
close(g)
print("n = {n}, x = {x}")
output
n = 12345, x = 3.5
from file-io