FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

RESOURCES

Store and retrieve arrays in resources


'=================
LOCAL FN ary2Res(@firstRecPtr&,@lastRecPtr&,rType&,rID,rRef)
'==================
'' This takes data from an array and saves
' it as a resource.
'' @firstRecPtr&: First record to save
' @lastRecPtr&: Last record to save + 1 <-- important!!
' rType: save as this res type (your choice)
' rID: save as this res ID (your choice)
' rRef: what file do we put it in (I use gSaveRef)
'' EXAMPLE:
''FN ary2Res(gArray(0),gArray(999),,_"DATA",1001,gRef)
'---------------------------------------
  sz& = lastRecPtr& - firstRecPtr&
  hndl& = FN NEWHANDLE(sz&)
  LONG IF hndl&
    BLOCKMOVE firstRecPtr&,[hndl&],sz&
    FN pGreplaceXRes(hndl&,rType&,rID,"",rRef)
  END IF
END FN
''=================
LOCAL FN res2Ary(@firstRecPtr&,rType&,rID,rRef)
'==================
'' This takes data from a resource and puts
' it into an array
'' @firstRecPtr&: First elem of array
' rType: saved as this res type (your choice)
' rID: saved as this res ID (your choice)
' rRef: what file do we get it from ' ' EXAMPLE:
'' FN res2Ary(gMyHugeArray(0),_"DATA",1001,gSaveRef)
'---------------------------------------
  curRes = FN CURRESFILE
  CALL USERESFILE(rRef)
  rHndl& = FN GET1RESOURCE(rType&,rID)
  LONG IF rHndl&
    recSize = FN GETHANDLESIZE(rHndl&)
    BLOCKMOVE [rHndl&],firstRecPtr&,recSize
  END IF
  CALL USERESFILE(curRes)
END FN

STAZ ~)~