Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BLOAD / BSAVE

Status
Not open for further replies.

qbasicking

Programmer
Aug 19, 2001
628
US
I posted a question a while ago about taking a part of the screen and storing it. i got two answers one said to use BLOAD / BSAVE and the other said GET / PUT. I couldn't get BLOAD / BSAVE to work so I used GET / PUT. It worked great for the time, but when I have a lot of windows or menus up or I take a large chunk of the screen I tend to run out of memory. How do I use BLOAD / BSAVE? The Help File is sketchy and my refernce manual fails to mention them.

This is the code I used for BASICA but won't work for qb.

BSAVE "Screen.m", 0,10000
BLOAD "Screen.m",0
 
Here's the info in the Help files enjoy...


'BSAVE Statement Details
'
'Syntax
' BSAVE filespec,offset,length
'
' filespec A string expression containing the file or device name.
' Output devices other than the console (SCRN: and CONS:)
' are supported.
' offset The offset of the starting address of the area in memory
' to be saved.
' length The number of bytes to save. This is a numeric
' expression returning an unsigned integer in the range
' 0-65,535.
'
'The BSAVE statement allows data or programs to be saved as memory-image
'files on disk. A memory-image file is a byte-for-byte copy of what
'is in memory along with control information used by BLOAD to
'load the file.
'
' Note: Programs written in earlier versions of BASIC no longer work
' if they use VARPTR to access numeric arrays.
'
'The starting address of the area saved is determined by the offset
'and the most recent DEF SEG statement.
'
'If no DEF SEG statement is executed before the BSAVE statement,
'the program uses the default BASIC data segment (DS). Otherwise,
'BSAVE begins saving at the address specified by the offset and
'by the segment set in the most recent DEF SEG statement.
'
'If the offset is a single- or double-precision floating-point value,
'it is coerced to an integer. If the offset is a negative number in
'the range -1 to -32,768, it is treated as an unsigned 2-byte offset.
'
' Note: Because different screen modes use memory differently, do not
' load graphic images in a screen mode other than the one used
' when the images were created.
'
'Differences From BASICA
'
'BSAVE does not support the cassette device.
'
'
'
'
'BLOAD Statement Details
'
'Syntax
' BLOAD filespec [,offset]
'
' Argument Description
' filespec A string expression containing the file specification.
' Input devices other than the keyboard (KYBD:) are
' supported.
'
' offset The offset of the address where loading is to start.
'
'The BLOAD statement allows a program or data saved as a memory-image
'file to be loaded anywhere in memory. A memory-image file is a byte-
'for-byte copy of what was originally in memory.
'
' Note: Programs written in earlier versions of BASIC no longer work
' if they use VARPTR to access numeric arrays.
'
'The starting address for loading is determined by the specified offset
'and the most recent DEF SEG statement. If offset is omitted, the
'segment address and offset contained in the file (the address used in
'the BSAVE statement) are used. Thus, the file is loaded at the address
'used when saving the file.
'
'If you supply an offset, the segment address used is the segment set
'by the most recently executed DEF SEG statement. If there has been no
'DEF SEG statement, the BASIC data segment (DS) is used as the default.
'
'If the offset is a single-precision or double-precision number it
'is coerced to an integer. If the offset is a negative number in the
'range -1 to -32,768, it is treated as an unsigned 2-byte offset.
'
' Note: Because BLOAD does not perform an address-range check, it is
' possible to load a file anywhere in memory. You must be careful
' not to write over BASIC or the operating system.
'
'Since different screen modes use memory differently, do not load
'graphic images in a screen mode other than the one used when they were
'created.
'
'Also, because BASIC program code and data items are not always stored
'in the same locations as they were in BASICA, do not use BLOAD with
'files created by BASICA programs.
' ----------------
'
'Differences from BASICA
'
'BLOAD does not support the cassette device.
'
'
'



Example use of BLOAD/BSAVE Statement

'******Start Coping here******
DIM Cube(1 TO 675)
SCREEN 1

' Draw a white box.
LINE (140, 25)-(140 + 100, 125), 3, B

' Draw the outline of a magenta cube inside the box.
DRAW "C2 BM140,50 M+50,-25 M+50,25 M-50,25"
DRAW "M-50,-25 M+0,50 M+50,25 M+50,-25 M+0,-50 BM190,75 M+0,50"

' Save the drawing in the array Cube.
GET (140, 25)-(240, 125), Cube

' Set segment to the array Cube's segment and store the drawing
' in the file MAGCUBE.GRH. Note: 2700 is the number of bytes
' in Cube (4 bytes per array element * 675).
PRINT "Saving to file MagCube.grh...": SLEEP 1
DEF SEG = VARSEG(Cube(1))
BSAVE "MAGCUBE.GRH", VARPTR(Cube(1)), 2700
DEF SEG ' Restore default BASIC segment.



'*** Programming example using BLOAD ***
' You must create the file MAGCUBE.GRH using the BSAVE statement
' programming example before you can run this program. This program
' uses MAGCUBE.GRH.
'
' Set the screen mode. The mode should be the same as the
' mode used to create the original drawing.
SLEEP 3
SCREEN 1

' Set segment to the array Cube's segment and load
' the graphic file into Cube.
CLS : PRINT "Loading from file MagCube.grh...": SLEEP 1

DEF SEG = VARSEG(Cube(1))
BLOAD "MAGCUBE.GRH", VARPTR(Cube(1))
DEF SEG ' Restore default BASIC segment.

' Put the drawing on the screen.
' NOTE: I added this so that you can see that it was re-loaded from the file....
FOR Cycle = 1 TO 80
PUT (Cycle, 10), Cube
SlowMe = TIMER + .1
DO
LOOP WHILE SlowMe > TIMER
CLS
NEXT Cycle

END
'******End Copying Here******

Hope this helps..
--MiggyD It's better to have two heads to solve a problem from different angles than to have tunnel vision to a dead end.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top