Functions and statements¶
The MV BASIC functions, statements and constants supported by the MVsharp runtime.
Looking for .NET signatures?
Every function listed here is implemented as a static method on the BasicRuntime.Functions
class. See the Runtime API reference for the exact C# overloads you can
call from C#, Python and JavaScript.
Functions¶
Abs¶
ABS(expression)
The ABS function returns the absolute value of an expression.
AccountPath¶
AccountPath(Expression)
The AccountPath function returns the Windows/Linux path to the Account specified in the expression
ActiveDirectory¶
ACTIVEDIRECTORY(aduser,adpassword,domain,userId,property)
The ActiveDirectory function queries your Active Directory (AD) controller and returns a property from it. aduser and adpassword are the credentials of an administrator on the AD controller, domain is the name of the domain, userId specifies the user record being queried and property is the name of the property to retrieve. STATUS() returns 0 for success and 1 if the property of userId does not exist.
Add.Account¶
Add.Account(accountName,hostName,account,ipAddress,userId,password,type)
The Add.Account function creates a database link to other MV databases (UniVerse/UniData/QM/jBASE/D3) to enable you to OPEN, READ, WRITE etc. files on other MV platforms.
Adds¶
Adds(expression1,expression2)
The Adds function adds all multivalues in expression1 to the corresponding multivalues in expression2.
Alpha¶
Alpha(expression)
The Alpha function tests the expression and returns true if all characters are alphabetic and false if any character is not alphabetic.
Ascii¶
Ascii(expression)
The Ascii function converts an EBCDIC string to ASCII.
Assigned¶
Assigned(variable)
The Assigned function checks to see if the variable has been assigned and returns true if it has been assigned a value or false if not.
Base64Decode¶
Base64Decode(expression)
The Base64Decode function converts the BASE64 string in expression to an ASCII string.
Base64Encode¶
Base64Encode(expression)
The Base64Encode function converts the expression into a BASE64 string.
BatchEnd¶
BatchEnd(fileVariable)
The BatchEnd function terminates batch processing on fileVariable and flushes any remaining writes to the file.
BatchStart¶
BatchStart(fileVariable,batchSize)
The BatchStart function begins batch processing on MVsharp files to improve IO performance. A single write is executed when the number of writes to fileVariable reaches batchSize.
Catalogued¶
Catalogued(expression)
The Catalogued function checks to see if the program name in expression has been catalogued in the VOC.
Cats¶
Cats(expression1,expression2)
The Cats function concatenates all multivalues in expression1 to the corresponding multivalues in expression2.
Change¶
CHANGE(Expression,oldstring,newstring)
The CHANGE function replaces one string with another in an expression.
ChangePort¶
ChangePort(expression)
The ChangePort function allows you to programmatically change your port number to a value defined in expression.
Char¶
CHAR(expression)
The CHAR function returns the ASCII character defined by the expression.
CheckSum¶
Checksum(expression)
The CheckSum function returns a checksum based on the CRC16 algorithm on the data supplied in expression.
ClearCommon¶
ClearCommon
The ClearCommon statement sets all the variables in unnamed common to 0.
Col1¶
Col1()
The Col1 function returns the column position after a Field statement of the character before the extraction.
Col2¶
Col2()
The Col2 function returns the column position after a Field statement of the character after the extraction.
Confirm¶
Confirm(message)
The Confirm function prompts the user 'Do you wish to ' and then the message supplied in the argument. It returns 0 for N and 1 for Y.
Count¶
Count(fileVariable)
Count(expression1,expression2)
When Count is used with a fileVariable, it returns the number of records in the file associated with the fileVariable. When used with expression1 and 2, it returns the number of occurrences of expression2 in expression1.
Create¶
Create(fileVariable)
Used after an OpenSeq statement when the file does not exist.
CreateFolder¶
CreateFolder(path)
Creates a directory and all its parent directories if they don't exist.
CreateRequest¶
CreateRequest(url,type,requestHandle)
Creates an HTTP request handle for the URL. type is GET or POST.
Date()¶
DATE()
The internal form of the date is expressed as the number of days before or since December 31, 1967. The internal format of December 31, 1967 is zero; any day before it is returned as a negative number and any day after it as a positive number.
Dcount¶
DCOUNT(expr1,Expr2)
The DCOUNT function counts the number of delimited elements in an expression.
Delete¶
DELETE(variable,am)
DELETE(variable,am,vm)
DELETE(variable,am,vm,svm)
The DELETE function removes an attribute, value or sub-value from a dynamic array.
Downcase¶
DOWNCASE(expression)
The DOWNCASE function converts an expression to all lower case characters.
Dquote¶
DQUOTE(Expression)
The DQUOTE function returns a string enclosed in double quotes.
Drop.Account¶
DROP.ACCOUNT(accountName)
The DROP.ACCOUNT function removes a connection to a remote database (UniVerse, UniData, jBASE, QM, D3, MongoDB).
End Case¶
END CASE
The END CASE statement terminates a CASE block. There should be a corresponding END CASE for each BEGIN CASE.
Equate¶
EQUATE definition TO value
EQU definition TO value
The EQU/EQUATE statement replaces all occurrences of the equated definition with its equivalent Value in your program.
Execute¶
EXECUTE statements {PASSLIST listnumber} {CAPTURING variable} {SETTING variable}
The EXECUTE statement executes the supplied arguments at a TCL level.
If the optional {CAPTURING variable} clause is supplied, all terminal IO from the statement will be returned in the variable.
An active select list can be passed to the statement by specifying {PASSLIST listnumber}.
If the optional {SETTING variable} is specified, the number of items selected will be returned in the variable.
Exit¶
EXIT
The EXIT statement exits a LOOP or FOR loop.
Field¶
FIELD(expression,separator,count)
FIELD(expression,separator,count,notoreturn)
The FIELD function extracts a portion of an expression by splitting the string using the separator provided and returning the element in the count position. If the optional notoreturn is specified, Field returns that number of fields including the separator.
Gosub¶
GOSUB label{:}
The GOSUB statement transfers execution to the internal subroutine named. Execution is continued with the first statement after the GOSUB when a RETURN is encountered.
Iconv¶
ICONV(expression,conversioncode)
The ICONV() function converts the value of expression to its internal representation according to the conversion codes in conversioncode.
Index¶
INDEX(expression,substring)
INDEX(expression,substring,occurrence)
The INDEX function returns the position of a substring in a string. The optional occurrence value specifies which occurrence of the substring to find.
Int¶
INT(expression)
The INT function returns the integer portion of a number with no decimal points.
Len¶
LEN(expression)
The LEN function returns the length of an expression.
License¶
License()
The License function returns a dynamic array of your license configuration: serial number, number of cores, number of users, expiry date, MVsync clients, MVsync updates, MVsync expiry and High Availability.
Lower¶
Lower(Expression)
The LOWER function lowers each marker by 1. AM > VM, VM > SVM etc.
Not¶
NOT(Expression)
The NOT function returns True (1) if the expression is false or blank, and False (0) if the expression is true.
Oconv¶
OCONV(expression,conversioncode)
The OCONV() function converts the value of expression to its external representation according to the conversion codes specified in conversioncode.
Raise¶
RAISE(Expression)
The RAISE function raises each marker by 1. SVM > VM, VM > AM etc.
Squote¶
SQUOTE(Expression)
The SQUOTE function returns a string enclosed in single quotes.
Stop¶
STOP
The STOP statement terminates the current program and returns to the calling program or TCL.
Trim¶
TRIM(expression)
The TRIM function removes all leading and trailing white space from a string.
Trimb¶
TRIMB(expression)
The TRIMB function removes all trailing white space from a string.
Trimf¶
TRIMF(expression)
The TRIMF function removes all leading white space from a string.
Unassigned¶
UNASSIGNED(variable)
The UNASSIGNED function returns True (1) when a variable has not been assigned a value and False (0) when it has.
Upcase¶
UPCASE(expression)
The UPCASE function converts an expression to all upper case characters.
Statements¶
Begin¶
The BEGIN statement is used to start a CASE block or a TRANSACTION block.
Begin Case¶
The BEGIN CASE statement is used to start a CASE block.
Begin Transaction¶
BEGIN TRANSACTION
The BEGIN TRANSACTION statement indicates the start of a transaction. All writes are batched together and are only committed when the COMMIT statement is executed.
Call¶
CALL subroutine{(arg1,arg2,...)}
CALL @variable{(arg1,arg2,...)}
The CALL statement passes program execution to another subroutine. The subroutine must be compiled and cataloged.
Case¶
CASE expr operator value
The CASE statement performs a test and if it resolves to true, all statements below the CASE are executed until the next CASE statement or END CASE statement.
Chain¶
CHAIN expression
The CHAIN statement terminates the current running program and starts the program in expression.
ClearFile¶
ClearFile fileVariable {ON ERROR} statements
The ClearFile statement clears all the data in the file referenced by fileVariable.
ClearInput¶
ClearInput
The ClearInput statement removes all unprocessed keystrokes in the user's input buffer.
ClearSelect¶
ClearSelect
ClearSelect expression
ClearSelect All
The ClearSelect statement without arguments removes select list 0. If specified with expression, the select list related to expression is removed and the All parameter removes all select lists.
Close¶
Close fileVariable {ON ERROR} statements
The Close statement closes the file handle referenced by fileVariable. The On Error clause is executed if a fatal error occurs.
Close.Socket¶
Close.Socket socketVariable
The Close.Socket statement closes a socket variable that was previously opened with Open.Socket, Open.ServerSocket or Accept.Socket.Connection.
CloseSeq¶
CloseSeq fileVariable {ON ERROR} statements
The CloseSeq statement closes the sequential file handle referenced by fileVariable (opened with OpenSeq). The On Error clause is executed if a fatal error occurs.
Commit¶
COMMIT
The COMMIT statement commits all writes in the transaction to the disk and continues executing at the statement following the END TRANSACTION.
Common¶
COM {/name/}variable,variable,...
COMMON {/name/}variable,variable,...
The COMMON statement allows you to define global variables across all programs that include the same common statement. If optional /name/ is supplied, this is a Named Common which allows you to create specific global variables associated with that common.
Continue¶
CONTINUE
The Continue statement returns program execution to the top of the FOR/LOOP loop.
Convert¶
CONVERT characters TO newcharacters IN variable
The CONVERT statement converts a series of characters to alternate characters in a dynamic array. If characters contains more than 1 character, each character is converted to the corresponding character in newcharacters.
Crt¶
CRT expression
CRT expression:
The CRT statement displays text in the terminal window. If the optional ':' is added, no carriage return is output after the text.
Debug¶
DEBUG
The DEBUG statement forces a program to enter the debugger at a specific point. This only applies if the program has been compiled in debug mode, for example: BASIC filename programname (D
Delete¶
DELETE filevariable, recordid
The DELETE statement deletes a record from a file.
Dim¶
DIM variable(depth)
DIM variable(depth,width)
The DIM statement creates a dimensioned array with the supplied number of elements. A dimensioned array can be single or multi-dimension.
End¶
END
The END statement terminates a THEN/ELSE block.
End Else¶
END ELSE
The END ELSE statement terminates the THEN portion and begins the ELSE portion of a code block.
End Transaction¶
END TRANSACTION
The END TRANSACTION statement indicates the end of a transaction. After a COMMIT or ROLLBACK, execution continues at the statements following the END TRANSACTION.
For¶
The FOR statement begins a FOR/NEXT Loop.
FormList¶
FORMLIST variable TO Listnumber
The FORMLIST statement converts a variable selectlist to a numbered selectlist.
Goto¶
GOTO label
GO label
GO TO label
The GOTO statement transfers program execution to the label specified after the GOTO statement.
If¶
IF expression THEN/ELSE
The IF statement begins a test block for a specific value. The block is terminated with an END statement.
$Include¶
$INCLUDE programname
$INCLUDE filename programname
The $INCLUDE directive inserts the program specified into the current source code. If the optional filename is specified the code is read from the file.
Loop¶
The LOOP statement begins a code block for looping. The loop is exited when either the WHILE/UNTIL is satisfied or the EXIT clause is executed.
Mat¶
MAT array = expression
The MAT statement allows you to initialise all the elements of an array to a specific value.
Match¶
expression MATCH/MATCHES pattern
The pattern matching operator, MATCH, and its synonym, MATCHES, compare a string expression to a pattern.
Next¶
NEXT variable
The NEXT statement terminates a FOR loop. Control is passed back to the FOR statement and the variable is incremented or decremented.
Open¶
OPEN {'DICT'},filename TO filevariable {ON ERROR} THEN/ELSE
The OPEN statement opens a file for data processing. If the OPEN statement fails, it executes any statements associated with an ELSE clause. If the OPEN is successful it will execute any statements associated with a THEN clause. Note that either one or both of the THEN and ELSE clauses are required.
Print¶
PRINT expression{:}
PRINT ON channel expression{:}
The PRINT statement sends output to a print channel. If no printer is on, the output goes to the terminal. The optional : at the end suppresses the carriage return appended to the expression.
Printer Close¶
PRINTER CLOSE
The PRINTER CLOSE statement closes the print channel. All data spooled will begin printing.
Printer Off¶
PRINTER OFF
The PRINTER OFF statement turns off printing to the printer. All subsequent PRINT statements will print to the terminal.
Printer On¶
PRINTER ON
The PRINTER ON statement turns on printing to the printer.
Program¶
PROGRAM
The PROGRAM statement defines this code as a program with no arguments. It must be the first statement in your code.
Read¶
READ record FROM filevariable, key {ON ERROR} THEN/ELSE
The READ statement reads a record from a file with the supplied key. If the key exists the THEN statements are executed, otherwise the ELSE statements are executed. The ON ERROR clause is executed if an error occurs during the READ process.
Readlist¶
READLIST variable FROM {listnumber|listvariable} THEN/ELSE
The READLIST statement reads all the remaining keys from the list number or list variable into a dynamic array. If keys are present in the list the THEN clause is executed else the ELSE clause is executed.
ReadNext¶
READNEXT var FROM listnumber THEN/ELSE
READNEXT var from variable THEN/ELSE
The READNEXT statement reads the next entry from a list number or variable. If no list number or variable is specified, the default list '0' is used. If an entry is available the THEN clause is executed, otherwise the ELSE clause is executed.
Readu¶
READU record FROM filevariable, key {LOCKED} {ON ERROR} THEN/ELSE
The READU statement reads a record from a file with the supplied key and attempts to lock the record. If the record is already locked the statements following the LOCKED clause are executed. If no LOCKED clause is present, execution stops and the record is released. If the key exists the THEN statements are executed, otherwise the ELSE statements are executed. The ON ERROR clause is executed if an error occurs during the READU process.
Readv¶
READV record FROM filevariable, key, attribute {ON ERROR} THEN/ELSE
The READV statement reads an attribute of a record from a file with the supplied key. If the key exists the THEN statements are executed, otherwise the ELSE statements are executed. The ON ERROR clause is executed if an error occurs during the READV process.
Release¶
RELEASE
RELEASE filevariable
RELEASE filevariable, key
The RELEASE statement releases a record lock that was previously set with a READU. If only the filevariable argument is specified, all locks for that file are released. If no arguments are specified, all locks set by the user are released.
Repeat¶
REPEAT
The REPEAT statement marks the end of a LOOP statement.
Return¶
RETURN
RETURN(expression)
The RETURN statement returns program execution to the following statement after a GOSUB. It also returns from a BASIC subroutine if no GOSUB is active. The second form of the RETURN statement is used in a FUNCTION call, expression is returned as the value for the function.
Rollback¶
ROLLBACK
The ROLLBACK statement discards all writes in the transaction and continues executing at the statement following the END TRANSACTION.
Select¶
SELECT filevariable TO listnum
SELECT filevariable TO variable
The SELECT statement creates a select list of elements in a specified variable or list number. If no list number or variable is present, the default select list '0' is used.
Subroutine¶
SUBROUTINE subroutinename
SUBROUTINE subroutinename(arg1,...)
The SUBROUTINE statement defines this code as a subroutine with optional arguments. Subroutines are called with the BASIC CALL statement. It must be the first statement in your code.
Until¶
UNTIL expr {DO}
The UNTIL statement terminates a FOR or LOOP loop when the specified expression is true. The optional DO is required in a LOOP.
While¶
WHILE expr {DO}
The WHILE statement terminates a FOR or LOOP loop when the specified expression is false. The optional DO is required in a LOOP.
Write¶
WRITE record ON filevariable , key {ON ERROR}
The WRITE statement writes a record to a file using the specified key. The file must be opened before the WRITE statement can be used. If an error occurs the ON ERROR clause is executed.
Writeu¶
WRITEU record ON filevariable , key
The WRITEU statement writes the record to a file using the key. If the record was previously locked, the lock is not removed and must be explicitly released using the RELEASE statement.
Writev¶
WRITEV record ON filevariable , key , attribute {ON ERROR}
The WRITEV statement writes an attribute to a file using the specified key and attribute number. The file must be opened before the WRITEV statement can be used. If an error occurs the ON ERROR clause is executed.
Constants¶
@Am¶
Returns the attribute marker CHAR(254).
@Svm¶
Returns the sub-value marker CHAR(252).
@Tm¶
Returns the text marker CHAR(251).
@Vm¶
Returns the value marker CHAR(253).