GXBF class

class geosoft.gx.GXBF
The BF class is used to access (or create) Binary files and remove
(or destroy) files from use. You can also perform a variety of
additional tasks, such as positioning within files, reading from
files and writing to files.
ch_size((int)arg1) → None:
Changes the size of a file
Parameters:arg1 (int) – new length in bytes
Returns:Nothing
Return type:None

New in version 5.0.0.

copy((GXBF)arg1) → None:
Copy entire contents of a source BF to a destination BF
Parameters:arg1 (geosoft.gx.GXBF) – Destination BF
Returns:Nothing
Return type:None

New in version 5.0.0.

crc((int)arg1, (int)arg2) → int:
Compute CRC of a file.
Parameters:
Returns:

CRC Value

Return type:

int

New in version 5.0.0.

static create((GXContext)ctx, (str)arg1, (int)arg2) → GXBF:
Create BF object.
Parameters:
Returns:

BF Object

Return type:

geosoft.gx.GXBF

New in version 5.0.0.

Note:

Run-time specific directory paths may be added the the front of file names
as follows:

      <geosoft>      the main Geosoft installation directory
      <geosoft2>     the secondary Geosoft installation directory
      <geotemp>      the Geosoft temporary file directory
      <windows>      the operating system Windows directory
      <system>       the operating system system directory
      <other>        other environment variables

For example "<geosoft>/user/csv/datum.csv"
static create_sbf((GXContext)ctx, (GXSBF)arg1, (str)arg2, (int)arg3) → GXBF:
Create BF object inside an SBF.
Parameters:
Returns:

BF Object

Return type:

geosoft.gx.GXBF

New in version 5.0.0.

Note:

see sbf.gxh
eof() → int:
Returns 1 if at the end of the file
Returns:1 if at the end of the file, 0 if not at the end of the file
Return type:int

New in version 5.0.0.

is_null() → bool

Check if the instance of geosoft.gx.GXBF is null (undefined)

Returns:True if this is a null instance of geosoft.gx.GXBF, False otherwise.
Return type:bool`
static null() → GXBF

A null (undefined) instance of geosoft.gx.GXBF

Returns:A null geosoft.gx.GXBF
Return type:geosoft.gx.GXBF
query_write() → int:
Check if you can write to the BF.
Returns:0 - No 1 - Yes
Return type:int

New in version 5.1.1.

read_binary_string((int)arg1, (int)arg2, (str_ref)arg3) → None:
Reads string data from current position in BF
Parameters:
Returns:

Nothing

Return type:

None

New in version 6.3.0.

read_double((int)arg1, (float_ref)arg2) → None:
Reads real data from current position in BF
Parameters:
Returns:

Nothing

Return type:

None

New in version 5.0.0.

Note:

If the data source may be in byte order different from that
required by the reader, you can add the source byte-order
to the BF elelment type.  The byte order will be swapped
if required.  For example, to write out a real number 3.5
with Most-Significant_Byte first (Mortorola) convention:

geosoft.gx.GXBF.write_double()(hBF,BF_BYTEORDER_MSB+GS_REAL,3.5).

If a byte order is not specified, the source is assumed to be
in the native byte order of the reading/writing computer.
read_int((int)arg1, (int_ref)arg2) → None:
Reads int data from current position in BF
Parameters:
Returns:

Nothing

Return type:

None

New in version 5.0.0.

Note:

If the data source may be in byte order different from that
required by the reader, you can add the source byte-order
to the BF elelment type.  The byte order will be swapped
if required.  For example, to write out a real number 3.5
with Most-Significant_Byte first (Mortorola) convention:

geosoft.gx.GXBF.write_double()(hBF,BF_BYTEORDER_MSB+GS_REAL,3.5).

If a byte order is not specified, the source is assumed to be
in the native byte order of the reading/writing computer.
read_vv((int)arg1, (GXVV)arg2) → None:
Read data to a VV from current position in BF
Parameters:
Returns:

Nothing

Return type:

None

New in version 5.0.0.

Note:

If the data source may be in byte order different from that
required by the reader, you can add the source byte-order
to the BF elelment type.  The byte order will be swapped
if required.  For example, to write out a real number 3.5
with Most-Significant_Byte first (Mortorola) convention:

geosoft.gx.GXBF.write_double()(hBF,BF_BYTEORDER_MSB+GS_REAL,3.5).

If a byte order is not specified, the source is assumed to be
in the native byte order of the reading/writing computer.
seek((int)arg1, (int)arg2) → None:
Moves file position
Parameters:
  • arg1 (int) – number of bytes from reference point
  • arg2 (int) – BF_SEEK constants
Returns:

Nothing

Return type:

None

New in version 5.0.0.

Note:

Terminates if attempt to move past the end of
a read-only file.
set_destroy_status((int)arg1) → None:
Set the flag to delete the file on close
Parameters:arg1 (int) – BF_CLOSE constants
Returns:Nothing
Return type:None

New in version 6.0.0.

size() → int:
Returns the file length
Returns:File size in bytes.
Return type:int

New in version 5.0.0.

tell() → int:
Returns current position of file pointer in bytes
Returns:Current file pointer location
Return type:int

New in version 5.0.0.

write_binary_string((int)arg1, (str)arg2) → None:
Write a binary string to a BF
Parameters:
Returns:

Nothing

Return type:

None

New in version 6.3.0.

write_data_null() → None:
Writes a null byte (0) to BF
Returns:Nothing
Return type:None

New in version 5.0.0.

write_double((int)arg1, (float)arg2) → None:
Writes real to the BF
Parameters:
Returns:

Nothing

Return type:

None

New in version 5.0.0.

Note:

See comments on byte order for the Read.. functions if you
want to enforce a certain byte order.

If a byte order is not specified, the data is written
in the native byte order of the writing computer.
write_int((int)arg1, (int)arg2) → None:
Writes int to the BF
Parameters:
Returns:

Nothing

Return type:

None

New in version 5.0.0.

Note:

See comments on byte order for the Read.. functions if you
want to enforce a certain byte order.

If a byte order is not specified, the data is written
in the native byte order of the writing computer.
write_vv((int)arg1, (GXVV)arg2) → None:
Writes VV to the BF
Parameters:
Returns:

Nothing

Return type:

None

New in version 5.0.0.

Note:

See comments on byte order for the Read.. functions if you
want to enforce a certain byte order.

If a byte order is not specified, the data is written
in the native byte order of the writing computer.

BF_BYTEORDER constants

Byte order for read/write
gx.BF_BYTEORDER_LSB = 256
Least significant byte first (Intel, Windows)
gx.BF_BYTEORDER_MSB = 512
Most significant byte first (Mororola, Sun)

BF_CLOSE constants

Close Flags
gx.BF_KEEP = 0
gx.BF_DELETE = 1

BF_ENCODE constants

The way a string is encoded
gx.BF_ENCODE_ANSI = 0
String is stored as ANSI code page
gx.BF_ENCODE_UTF8 = 1
String is stored as UTF8

BF_OPEN_MODE constants

Open Status
gx.BF_READ = 0
Read only
gx.BF_READWRITE_NEW = 1
erases existing file
gx.BF_READWRITE_OLD = 2
file must pre-exist
gx.BF_READWRITE_APP = 4
open and append onto pre-existing file (cannot be read from)

BF_SEEK constants

Seek Location
gx.BF_SEEK_START = 0
gx.BF_SEEK_CURRENT = 1
gx.BF_SEEK_EOF = 2