English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 13 February 2021, 18:37   #1
LeCaravage
Registered User
 
LeCaravage's Avatar
 
Join Date: May 2017
Location: AmigaLand
Posts: 459
Saving an array to File

Hi,

I use BlitzBasic 2 on Amiga 500 KS1.3

I'd like to save an array rawb.B(x) to a file. Straight bytes from rawb(x) to file.
I use to have the code but lost it and can't find it anywhere on web. So I seak for your help.
Thanks
LeCaravage is offline  
Old 14 February 2021, 03:09   #2
Samurai_Crow
Total Chaos forever!
 
Samurai_Crow's Avatar
 
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,186
In DOS.library there's a call called Write() that will do it but I don't know the Blitz BASIC handle to it.
Samurai_Crow is offline  
Old 14 February 2021, 15:29   #3
Coagulus
Gets there in the end...
 
Coagulus's Avatar
 
Join Date: Sep 2005
Location: Wales
Posts: 862
On Wormy I created a bank using InitBank and then Poked the values into it. Then used SaveBank to save it. Loading was the same but in reverse using Peek.

There may be a better way but that worked.
Coagulus is offline  
Old 14 February 2021, 15:46   #4
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Yep, savebank and loadbank will work fine, but if you already have the memory you want to save, you can save and load any memory range with WriteMem and ReadMem. Knowing the size of an array, you can save the entire block and read it back to the variables if you wished. It's not foolproof so you'd want to make absolutely sure you're giving it valid values, but it's quite straightforward.

The address of the start of an array is obtained using &arrayname(0), and the size is (number of elements + 1) * element size. If you're dealing in bytes, each element is 1 byte so an array set up with Dim arrayname(50) is size 51. Then, WriteMem(myFile, &arrayname(0), 51) should do the trick to save it to a file you're opened, and ReadMem will load it back in. Make sure you have the array set up before you load anything into it this way!
Daedalus is offline  
Old 14 February 2021, 16:37   #5
LeCaravage
Registered User
 
LeCaravage's Avatar
 
Join Date: May 2017
Location: AmigaLand
Posts: 459
@all : Thanks for your help mates.

I thought using Allocmem, copy array to allocmem's adress and then Writemem.
But your bank method suits me better because faster and easier.
LeCaravage is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating an array gives me a Guru Shatterhand Coders. Blitz Basic 14 13 August 2019 20:54
Problem saving ROM in config file with 3.6.1 AlphaUMi support.WinUAE 8 21 March 2018 19:55
Blitz2: Pointer to array idrougge Coders. Blitz Basic 3 26 March 2015 21:44
Where is my file saving too? Need to back it up Kola New to Emulation or Amiga scene 19 20 December 2008 20:23
Saving the Amiga confiq file? neil324 project.MAGE 2 06 October 2008 18:42

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 19:56.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.06624 seconds with 15 queries