18.02.2012, 13:04
PHP код:
#define memory_exist(%1) existproperty( .value = hash( #%1 ) )
#define memory_delete(%1) deleteproperty( .value = hash( #%1 ) )
#define memory_set(%1,%2) setproperty( .value = hash( #%1 ), .string = #%2 )
#define memory_get(%1,%2) getproperty( .value = hash( #%1 ), .string = %2 ); strunpack( %2, %2, sizeof(%2) )
#define memory. memory_
stock hash(str[])
{
new key;
for ( new x, xmax = strlen( str ); x < xmax; x++ )
{
key += str[x];
}
key *= key;
key >>= 11;
return key % 1024;
}
Пример:
PHP код:
new result[16];
memory.set("test string", "0.0");
memory.get("test string", result);