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

MATHEMATICS

Perform a checksum


Here's another approach to a checksum. Not tested, but it will give you the concept. It gives a checksum on any text handle, and while it's quick and simple, it's not _particularly_ easy for a hacker to adjust for changes. It works equally well on ZTXT handles, or resource handles, or any handle for that matter!
LOCAL FN checkSum&(hndle&)
  DIM checkVal&,numLongs&,loop&
  XREF@ textArray&(99)         'Turn handle into array of long int's

  LONG IF hndl&
    textArray& = hndle&

    checkVal& = FN GETHANDLESIZE(hndle&) 'Use length for inil value
    numLongs& = (checkVal& >> 2) - 1     'Treat as long int's--how many?

    LONG IF numLongs& >= 0
      FOR loop& = 0 TO numLongs&
        checkVal& = checkVal& XOR textArray&(loop&) 'calc checksum
      NEXT
    END IF
  END IF

END FN = checkVal&
Jay