
typedef dword BOOL
typedef dword DWORD
typedef quad  DWORDLONG

typedef struct _MEMORYSTATUSEX {
  DWORD     dwLength;
  DWORD     dwMemoryLoad;
  DWORDLONG ullTotalPhys;
  DWORDLONG ullAvailPhys;
  DWORDLONG ullTotalPageFile;
  DWORDLONG ullAvailPageFile;
  DWORDLONG ullTotalVirtual;
  DWORDLONG ullAvailVirtual;
  DWORDLONG ullAvailExtendedVirtual;
} MEMORYSTATUSEX, *LPMEMORYSTATUSEX;


extern lib "kernel32.dll"

'void Sleep(sys msecs)
BOOL GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)

end extern

MEMORYSTATUSEX m
m.dwLength = sizeof m
GlobalMemoryStatusEx m
quad mi=m.ullAvailPhys

void AvailMem(quad*ma){GlobalMemoryStatusEx m : ma=m.ullAvailPhys}
void UsedMem(quad*ma){GlobalMemoryStatusEx m : ma=mi-m.ullAvailPhys}


TEST:
=====

string cr=chr(13,10)
quad ma1,ma2,ma3,ma4
bstring s1,s2

s1=space 1e6 : UsedMem ma1
s2=space 1e6 : UsedMem ma2
s1=" " : s2=" " : UsedMem ma3
frees s1 : frees s2 : UsedMem ma4

print "Memory In Use:" cr ma1 cr ma2 cr ma3 cr ma4

