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

Open multiple resource files


mainResFile% = FN CURRESFILE
soundResFile% = USR OPENRFPERM(sounds$,SYSTEM(_aplVol),_fsRdPerm)
' I don't know the relative arguments on HOPENRESFILE vs OPENRFPERM--
' the latter just happens to be what I use
artResFile% = USR OPENRFPERM(art$,SYSTEM(_aplVol),_fsRdPerm)
IF soundResFile% < 1 OR artResFile% < 1 THEN FN fileMissing
' if either of the external files failed to load, put up dialog box
' telling user the files have to be in same folder as, blah blah,
' and can't be renamed... and then END on the spot
CALL USERESFILE(mainResFile%)
' since half the point of external res files is to save search time
' I default to the app itself unless specifically pointing to another file
' (go to soundResFile%, load a sound, set it back to mainResFile%)

Lucy


Here is how I open multiple resource files. Several years ago, I developed a Craps game in FB.
In addition to the resources stored in the application itself, there are two additional resource files, one containing music; the other various items of vocal patter for the game, simulating the dealer's calls. The following function checks that the resource files are present. If present, they are opened; if not, the user is given a message to that effect. "patterflag" and "musicflag" are globals indicating whether the program should or should not try to make the sounds, depending on whether the sound resource files are present or not.

CLEAR LOCAL
  DIM ResErr
  DIM crapssndRef1%
  DIM crapssndRef2%
  DIM 37 NA$
  DIM 33 NB$
  DIM 27 NC$
  DIM item
LOCAL FN opensound 'open craps sound resource files
  crapssndRef1% = USR OPENRFPERM ("crapspatter.rsrc", WDrefNum%, _fsRdPerm)
  ResErr = FN RESERROR 'Toolbox function that returns type of Resource error
  LONG IF ResErr <> 0
    NA$ = "The file crapspatter.rsrc could not"
    NB$ = "be found. Therefore, the dealer's"
    NC$ = "patter will not be heard."
    CALL PARAMTEXT (NA$, NB$, NC$, "") 'toolbox call
    item = FN NOTEALERT(1,0) 'Standard notealert called by toolbox
    patterflag = 0
  XELSE
    patterflag = -1
  END IF
  ResErr = 0
  crapssndRef2% = USR OPENRFPERM ("crapsmusic.rsrc", WDrefNum%, _fsRdPerm)
  LONG IF ResErr <> 0
    NA$ = "The file crapsmusic.rsrc could"
    NB$ = "not be found. Therefore, no"
    NC$ = "music will be heard."
    CALL PARAMTEXT (NA$, NB$, NC$, "")
    item = FN NOTEALERT(1,0)
    musicflag = 0
  XELSE
    musicflag = -1
  END IF
  ResErr = 0
END FN

I should mention that this was a FB v. 1.03 program; I have not tested the above code in FB II so I don't know if it is presently valid. I'm sure one of the regular contributers to this list can answer that.

Richard Goodman