Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Global Atoms
Message
From
06/09/2004 18:18:14
 
 
To
06/09/2004 18:08:38
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00939784
Message ID:
00939801
Views:
13
>>What I further found out:
>>- The maximum size for the stringtype key/info is 256 bytes, I believe.
>>- Each redeclaration (with GlobalAddAtom) of the same atom name increases what might be called a 'stack number'. Each delte (with GlobalDeleteAtom) decreases it. So, the most secure way to get rid of the entry is:
do while GlobalFindAtom( cString ) > 0
>>	GlobalDeleteAtom( nAtom )
>>enddo
>
>It seems to me that this would be an abuse of the original idea of using atoms - which might cause some problems.
>
>What I briefly read some years ago - assuming I read and understood it correctly - is more or less the following.
>
>Atoms are used for efficient storage of strings. Each time you create an atom, with the corresponding functions, Windows will check whether an identical string already exists. If it does, the same space will be used again. If it doesn't, a new atom will be created.
>
>So, it would seem to me that any function must use GlobalAddAtom() to define the string, and a single invocation of GlobalDeleteAtom() to release it. Then, if another program or process happens to still use it, it will remain in memory, as it should.
>
>Reducing the usage count to zero would be an indication that no process, not the one you are currently in, and no other process, uses the specific string any longer.

I agree. Normally, one should use a quite unique string.

Here's a nice piece of code (http://www.news2news.com/vfp/?group=-1&function=167 Anatoliy Mogylevets)
#DEFINE AtomStrLength   512 

DECLARE INTEGER GlobalGetAtomName IN kernel32; 
    INTEGER  nAtom,; 
    STRING @ lpBuffer,; 
    INTEGER  nSize 

CREATE CURSOR cs (atom N(12), strlen N(5), name C(250)) 

* scan string atoms: from 0xC000 to 0xFFFF 
FOR nAtom = 49152 TO 65535 
    lpBuffer = Repli(Chr(0), AtomStrLength) 
    lnResult = GlobalGetAtomName (nAtom, @lpBuffer, AtomStrLength) 

    IF lnResult > 0 
        INSERT INTO cs VALUES (nAtom, lnResult, LEFT(lpBuffer, lnResult)) 
    ENDIF 
ENDFOR 

SELECT cs 
GO TOP 
BROW NORMAL NOWAIT
Groet,
Peter de Valença

Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.
Previous
Reply
Map
View

Click here to load this message in the networking platform