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

TEXT

Protect a TEXT resource


Let me make some simple suggestions to tedd's text resource question.

1 Set a variable to zero:
gCheckSum = 0
2 Store the old res file and switch to the app:
currRes = FN CURRESFILE
CALL USERESFILE SYSTEM(_aplRes)
3 Count all text resources
count = FN COUNT1RESOURCES(_"TEXT")
4 loop thru all and checksum
FOR x = 1 TO count
  rHndl& = FN GET1INDRESOURCE(_"TEXT",x)
  LONG IF rHndl&
    size& = FN GETHANDLESIZE(rHndl&)
    FOR loop& = 0 to size& - 1
      gCheckSum = gCheckSum + PEEK([rHndl&]+loop&)
    NEXT
  END IF
NEXT
5 restore the res file
CALL USERESFILE currRes
6 Store the checksum (as a resource?) in your application.

Note: You want to do this when the application flag is _false. In other words, when you are running interactive, this routine should run automatically. It shouldn't take it more than a half second or so to calc the check sum.

When the application flag is true, you want to go thru the same procedure, except that this time you compare the checksum that you just calculated to the stored version.

Another note: gCheckSum is an integer and will be over run many times. That's OK. It's still a checksum.

Another note: it doesn't matter if you have style information or not. In fact, you don't have to do this on _"TEXT" resources, you could pick any kind.
STAZ.