[futurebasic] Array to resource?

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 2000 : Group Archive : Group : All Groups

From: Hans van Maanen <hans@...>
Date: Sun, 31 Dec 2000 09:28:27 +0100
Hi all

What am I doing wrong here?
I want to put an array of 101 doubles in a resource for quick 
reference in my resource file q.r as resource "Facs", nr 128.

Somehow, the resH does not get written into the resource file after closing.
The resource is there in memory, as resH2 shows (it fills in the 
first eleven doubles), but after quitting the program, the file q.r 
does not contain my new resource. Or is there something wrong with 
CHANGEDRESOURCE or WRITERESOURCE?

This kind of thing used to work in FB^2!

Help?

Hans van Maanen

---------------------------------------------------

RESOURCES "q.r"

begin globals
	dim k(100) as double
	dim a as double
	dim restype as double
	dim resH as handle
	dim resH2 as handle
	dim resnr as int
	dim i as int

end globals

restype  = _"Facs"
resnr     = 128

WINDOW 1

'make array...
FOR i = 0 TO 100
	k(i) = i / 3000
NEXT

'fill resource...
resH = FN NEWHANDLE(808)
LONG IF (resH <> 0) and (syserror = _noErr)
	hlock(resH)
	BLOCKMOVE @k(0), [resH], 808
	hunlock(resH)
	CALL ADDRESOURCE(resH, restype, resnr, "")
	CALL SETRESATTRS(resH, _resPurgeable%)
	CALL CHANGEDRESOURCE(resH)
	CALL WRITERESOURCE(resH)
	CALL RELEASERESOURCE(resH)
END IF

'check memory...
resH2= FN GET1RESOURCE(restype, resnr)
LONG IF resH2
	FOR i = 0 TO 10
		BLOCKMOVE [resH2] + 8 * i, @a, 8
	PRINT a
	NEXT
END IF


DO
UNTIL FN BUTTON
END