Skip to content

Extra functions

Wang Renxin edited this page May 31, 2022 · 18 revisions

MY-BASIC contains severial utility functions which are written in the shell/main.c file. This page describes all these functions.

BEEP

beep

Beeps once with speaker. The simplest sample for writing an extended BASIC 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 call stack. Assuming we got following code:

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