Bput Command

Purpose

Fast save of an area of memory to a file.

Syntax

Bput #n, addr, count

n, addr, count:integer expression

Description

An area of memory can be saved to disk (RAM disk, hard disk etc.) using Bput (block put) and loaded back in with Bget (block get). The channel #n must be opened first with Open names$ for Output As #. The integer expression addr contains the start address of the memory to be saved. In addition, count must specify the length of the file.

Example

' Save and Load an array

OpenW # 1

Dim a%(999), addr%, b%(200), count%, i%

For i% = 0 To 999

a%(i%) = Rand(1000)

Next i%

addr% = V:a%(0)

count% = (V:a%(1) - V:a%(0)) * 1000

Open "C:\TEST.DAT" for Output As # 1

BPut # 1, addr%, count%

Close # 1

Open "C:\TEST.DAT" for Input As # 1

addr% = V:b%(0)

count% = (V:b%(1) - V:b%(0)) * 200

BGet # 1, addr%, count%

Close # 1

Kill "c:\TEST.DAT" // Tidy up line

For i% = 1 To 10

Print b%(i%)

Next i%

Remarks

The saving of memory with Bput is similar to BSave. In contrast to BSave, Bput saves the data through a previously opened channel under a previously defined file name.

See Also

Bload, BSave, Bget, Open

{Created by Sjouke Hamstra; Last updated: 26/09/2014 by James Gaite}