CLEAR does quite complicated things with HIMEM, MEMSIZ and STKTOP based on VARTAB and MAXFIL values... As this is all so 100% BASIC oriented I wonder why you can't just do it in BASIC? If you want to hide it from users then just execute the statement on your ML-program... I don't really see any benefit reimplementing it.