Skip to content

Extra functions

Wang Renxin edited this page Feb 2, 2017 · 18 revisions

MY-BASIC contains severial utility functions which are not written in the "core/my_basic.c", but in the "shell/main.c". This page describes all these functions.

beep

beep

Beeps once with the speaker. The simplest sample for writing a customized scripting interface function.

gc

gc()

Tries to trigger garbage collection, and returns how much bytes have been collected.

now

now()/now(FORMAT_STRING)

Gets a current time string.

Parameter format:

Specifier Replaced by Example
None Represent Www Mmm dd hh:mm:ss yyyy Sat Jun 20 09:29:00 2015
%D Short MM/DD/YY date 06/20/15
%F Short YYYY-MM-DD date 2015-06-20
%T ISO 8601 time format (HH:MM:SS) 14:55:02
%R 24-hour HH:MM time 14:55
More... Refer to strftime

os

os()

Gets the name of current OS.

raise

raise()/raise(ABORT_CODE)

Raises an error, with an optional abort code.

sys

sys(COMMAND)

Invokes a system command.

ticks

ticks()

Gets the elapsed tick count since system bootup in millisecond.

trace

trace()

Gets and prints the execution stack frames. Assuming we got below:

def fun()
	trace()
enddef
def foo()
	fun()
enddef
def bar()
	foo()
enddef
bar()

It would print top down FUN <- FOO <- BAR.

Clone this wiki locally