 REM >Director:Menus.System.FreeMem
 REM By Rob Craig-Wood

 ON ERROR: ON ERROR OFF: ERROR ERR,REPORT$+" at "+STR$ ERL

 DIM b% 256

 Menu=FNswi_number("Director_Menu")
 EndMenu=FNswi_number("Director_EndMenu")
 Option=FNswi_number("Director_Option")
 Dash=FNswi_number("Director_Dash")

 menu$="Free memory"
 OSCLI"Set Director$Menu "+menu$
 SYS Menu,"<Director$Menu> -temp"

 SYS "Wimp_SlotSize",-1,-1 TO ,next%,free%
 free$=STR$(INT(free%/1024))
 dfree$=FNmake_string("Free:",free$)
 next$=STR$(INT(next%/1024))
 dnext$=FNmake_string("Next:",next$)
 totfree%=INT((next%+free%)/1024)
 totfree$=STR$(totfree%)
 dtotfree$=FNmake_string("Total free:",totfree$)
 SYS "OS_ReadMemMapInfo" TO psize%,pages%
 avail%=INT(psize%/1024)*pages%
 avail$=STR$(avail%)
 davail$=FNmake_string("Total:",avail$)
 used$=STR$(avail%-totfree%)
 dused$=FNmake_string("Used:",used$)

 SYS Option,""""+dnext$+""""
 SYS Option,""""+dfree$+""""
 SYS Option,""""+dtotfree$+""""
 SYS Dash
 SYS Option,""""+dused$+""""
 SYS Option,""""+davail$+""""
 SYS EndMenu

 END

 DEF FNmake_string(front$,a$)
 FOR n=1 TO (18-(LEN a$+LEN front$))
  front$=front$+" "
 NEXT n
 =front$+a$+" Kb"


 DEF FNswi_number(name$)
 LOCAL c%
 SYS "OS_SWINumberFromString",,name$ TO c%
 =c%


