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

Copy PICT resources


I need help. I have a bunch of PICT Resources in one free-standing Resource File. I want to copy some of these under program control to another free-standing Resource File, with all their attributes.
At the moment, I'm drawing the PICTs, and then capturing them from the screen and writing them back out, which I freely admit is daft.
If someone can give me a "by numbers" snippet of code that does the above directly, I'll be eternally grateful.
Phil

'     here's rough code that illustrates the job...
'     Bowerbird

COMPILE 0,_caseinsensitive : % _ACount,0 : WINDOW OFF
gcounter=0
WINDOW 1,"",(0,0)-(600,400),_dialogshadow
tofilename$="pyates-to.rsrc"
fromfilename$="pyates-from.rsrc"
tovolrefnum%=0
fromvolrefnum%=0
gpictsto%=FN OPENRFPERM (tofilename$,tovolrefnum%,_fswrperm)
gpictsfrom%=FN OPENRFPERM (fromfilename$,fromvolrefnum%,_fsrdperm)
IF gpictsto%<=0 THEN BEEP : DELAY 1000 : END
IF gpictsfrom%<=0 THEN BEEP : BEEP : DELAY 1000 : END
CALL USERESFILE(gpictsfrom%)
END GLOBALS

CLEAR LOCAL FN savetonew (p&,rsrcnum%,rsrcname$)
  s&=p&
  CALL DETACHRESOURCE(p&)
  CALL RELEASERESOURCE(p&) 
  CLS : PICTURE (0,0),s&
  LOCATE 10,0 : PRINT rsrcnum%,rsrcname$
  CALL USERESFILE(gpictsto%)
  CALL ADDRESOURCE (s&,_"PICT",rsrcnum%,rsrcname$)
  CALL WRITERESOURCE (s&)
  CALL SETRESATTRS (s&,32)
  CALL DETACHRESOURCE (s&)
  DEF DISPOSEH (s&)
  CALL USERESFILE(gpictsfrom%)
END FN

CLEAR LOCAL FN doit
  CALL USERESFILE(gpictsfrom%)
  gcounter=gcounter+1
  numberofpicts=FN COUNT1RESOURCES (_"PICT")
  LONG IF gcounter<=numberofpicts
    p&=FN GET1INDRESOURCE (_"PICT",gcounter)
    LONG IF p&
      CALL GETRESINFO (p&,rsrcnum%,restype&,rsrcname$)
      FN savetonew (p&,rsrcnum%,rsrcname$)
    END IF
  XELSE
    gcounter=-1
    cls : print "command-period to end..."
  END IF
END FN

CLEAR LOCAL FN doend
  CALL UPDATERESFILE (gpictsto%)
  CALL CLOSERESFILE (gpictsto%)
  CALL CLOSERESFILE (gpictsfrom%)
  END
END FN

ON BREAK FN doend
DO
  HANDLEEVENTS
  IF gcounter>=0 THEN FN doit
UNTIL 0

Bowerbird