Skip to content

Extra functions

Wang Renxin edited this page Mar 3, 2016 · 18 revisions

MY-BASIC contains severial utility functions which are not written inside 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 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 Tue Jan 26 08:00:00 2016
%D Short MM/DD/YY date 08/23/01
%F Short YYYY-MM-DD date 2001-08-23
%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 current OS name.

raise

raise()/raise(ABORT_CODE)

Raises an error with or without an abort code.

set_importing_dirs

set_importing_dirs(DIRS)

Sets importing directories.

DIRS are directory pathes separated by semicolons, eg. "data;data/res;../data;../data/res".

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