I have created the atom and I know how to get the name of the atom, but I can't for some reason delete the atom that I created.

atomName = "KeyPress"

atomAvail = GlobalFindAtom(atomName)
(atomAvail should be a 0 to let me know that the Atom is available, but this only worked the first time and now always has the integer value assigned to it regardless of GlobalDeleteAtom call)

atomNum = GlobalAddAtom(atomName)


GlobalDeleteAtom (atomNum)

end function

What am I doing wrong?