Class UtilityFunctions
java.lang.Object
com.scriptbasic.utility.functions.UtilityFunctions
public class UtilityFunctions
extends java.lang.Object
Static methods in this class are registered in the interpreter when the
interpreter starts. The interpreter calls the static method
MethodRegisterUtility.registerFunctions(Class, Interpreter) and that function
registers the methods in this class with their own name so that BASIC
programs can call the functions like BASIC built in functions.- Author:
- Peter Verhas date July 15, 2012
-
Method Summary
Modifier and Type Method Description static java.lang.Integerasc(java.lang.Object arg)Returns an Integer representing the character code corresponding to the first letter in a string.static byte[]byteBuffer(int len)Create a new byte buffer of lengthlen.static java.lang.Doublecdbl(java.lang.Object arg)static java.lang.Stringchr(java.lang.Object charcode)Returns a String containing the character associated with the specified character code.static java.lang.Longclng(java.lang.Object arg)static java.lang.LonggetByte(byte[] buffer, java.lang.Long i)static byte[]getStringBytes(java.lang.String s)static java.lang.BooleanisDefined(java.lang.Object s)static java.lang.BooleanisNull(java.lang.Object s)static java.lang.BooleanisUndef(java.lang.Object s)static java.lang.Longlength(java.lang.Object arg)static voidlogDebug(java.lang.String message)static voidlogError(java.lang.String message)static voidlogInfo(java.lang.String message)static java.lang.ObjectnewMagicBean()static voidsetByte(byte[] buffer, java.lang.Long i, java.lang.Long v)static java.lang.StringstringifyBuffer(byte[] buffer)static java.lang.Objectundef()This function returns the undef value.
-
Method Details
-
newMagicBean
public static java.lang.Object newMagicBean() -
logError
public static void logError(java.lang.String message) -
logInfo
public static void logInfo(java.lang.String message) -
logDebug
public static void logDebug(java.lang.String message) -
undef
public static java.lang.Object undef()This function returns the undef value.- Returns:
- the undef value
-
isUndef
public static java.lang.Boolean isUndef(java.lang.Object s)- Parameters:
s- is some value or object- Returns:
- true if the parameter is undefined
-
isDefined
public static java.lang.Boolean isDefined(java.lang.Object s)- Parameters:
s- is some value or object- Returns:
- true if the parameter is defined (not isUndef).
-
isNull
public static java.lang.Boolean isNull(java.lang.Object s)- Parameters:
s- is some value or object- Returns:
- true if the parameter is null
-
byteBuffer
public static byte[] byteBuffer(int len)Create a new byte buffer of lengthlen.- Parameters:
len- the length of the buffer allocated.- Returns:
- the new buffer
-
getByte
public static java.lang.Long getByte(byte[] buffer, java.lang.Long i) -
setByte
public static void setByte(byte[] buffer, java.lang.Long i, java.lang.Long v) throws BasicRuntimeException- Throws:
BasicRuntimeException
-
getStringBytes
public static byte[] getStringBytes(java.lang.String s) -
stringifyBuffer
public static java.lang.String stringifyBuffer(byte[] buffer) -
length
public static java.lang.Long length(java.lang.Object arg) -
cdbl
- Throws:
BasicRuntimeException
-
clng
- Throws:
BasicRuntimeException
-
chr
Returns a String containing the character associated with the specified character code.- Parameters:
charcode- argument is a Long that identifies a character- Returns:
- character
- Throws:
BasicRuntimeException- fail if incorrect character code
-
asc
Returns an Integer representing the character code corresponding to the first letter in a string.- Parameters:
arg- string argument- Returns:
- character code corresponding to the first letter
- Throws:
BasicRuntimeException- fail on empty input
-