HomeStartingEnvironmentDBMSVisualPQLProceduresSQLFormsHost/APIIndex
VisualPQL homecontents start chapter top of pagebottom of pagenext page index Functions

Functions

Functions return a single numeric or string value derived from the arguments of the function. Arguments are separated by commas. In general, the functions can appear in any string, arithmetic or logical expression in a VisualPQL program. Schema functions can be used in a PROGRAM. The functions are listed by type and in alphabetical order with a full explanation of each.

List of Functions by Type

Function types are:

List of Functions by Name

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

homecontents start chapter top of pagebottom of pagenext page index

Trigonometric Functions

ACOS arc cosine (also ARCOS)

ASIN arc sine (also ARSIN)

ATAN arc tangent

COS trigonometric cosine

SIN trigonometric sine

TAN trigonometric tangent

TANH hyperbolic tangent

homecontents start chapter top of pagebottom of pagenext page index

Mathematical Functions

ABS absolute value

AINT truncation (also TRUNC)

ALOG natural logarithm (also LN or LOG)

ALOG10 base 10 logarithm (also LG10 or LOG10)

AMOD remainder of division (also MOD)

EXP exponentiation (base e)

FEQ compares two floating point numbers within a tolerance

RAND random uniform number (0-1) (also RANF)

REAL4 returns the REAL*4 value of a REAL*8 number

RND rounding

SIGN transfer of sign

SQRT square root

TRUNC truncates least significant digits

homecontents start chapter top of pagebottom of pagenext page index

Argument List Functions

CNT count the number of arguments that are not missing

FST return the first argument that is not missing

LST return the last argument that is not missing

MAX return the largest argument that is not missing

MEAN compute the mean of the arguments that are not missing

MIN return the smallest argument that is not missing

STDEV compute the standard deviation of non missing values

SUM compute the sum of all arguments that are not missing

homecontents start chapter top of pagebottom of pagenext page index

Across Record Functions

The "across records" functions may only appear in PROCESS REC or PROCESS ROW blocks . They compute a result based on a single variable in each record or row processed in the PROCESS REC or PROCESS ROW block. They ignore values that are missing or undefined. Records that contain missing or undefined values are not counted nor are they used in the calculation of averages. Some of these functions can be used with string values, others do not apply to strings. If a function returns a string (e.g. as a maximum), a maximum of 32 characters are returned.
If the PROCESS RECORD command includes the CASEFUNR keyword then the statistics will be calculated over all records in all cases.
CNTR,FSTR,LSTR,MAXR,MINR,CNT,FST,LST,MAX,MIN can all be used with strings. MEANR,STDEVR,SUMR,AMOD,MEAN,STDVEV,SUM are only relevant to numeric values.

CNTR counts the number of times the variable occurs.

FSTR returns the first value processed.

LSTR returns the last value processed

MAXR returns the largest value processed

MEANR computes the average value (SUMR / CNTR)

MINR returns the smallest value

STDEVR computes the standard deviation

SUMR computes the sum of values

homecontents start chapter top of pagebottom of pagenext page index

Date and Time Functions

CDATE converts a date string to a date integer

CTIME converts a time string to a time integer

DATEC converts a date integer to a date string

DATET returns the current date and time as a string

DTTOTS takes a date and a time integer and returns a Timestamp as a real*8 value

JULC converts a date integer to a date string

JULN converts day, month, and year to a date integer

NOW returns the current time as a time integer

TIME converts hours, minutes, and seconds to a time integer

TIMEC converts a time integer to a time string

TODAY returns current date as a date integer

TSTODT takes a Timestamp and returns the date component as an integer

TSTOTM takes a Timestamp and returns the time component as an integer

homecontents start chapter top of pagebottom of pagenext page index

Global Functions

DGLOBAL Deletes a global variable

DSN Returns a full filename associated with an attribute

GLOBALN Assigns a numeric value to a global variable

GLOBALS Assigns a string value to a global variable

NARG Returns a numeric argument from run parameter list

NGLOBAL Returns the value of a global numeric variable

SARG Returns a string argument from run parameter list

SGLOBAL Returns the value of a global string variable

homecontents start chapter top of pagebottom of pagenext page index

String Functions

CAPITAL Capitalises the first letter of each word in string

CATINT Returns an integer value of a categorical variable

CATSTR Returns a string value of a categorical variable

CENTER Returns a centred string

CHAR Returns the character with the numeric internal value

CHARHEX Converts a character or character string into a hex representation of the character codes.

COMMA Separates thousands by inserting commas in a numeric string

EDIT Applies editing template to a data string

FILL Replaces blanks in string

FORMAT Converts a number to a string

HEXCHAR Converts a hex representation of a character string into the ASCII characters.

ICHAR Returns the numeric internal value of a character

LEN Returns the string length in characters

LOWER Converts all characters in string to lower case

NUMBR Converts a string to a number

PACK Returns the string with compressed blanks

PAD Pads a string with character to specified length

PATTERN Returns whether a pattern is found in a string

PFORMAT Converts a number to a formatted string

PICTURE Validates a string by comparing to a picture

REGEXP Searches a string for a substring specified by a regular expression

REGREP Searches a string for a substring specified by a regular expression and replaces it according to a second regular expression

REPLACE Replaces substrings with a specified string

REVERSE Returns a string spelled backwards

SBST Returns a substring of a string

SGET Returns the value of a string variable

SPREAD Returns a string with single blanks between characters

SPUT Stores string value in string variable

SRST Searches for a substring

SUBSTR Returns a substring of a string

TRIM Trims trailing blanks from a string

TRIML Deletes blanks from the left

TRIMLR Deletes blanks from the left and the right

TRIMR Deletes blanks from the right

UPPER Converts all characters of string to upper case

VARGET Gets value from string variable where variable name is an expression.

VARPUT Puts value into string variable where variable name is an expression.

homecontents start chapter top of pagebottom of pagenext page index

Concurrent Functions

CASELOCK Change lock type for and retry current CIR (also CIRLOCK)

RECLOCK Change lock type for and retry current record

SYSTEM(36) Whether current record is locked

SYSTEM(37) Whether current CIR is locked

SYSTEM(38) Whether a concurrent session using Master

SYSTEM(39) Returns the ordinal number of the default database. No Database returns 0

homecontents start chapter top of pagebottom of pagenext page index

Miscellaneous Functions

ARRDIMN Returns number of dimensions of a local array variable

ARRDIMST Returns start value of a dimension of a local array variable

ARRDIMSZ Returns number of entries of a dimension of a local array variable

CLIPAPP Adds text to the clipboard

CLIPGET Gets text from the clipboard

CLIPLINE Gets count of lines in the clipboard

CLIPSET Clears the clipboard and adds text to the clipboard

CRYPTKEY Sets the key for the encryption functions.

CURREC Returns the record type (number) for the record currently being processed.

DECRYPT Decrypts an encrypted string.

ENCRYPT Encrypts a string.

ERROR Displays a text message error box

EXISTS Indicates if variable exists (not missing or undefined)

EXTERN Invokes user-supplied external functions returning a numeric value. These must be in the EXTERN dll.

EXTERNS Invokes user-supplied external functions returning a string value. These must be in the EXTERN dll.

HELP Invokes the Help system

MISNUM Returns the "type" of missing or undefined value

MISSING Returns the original value for missing values

MSGTXT Returns the error message text for an error number

PROGRESS Controls the display of a progress bar

SEEK Sets a position on an open file.

SRCH Searches a table of values

STDNAME Checks a name and wraps curly brackets around if it is a non-standard name. SYSTEM Returns various system values such as CPU time used, whether a database access has been successful, etc.

YESNO Displays a text question box and returns response

homecontents start chapter top of pagebottom of pagenext page index

Session Functions

APPDIR Returns application directory

ATTRNAME Attribute n name (str)

BUFNAME Buffer n name

CPYFILE copies a file

CURDIR Returns current directory

DEFFAM Default family name

DEFMEM Default member name

DEFTFN Default tabfile name

DELDIR Deletes the named directory

DELFILE Deletes the named file

EDITNAME Editor name

FAMNAME Family n name

FILECNT Returns a count of files in named directory

FILEIN Browses for a file

FILEIS Returns if name exists as file or directory

FILEN Returns the nth file in directory

FILEOUT Browses for an output file

FILESTAT Returns various data about named file e.g. Date/time of creation/access, size of file, etc. Times and dates are in system format

FILETIME Returns various data about times of creation/access of file with times and dates converted to SIR formats

GETENV Gets a string environment variable value

GLOBNAME Gets the name of the nth global variable

LINES Lines remaining on output page

MAKEDIR Creates a directory

MEMCOUNT Count of members in family

MEMINFO Various information about a member

MEMNAME Name of nth member

NSUBDIR Name of nth subdirectory

OUTFNAME Name of current output file

PAGELEN Length of output page

PAGENO Current output page number

PAGEWID Width of output page

PROCFILE Procedure file attribute name

PROCNAME Procedure file filename

RACCESS Returns the read access level of user

RNMFILE Renames a file or directory

SETDIR Sets current directory

SETRC Sets a return code

SIRUSER Sets/returns the current user name

SUBDIR Concatenates a subdirectory to existing directory path in correct system specific manner

SYSTEM Returns various "system" status values

UPGET Gets User Preference (from INI file)

UPSET Sets User Preference (in INI file)

WACCESS Returns the write access level of user

WINCNT Returns the number of lines in the output window

WINLIN Returns the nth line from the output window

WINMOVE Moves and resizes the main window

WINPOS Moves to line in output window

WINSELL Returns selected line from output window

WINSELP Returns position in line selected from output window

homecontents start chapter top of pagebottom of pagenext page index

Schema & Database Functions

COUNT Number of records of a given type in the current case

DATEMAP Returns the date format (map) of a date variable

DBINDN Name of nth index on default database

DBINDR Number of record type indexed

DBINDS Number of indexes on default database

DBINDT Name of the nth variable in index followed by either ASC or DESC and UPPER if uppercase index

DBINDU Returns 1 if index is unique

DBINDV Number of variables in index

DBNAME Name of the nth database

DBTYPE Returns database type, case or caseless

JOUFLAG Returns whether journaling is on for default database

KEYNAME Returns name of a record type key field

KEYORDER Returns sort order ("A" or "D") of a key field

MAXRECS Returns the maximum allowed number of a particular record type

MISS Returns the original (string) for missing values (0 - 3) for a variable

MKEYSIZE Returns the size of the largest record key in the database

MRECSIZE Returns size of the largest record in the database

NKEYS Returns the number of key fields for a record type

NLABELS Synonym for NVALLAB. Returns the number of variable value labels defined for a variable

NMAX Returns the maximum value of a numeric variable range

NMIN Returns the minimum value of a numeric variable range

NOFCASES Returns the maximum number of cases for the database

NRECS Returns the maximum number of record types for the database

NUMCASES Returns the number of cases in the database

NUMRECS Returns the number of records of a given type in the database

NVALID Returns the number of defined valid values for a variable

NVALLAB Returns the number of variable value labels defined for a variable

NVARDOC Returns the number of lines of variable documentation defined for a variable

NVARS Returns the number of variables for the specified record type

NVARSC Returns the number of variables including common vars for the specified record type

NVVAL Returns the nth valid value of a numeric variable

RECDOC Returns the nth line of documentation for a record or database

RECDOCN Returns the number of lines of documentation for a record

RECLEVEL Returns the update level at which a record was last written to database

RECNAME Returns the name of the record type

RECNUM Returns the number of the record name

RECSIZE Returns the record size of a specified record type

RKEYSIZE Returns the key size of a specified record type

RRECSEC Returns the read security level of a record type

RVARSEC Returns the read security level of a variable

SMAX Returns the maximum value of a string variable range

SMIN Returns the minimum value of a string variable range

STATTYPE Returns whether a numeric variable is defined as observation, control or neither

SVVAL Returns the nth defined string valid value of a variable

TIMEMAP Returns the time format (map) string format of a time variable

UPDLEVEL Returns the current update level of database

VALIDATE Validates a value of a database variable against schema

VALLAB Returns the value label for the current value of a variable

VALLABSC Returns the value label for a specified value of a variable

VALLABSN Returns the nth value label of a variable

VALLABSP Returns the number (nth) of the value label associated with a specified value of a variable.

VALLABSV Returns a string that is the nth value associated with value labels of a variable.

VARLAB Returns the variable label for a variable (up to 78 characters)

VARLABSC Returns the variable label of a specified variable (up to 78 characters)

VARDOCSN Returns the nth line of variable documentation of a specified variable

VARNAME Returns the name of the variable using counts excluding common vars.

VARNAMEC Returns the name of the variable using counts including common vars.

VARPOSIT Returns the input position of the variable

VARTYPE Returns the storage type of a variable (string or numeric)

VFORMAT Returns a string representing the variable input format

VSCALE Returns the scaling factor for a scaled integer

VSCHFMT Returns the variable input output format as shown in the schema DATA LIST

VTYPE Returns the SIR data type of a variable (7 types)

VXLEN Returns the number of characters required to display the variable

WRECSEC Returns the write security level of a record type

WVARSEC Returns the write security level of a variable

homecontents start chapter top of pagebottom of pagenext page index

Tabfile & Table Functions

TABINDN Index name of nth index

TABINDS Number of indexes on nth table

TABINDT Variable name and sequence of nth variable on index

TABINDU If nth index is unique

TABINDV Number of variables in nth index

TABNAME Name of nth table

TABRECS Number of rows on nth table

TABVARS Number of cols (variables) in nth table

TABVINFN Various numeric data about column

TABVINFS Various string data about column

TABVNAME Column name

TABVRANG Value of valid/missing range for column

TABVTYPE Column type

TABVVALI Validates table column

TABVVLAB Value label for table column

TABVVVAL Value label value for table column

TFACCESS Access a(uto),r(ead) w(rite) of nth tabfile

TFATTR Internal attribute name of nth tabfile

TFCOUNT Number of connected tabfiles

TFFILE Filename of nth tabfile

TFGRNAME Group name of nth tabfile

TFGRPW Group password of nth tabfile

TFJNNAME Journal name of nth tabfile

TFNAME Name of nth tabfile

TFTABS Number of tables on nth tabfile

TFUSNAME User name of nth tabfile

TFUSPW User password of nth tabfile

homecontents start chapter top of pagebottom of pagenext page index

Read/Write Functions

NGET Gets the value of a numeric variable

NPUT Stores a value in a numeric variable

NREAD Pops up a box on the screen with a prompt and returns a number from the user

SGET Gets the value of a string variable

SPUT Stores a value in a string variable

SREAD Pops up a box on the screen with a prompt and returns a string from the user

TWRITE Writes a string to the scrolled output window

homecontents start chapter top of pagebottom of pagenext page index

Dialog & Menu Functions

BRANCH Adds a branch to the tree at a particular place.

BRANCHD Deletes a branch from the tree.

BRANCHN Returns id of nth branch.

FINDITEM Search list for text

GETBTNH Returns the height of button control

GETCHCH Returns the height of choice control

GETCHKH Returns the height of check control

GETFLT Gets floating point as per GETTXT

GETFOCUS Returns id of control with focus

GETICHK Returns check or radio state

GETIFLT Returns floating point from a list

GETIINT Returns integer of item from a list

GETINT Gets integer as per GETTXT. 0 if not integer

GETITXT Returns text of item from a list

GETLBLH Returns the height of labels

GETLTXT Gets the text from a line in a multi-line text control

GETMAXCH Returns the height of the maximum single line control

GETMCHK Tests the state of a menu or toolbar item

GETMSEL Returns pos of nth selected item from multiple selection

GETNITEM Returns number of items in choice or list

GETNLINE Gets number of lines in multi-line text control

GETNSEL Returns number of items selected in multiple selection

GETPOS Returns pos of current selection in list or choice or keyboard focus in multiple selection

GETRADH Returns the height of radio control

GETRSTEP Returns the size of the row step

GETTXT Gets text from edit and from highlighted item in choice or list. (Gets label text from label, button, check and radio)

GETTXTH Returns the height of text control

IDSTATUS Returns the status of a control

NBRANCH Returns number of braches in a tree below a point.

SCROLLAT Gets a position in a GUI scrollable item

SCROLLTO Sets a position in a GUI scrollable item

SETPOS Sets a position in a GUI multi-line item

SETRANGE Sets minimum/maximum values in a GUI slider/spin/progress control. Sets the maximum number of characters allowed in an edit or text field (ignoring the minimum parameter).

Dialog Editor

DITEM... There are a number of functions that return information about items on a DEDIT dialog, that is a dialog used for screen painting. These functions are all named DITEMxxx.

homecontents start chapter top of pagebottom of pagenext page index

Client/Server Functions

There are three servers in SIR/XS and a client program may be communicating with one of those or with an ODBC server from another software supplier. The three SIR/XS servers are Master that controls concurrent updates, the SQLServer, that acts as an ODBC server for other packages, and the PQLServer that is a server that can run any SIR/XS processes requested by a client. Most communication with master is done transparently i.e. it does not require specific functions, however there are a set of functions that can be used to administer master if required.

Client Functions to administer Master

DELMCLID Deletes the client from Master.

GETAKL Returns the client AutoKill Limit from Master.

GETDFC Returns the difference file copy interval from Master.

GETMCADD Returns the client tcp/ip address from Master.

GETMCLID Returns the nth client id from Master.

GETMCLST Returns the time of last message for nth client from Master.

GETMCON Returns the time of log on for nth client from Master.

GETMDBN Returns the name for nth database from Master.

SETAKL Sets the AutoKill time Limit for master clients.

SETDFC Sets the difference file copy interval for Master.

Client Functions to SQLServer/ODBC

BINDPARM Binds an SQLServer/ODBC parameter.

COLCOUNT Returns a count of columns created by the execute

COLLABEL Returns the label of a specific column created by the execute

COLLEN Returns the length of a specific string column created by the execute

COLNAME Returns the name of a specific column created by the execute

COLTYPE Returns the type of a specific column created by the execute

COLVALN Returns the numeric value of a specific column created by the execute

COLVALS Returns the string value of a specific column created by the execute

GETERR Returns the oldest error posted for this application and deletes the message.

NEXTROW Steps through the rows one at a time

ODBCTABS Produce list of tables on the data source

ODBCCOLS Produce list of columns from the named table on the data source

ROWCOUNT Count of rows created by the execute

Client Functions to PQLServer

SERADMIN Various server administration capabilities (returning numeric values)

SERADMIS Various server administration capabilities (returning string values)

SEREXEC Instructs server to execute previously sent commands

SERGET Gets a line of output from server

SERLINES Asks server how many lines of output are left

SERLOG Logs on to the server

SERSEND Sends a string to the server

SERSENDB Sends a buffer to the server

SERTEST Asks server if execution has completed

PQLServer Functions

(These have no effect if used in a program that is not running on the server)
SERNOOUT Suppresses server output

SERWRITE Writes a line of output from server

homecontents start chapter top of pagebottom of pagenext page index

CGI Functions

Buffer functions return number of lines. All parameters are string expressions.

CGIBUFPN Get buffer of value of parameter

CGIBUFPN Get buffer of value of parameter

CGIBUFSV Get buffer of value of server variable

CGIVARPN Get parameter value

CGIVARSV Get server variable value

homecontents start chapter top of pagebottom of pagenext page index

Alphabetic List of All Functions

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

ABS

num = ABS( X )

Returns the absolute value of X.

ACOS

num = ACOS( X )

Returns the arc cosine of X. The result is in the range 0 to PI radians. Values of X outside the range -1<X>1 return undefined.

AINT

num = AINT( X [,n] )

Returns the truncated value of X. If n is omitted or 0, truncates to an integer value. If n is specified, truncates to that power of 10. e.g. AINT (1266,2) truncates to 1200, AINT(1.266,-2) truncates to 1.26.

ALOG

num = ALOG( X )

Returns the natural logarithm (base e) of X. Values less than or equal to zero return undefined.

ALOG10

num = ALOG10( X )

Returns the base 10 logarithm of X. Values less than or equal to zero return undefined.

AMOD

num = AMOD(X , Y)

Returns the remainder of X divided by Y. If Y is zero, undefined is returned.

APPDIR

str = APPDIR(0)

Returns SIR/XS application directory. That is the directory where the SIR executables are installed.

ARCOS

num = ARCOS( X )

See ACOS function.

ARRDIMN

num = ARRDIMN(array_name_exp)

Returns the number of dimensions for specified local array variable.

ARRDIMST

num = ARRDIMST(array_name_exp,dim)

Returns the start value for the specified dimension for specified local array variable (normally 1 unless array specified to start at different value).

ARRDIMSZ

num = ARRDIMSZ(array_name_exp,dim)

Returns the size of the specified dimension for specified local array variable.

ARCOS

num = ARCOS( X )

See ACOS function.

ARSIN

num = ARSIN( X )

See ASIN function.

ASIN

num = ASIN( X )

Returns the arc sine of X. The result is in the range -pi/2 to +pi/2 radians. Values outside the range-1<X>1 return undefined.

ATAN

num = ATAN( X )

Returns the arctangent of X. The result is in the range -pi/2 to +pi/2 radians.

ATTRNAME

str = ATTRNAME(n)

Returns the nth Attribute name (SYSTEM(52) = attribute count).

BINDPARM

num = BINDPARM(conid,statid,parmno,num_exp)

Binds an sqlserver/odbc parameter.

BRANCH

num = BRANCH(control_id,parent_id,node_id,text)

Creates a new node under the given parent node in the tree control.

BRANCHD

num = BRANCHD(control_id,node)

Deletes a branch in the tree control given by the node.

BRANCHN

num = BRANCHN(control_id,node,n)

Returns id of nth child of the given node.

BUFNAME

str = BUFNAME(n)

Returns the nth Buffer name (SYSTEM(56) = buffer count).

CAPITAL

str = CAPITAL( str )

Capitalises the first alphabetic character of the string and the first alphabetic character following a blank. All other characters remain unedited. For example:

NAME = 'this is the first day of the week'
NAME = CAPITAL(NAME)
Returns: This Is The First Day Of The Week

CASELOCK

num = CASELOCK(locktype)

Changes the lock type for the current Case (CIR) and attempts to read the current CIR from the database. See SYSTEM(37) function to determine if current CIR is locked. The locktype codes are (any other values set concurrent read):

1 = Exclusive
2 = Concurrent Read
3 = Concurrent Write
4 = Protected Read
5 = Protected Write
6 = Exclusive

CATINT

num = CATINT(A, B)

Returns an integer corresponding to the category in categorical variable A that B matches. A and B may be variables, string constants or expressions. Returns a zero if no match is found.

CATSTR

str = CATSTR(A)

Returns a string corresponding to the current value of the specified categorical variable.

CDATE

num = CDATE(X, date format)

Returns the date integer equivalent to the date string X that may be a string constant, variable or expression. The date format is a string expression. See date formats for a complete description. If a date earlier than October 15, 1582 is specified, undefined is returned. Example:
INTDATE = CDATE('6/3/7', 'MM/DD/YY')

CENTER

str = CENTER(X , strY)

Returns string strY centred in a string X characters in length. Example:

RESULT = CENTER(9, 'ABC')

returns:  "   ABC   ".

CGIBUFPN

n = CGIBUFPN(buf,pn)

Used when dealing with CGI from webserver. Puts value of CGI parameter into named buffer. Returns number of lines. Parameters are string expressions.

CGIBUFSV

n = CGIBUFSV(buf,sv)

Used when dealing with CGI from webserver. Puts value of server variable into named buffer. Returns number of lines. Parameters are string expressions.

CGIVARPN

str = CGIVARPN(pn)

Used when dealing with CGI from webserver. Returns named parameter value in string variable. Parameter name is a string expression.

CGIVARSV

str = CGIVARSV(sv)

Used when dealing with CGI from webserver. Returns named server variable value in string variable. Server variable name is a string expression.

CHAR

str = CHAR(N)

Returns a single character. The character returned is the character with the internal value of N. (See the ICHAR function.) If N is larger than 255, N is divided by 256 and the remainder is taken. This gives the set of standard characters. If N is missing, a null string is returned (length 0).

CHARHEX

hexstr = CHARHEX(str)

Returns a hex representation of the input string. Each character is converted to its ASCII value then that is converted to hexadecimal.
COMPUTE HEX1 = CHARHEX("Hello World")

HEXCHAR

str = HEXCHAR(hexstr)

Converts the hexadecimal codes in the input string to their associated ASCII characters.
COMPUTE STR = HEXCHAR("48656C6C6F20576F726C64")

CIRLOCK

See CASELOCK function

CLIPAPP

num = CLIPAPP(text)

Appends text to the clipboard (the place holding text you cut and paste).

CLIPGET

str = CLIPGET(line)

Gets a line of text from the clipboard (the place holding text you cut and paste).

CLIPLINE

num = CLIPLINE(dummy)

Gets number of lines of text currently in the clipboard (the place holding text you cut and paste).

CLIPSET

num = CLIPSET(text)

Clears the clipboard and puts text into the clipboard (the place holding text you cut and paste).

CNT

num = CNT(X1 , X,..... , Xn)

Counts the number of values in a list that exist (not missing or undefined). There may be up to 128 variables in the list. Returns zero (0) if no values exist.

CNTR

num = CNTR( X )

Returns the number of values of X found during a PROCESS REC or PROCESS ROWS loop that are not missing or undefined. Returns zero if all values are missing or undefined.

COLCOUNT

num = COLCOUNT (conid,statid)

Client/Server function. Returns a count of columns created by the execute.

COLLABEL

str = COLLABEL (conid,statid,colno)

Client/Server function. Returns the label of a specific column created by the execute.

COLLEN

num = COLLEN (conid,statid,colno)

Client/Server function. Returns the length of a specific string column created by the execute.

COLNAME

str = COLNAME (conid,statid,colno)

Client/Server function. Returns the name of a specific column created by the execute.

COLTYPE

num = COLTYPE (conid,statid,colno)

Client/Server function. Returns the type of a specific column created by the execute. This is one of the following:
1 = String
2 = Timestamp string
3 = Date
4 = Time
5 = Integer
6 = R4
7 = R8
8 = Scaled Integer

A timestamp string is a formatted 18 byte string containing a combination date/time as follows:
YYYYMMDDHHMMSStttt where YYYY is the year, MM is the month, DD is the day number, HH is the 24 hour number, MM is the minutes, SS is the seconds and tttt is the thousandths of a second. Any of these components may be zero.

COLVALN

num = COLVALN (conid,statid,rowno,colno)

Client/Server function. Returns the numeric value of a specific column created by the execute. This does not have to be the same type as returned by COLTYPE. e.g. Integers can be assigned to a real.

COLVALS

str = COLVALS (conid,statid,rowno,colno)

Client/Server function. Returns the string value of a specific column created by the execute.

COMMA

str = COMMA( str )

Places a comma between every third digit to the left of a decimal point (actual or implied) in a string with a numeric form. For example, COMMA ('4500000') returns '4,500,000'.

COS

num = COS( X )

Returns the trigonometric cosine of X, where X is measured in radians.

CPYFILE

num = CPYFILE (oldname_str,newname_str)

Copies a file from oldname_str to newname_str. Returns 0 for a success, -1 for a problem opening the source file, -2 for a problem opening the target file and -3 for errors during the copy.

CRYPTKEY

num = CRYPTKEY(encryption_key)

Sets the key used by the encryption functions ENCRYPT/DECRYPT. The key is a 256 bit (32 character) string. The key only needs to be set once in a session that uses the encryption functions. If the key is not set, the encryption functions use a key of all blanks.

The specified key is an expression. i.e. a variable name or a string in quotes.

COUNT

num = COUNT( X )

Returns the number of records for record type X within the current case.

CTIME

num = CTIME(X , time format)

Returns the number of seconds from midnight to the given time.
Specify a time string X and a time format. See
time formats for a complete description. If the hour, minute or second field is omitted, they default to zero. For example:

WINTIME = CTIME('18:36:45', 'HH:MM:SS')

CURDIR

str = CURDIR( 0 )

Returns the current directory.

CURREC

num = CURREC( 0 )

Returns the record type number for the record currently being processed in a PROCESS RECORD or PROCESS DATA block.

DATEC

str = DATEC(X , date format)

Returns a date string equivalent to the date integer X formatted according to the date format. The format is a string constant. See date formats for a complete description. For example, DATEC(XBEG, 'Www, Mmm DDth, YYYY') produces a result such as "Thu, May 25th, 2007

DATEMAP

str = DATEMAP (rtnum, varname_exp)

Returns a string with the date format (map) of the specified date variable. If the record number (rtnum) is negative, the function applies to a summary variable; if rtnum is one more than the maximum record count (i.e. NRECS(0)+1) then this applies to a standard variable.
The varname is an expression. If this is a constant, enclose the name in single quotes. Undefined is returned if the variable is unknown or is not a date variable. For example, if the variable BIRTHDAY in record type one has the date format "MM DD YY" defined in the schema, then DATESTR equals "MM DD YY".

DATESTR = DATEMAP (1, 'BIRTHDAY')

DATET

str = DATET(N1 , N)

Returns a 27-character string containing the current date and time. The string is composed of the following substrings:

Date
  1- 3 Day of  the week  (SUN,MON,etc.)
  4- 5 Comma and blank
  6- 8 Month of the year  (JAN,FEB,etc.)
     9 Blank
 10-11 Day of the month
 12-13 Comma and blank
 14-17 Year
 18-19 Comma and blank

Time
 20-21 Hour (1 to 12)
    22 Period
 23-24 Minutes
    25 Blank
 26-27 AM or PM

The two arguments N1 and N are constants in the range 1 to 27 that select a substring of the 27-character string. For example, suppose the current date is May 25, 2000, and the time is 1:05 PM; the day is Thursday.

PROGRAM
TODATE  = DATET (6, 17)
NOWTIME = DATET(20, 27)
WKDAY   = DATET(1, 3)
WRITE TODATE NOWTIME WKDAY
END PROGRAM

OUTPUT:  MAY 25, 2000 01.05 PM THU

DTTOTS

real*8 = DTTOTS (date,time)

Takes a date and time integer and returns a timestamp. A timestamp is a real*8 representation and is the number of seconds since the start of the SIR/XS calendar. You can do calculations between timestamps but the individual date and time components must be extracted using the TSTODT and TSTOTM functions before using any other date and time functions e.g. for print formatting.

DBINDN

str = DBINDN (index)

Returns name of nth index.

DBINDR

n = DBINDR (index)

Returns number of record type indexed by nth index.

DBINDS

n = DBINDS (dummy)

Returns number of indexes on default database.

DBINDT

str = DBINDT (index,varno)

Name of nth variable in nth index plus ASC/DESC and UPPER.

DBINDU

n = DBINDU (index)

Returns 1 if the index is unique or 0 if the index is not unique.

DBINDV

n = DBINDV (index)

Returns number of variables in nth index.

DBNAME

str = DBNAME (n)

Returns a string with the name of the nth attached database. If n is zero, returns the name of the default database.

DBTYPE

num = DBTYPE (dummy)

Returns 1 if a case structured database or 0 if caseless.

DECRYPT

str = DECRYPT(string,length)

Decrypts an encrypted string. Set the encryption key (using CRYPTKEY prior to the first invocation of this function. Obviously the key must be the same as was used to encrypt the string.

DEFFAM

str = DEFFAM(0)

Returns the default family name.

DEFMEM

str = DEFMEM(0)

Returns the default member name.

DEFTFN

str = DEFTFN(0)

Returns the default tabfile name.

DELDIR

n = DELDIR(dir_name)

Deletes the named directory. Returns 0 for success.

DELFILE

n = DELFILE(file_name)

Deletes the named file (use filename not attribute). Returns 0 for success.

DELMCLID

str = DELMCLID(id,password)

Deletes the client from master. Get the client id from GETMCLID. Specify a password as a string variable or string in quotes if the Master is started with a password.

DGLOBAL

num = DGLOBAL(string_exp)

Deletes a global. The string expression may be the global name enclosed in quotes or a string variable.

DITEM

DITEM...

The DITEM series of functions all pertain to the Dialog Editor used to construct screen painting applications.

DITEMCOL

num = DITEMCOL(n) Returns the column the nth DEDIT item is positioned at.

DITEMH

num = DITEMH(n) Returns the height of the nth DEDIT item.

DITEMID

num = DITEMID(n)Returns the id of the nth DEDIT item.

DITEMROW

num = DITEMROW(n) Returns the row the nth DEDIT item is positioned at.

DITEMS

num = DITEMS(0) Returns the number of items on DEDIT dialog.

DITEMSEL

num = DITEMSEL(0) Returns the number of items selected on DEDIT dialog.

DITEMSID

num = DITEMSID(n) Returns the id of the nth selected DEDIT item.

DITEMTXT

str = DITEMTXT(n) Returns the text of the nth DEDIT item.

DITEMTYP

num = DITEMTYP(n) Returns the type of control of the nth DEDIT item.

DITEMW

num = DITEMW(n) Returns the width of the nth DEDIT item.

DSN

str = DSN( string_exp )

Returns the operating system filename of an attribute. The attribute may be a variable or constant.

EDIT

output_str = EDIT( input_str,edit_str )

EDIT applies an edit string to data to produce the output. The edit string is made up of circumflexes ( ^ ), that represent a character of the input string, and any other characters to insert. Example:

PROGRAM
SSN = EDIT('123456789','^^^-^^-^^^^')
WRITE SSN
END PROGRAM

Output: 123-45-6789

EDITNAME

str = EDITNAME(0)

Returns the name of the current text editor.

ENCRYPT

str = ENCRYPT(string,length)

Encrypts a string. Set the encryption key (using CRYPTKEY) prior to the first invocation of this function.
The string is a SIR string and the encrypted string is also a normal SIR string but it should be noted that encryption may result in non-text characters and so encrypted strings should not be written to text files.
The encryption algorithm encrypts eight (8) characters at a time and any input string is padded with blanks so that the output is a correctly encrypted string. If you truncate this and save an encrypted string that is not a multiple of eight, the last few characters will not decrypt properly.

ERROR

num = ERROR( strX )

Displays an error box with the specified text and waits for acknowledgment.

EXISTS

num = EXISTS( X )

Returns 1 if X exists, 0 if X is missing or undefined. To test several numeric variables for existence, use the CNT function.

EXTERN

num = EXTERN ( X )

Invokes a user-supplied external function from the EXTERN dll. The function can take a numeric or string parameter and calls a different user function for each case. The extern.dll library supplied by SIR contains dummy functions which return zero.

EXTERNS

str = EXTERNS ( X )

Invokes a user-supplied external function from the EXTERN dll. The function can take a numeric or string parameter and calls a different user function for each case. The extern.dll library supplied by SIR contains dummy functions which return blank (a zero length string).

EXP

num = EXP( X )

Returns the value of e raised to the X power. e is the constant 2.71828.

FAMNAME

str = FAMNAME(n)

Returns the nth family name in the default procfile. (SYSTEM(57) = Count of families).

FEQ

str = FEQ(real1,real2,exponent)

Tests two floating point numbers for equality within a limit of accuracy. The function returns 0 if approximately equal, 1 if unequal. For example, if the exponent was -3, the numbers would be equal if within .001.

FILECNT

n = FILECNT(str)

Counts the files in the directory given by the string argument. The string must be a filename or mask. For example, specify a mask like '*.pql' for the count of those files with extension "pql" in the current directory.

FILEIN

str = FILEIN(filter,default_extension)

Displays a file browse box for user to choose existing file. Returns zero length string if user cancels.

FILEIS

n = FILEIS(file_name_string)

Tests if file exists. Returns -1 if name is a directory; 0 if no such name; 1 if file exists.

FILEN

str = FILEN(string,n)

Returns the nth file name in the directory given by the string argument. The string must be a filename or mask. For example, to list all files with extension "pql" in the current directory:

FOR N = 1,FILECNT("*.pql")
. WRITE [FILEN("*.pql",N)
END FOR

FILEOUT

str = FILEOUT(filter,default_extension)

Displays a file browse box for user to choose output file. Returns zero length string if user cancels.

FILESTAT

n = FILESTAT(filename_string,type_of_data)

Returns various system specific data about a named file.
Type of data
1 gid Numeric identifier of group that owns file (UNIX-specific)
2 st_atime Time of last access of file. (system date/time integer)
3 st_ctime Time of creation of file. (system date/time integer)
4 st_dev Drive number of the disk containing the file (same as st_rdev).
5 st_ino Number of the information node (the inode) for the file (UNIX-specific).
6 st_mode Bit mask for file-mode information. The _S_IFDIR bit is set if path specifies a directory; the _S_IFREG bit is set if path specifies an ordinary file or a device. User read/write bits are set according to the file's permission mode; user execute bits are set according to the filename extension.
7 st_mtime Time of last modification of file. (system date/time integer)
8 st_nlink Always 1 on non-NTFS file systems.
9 st_rdev Drive number of the disk containing the file (same as st_dev).
10 st_size Size of the file in bytes; (Can exceed I4 in size)
11 uid Numeric identifier of user who owns file (UNIX-specific)

FILETIME

n = FILETIME(filename_string,type_of_data)

Returns SIR times or dates about a file
Type of data
1 Time of last access of file. (SIR time integer)
2 Date of last access of file. (SIR date integer)
3 Time of creation of file. (SIR time integer)
4 Date of creation of file. (SIR date integer)
5 Time of last modification of file. (SIR time integer)
6 Date of last modification of file. (SIR date integer)

FILL

str = FILL(strX , strY)

Replaces all blank characters in strX with the first character of string argument strY. The length of strX does not change. For example:

RESULT = FILL ('  $100.00', '*')
returns  "**$100.00"

FINDITEM

num = FINDITEM (id,pos,txt)

Search dialog choice or list for text and return position. Can start from partway through.

FORMAT

str = FORMAT( X [,W [,D ]] )

Converts X to a string. FORMAT( X ) returns free-field format as wide as necessary to fit the value. FORMAT(X,W) returns a free field format of width W. FORMAT(X,W,D) returns a number with D decimal places in width W. X, W and D, can be variables, constants or expressions. W, if specified, must be greater than or equal to zero. D, if specified, can be -1 or greater than or equal to zero. -1 is equivalent to not specifying a value (free field format). If D is specified, W must be greater than D. For example:

STR = FORMAT (1.3)       returns  '1.3'
STR = FORMAT (1.3, 4)    returns  ' 1.3'
STR = FORMAT (1.3, 5, 2) returns  ' 1.30'

FST

num|str = FST( X1, X.., Xn )

Returns the first value in the list of up to 128 variables that is not missing or undefined.

FSTR

num|str = FSTR( X )

Returns the first value of X encountered during a PROCESS REC or PROCESS ROWS loop that is not missing or undefined.

GETBTNH

num = GETBTNH (dummy)

Returns the height of button control (for positioning).

GETCHCH

num = GETCHCH (dummy)

Returns the height of choice control( for positioning).

GETCHKH

num = GETCHKH (dummy)

Returns the height of check control( for positioning).

GETAKL

n = GETAKL(0)

Returns automatic disconnection timeout for idle clients (from Master) in minutes.

GETDFC

n = GETDFC(0)

Returns time (from Master) of difference file copy interval in minutes.

GETENV

str = GETENV(variable_str)

Returns the value of the named environment variable.
COMPUTE OSPATH = GETENV('PATH')

GETERR

str = GETERR (dummy)

Client/server function. Returns the oldest error posted for this application and deletes the message. Returns a zero length string if no messages. Errors are not specific to a connection or statement, rather they are posted for this instance of SIR/XS and, if errors are not retrieved when an error condition occurs, multiple error messages may be waiting. One logical error may also give rise to multiple error messages from the server.

GETFLT

dbl = GETFLT (id)

Gets floating point as per GETTXT. Returns 0.0 if not f.p. number.

GETFOCUS

num = GETFOCUS (0)

Returns id of control with focus.

GETICHK

num = GETICHK (id)

Returns check or radio state.

GETIFLT

dbl = GETIFLT (id,pos)

Returns floating point from a list.

GETIINT

int = GETIINT (id,pos)

Returns integer of item from a list.

GETINT

int = GETINT (id)

Gets integer as per GETTXT. 0 if not integer.

GETITXT

str = GETITXT (id,pos)

Returns text of item from a list.

GETLBLH

num = GETLBLH (dummy)

Returns the height of labels ( for positioning).

GETLTXT

str = GETLTXT (id,p)

Gets the text from a line in a multi-line text control.

GETMAXCH

num = GETMAXCH (dummy)

Returns the height of the maximum single line control ( for positioning).

GETMCADD

str = GETMCADD (id)

Returns tcp/ip address for client from master.

GETMCHK

num = GETMCHK (id)

Returns check state from menu item.

GETMCLID

n = GETMCLID (n)

Returns id for nth client from master.

GETMCLST

n = GETMCLST (n)

Returns time of last message for nth client from master.

GETMCON

n = GETMCON (n)

Returns time of log on for nth client from master.

GETMDBN

str = GETMDBN (n)

Returns name of nth database from master.

GETMSEL

num = GETMSEL (id,N)

Returns the position of the nth selected item from a single or multiple selection list. In the case of a single selection list then GETMSEL(id,1) is the same as GETPOS(id).

GETNITEM

num = GETNITEM (id)

Returns number of items in choice or list.

GETNLINE

num = GETNLINE (id)

Gets number of lines in multi-line text.

GETNSEL

num = GETNSEL (id)

Returns number of items selected in multiple selection or returns 1 for a single selection list.

GETPOS

num = GETPOS (id)

Returns pos of current selection in list or choice or keyboard focus in multiple selection.

GETRADH

num = GETRADH (dummy)

Returns the height of radio control (for positioning).

GETRSTEP

num = GETRSTEP (dummy)

Returns the size of the row step (for positioning).

GETTXT

str = GETTXT (id)

Gets text from edit and from highlighted item in choice or list. (Gets label text from label, button, check and radio).

GETTXTH

num = GETTXTH (dummy)

Returns the height of text control (for positioning).

GLOBALN

num = GLOBALN(globvar_exp , numeric_exp)

Assigns a numeric value to a global variable. The first argument is the name of the global variable, the second argument is the numeric expression (or variable name). For example: To assign the global variable RT the value 25.5:

COMPUTE Y = GLOBALN('RT', 25.5)

GLOBALS

num = GLOBALS(stringexp , stringexp)

Assigns a string value to a global variable. The first argument is the name of the global variable, the second argument is the string expression (or variable name). For example: To assign the global variable TEMP the value JOE SMITH:

COMPUTE Y = GLOBALS ('TEMP','JOE SMITH')
GLOBALN and GLOBALS return:

0 if the assignment was made.

-1 if the first argument is not a valid global variable name.

-2 if the second argument is missing.

Do not try to use the value of globals set by GLOBALN or GLOBALS for text substitution in the same program (by using the global variable name within angle brackets) because the functions work at execution time and text substitution happens at compile time.

GLOBNAME

str = GLOBNAME(n)

Returns the name of the nth global variable. (SYSTEM(53) = Global Count).

HELP

error = HELP( help page )

Invokes the HELP system, beginning with the specified help page. The page must be in html format in the help directory. The page name can contain directory names using forward slashes to delimit. Enclose the name in quotes. The system converts this to a file name prefixed with a path pointing to the help directory and suffixed with the file extension .htm. For example:

COMPUTE X = HELP ('visualpql/function/foreword')

ICHAR

num = ICHAR(C)

Returns a numeric value equivalent to the position in the character collating sequence of the first character in string C. The character collating sequence for a given computer is the set of numeric codes used for internal character representation (ASCII).

IDSTATUS

num = IDSTATUS(id)

Returns the status of a GUI element. -1 = the control does not exist; 0 = the control is disabled; 1 = the control is enabled.

JOUFLAG

num = JOUFLAG (dummy)

Returns whether journaling is on (1) or off (0) for the database.

JULC

str = JULC( X )

Converts a "date integer", X, into an 12-character string of the form 'MMM DD, YYYY'.

JULN

num = JULN(month,day,year)

Returns a "date integer" where the three numeric arguments are month, day and year. A "date integer" is the number of days since the start of the Gregorian calendar on October 15, 1582.
Years can be specified as various values. If a year of zero is specified, this year is used. If a year of less than 10 is specified, this decade is used. If a year between 10 and 99 is specified, the CENTYR parameter is used to determine the appropriate century to use. If a year between 100 and 999 is specified, then values greater than 583 are taken to be in the last millennium (1583 - 1999), values smaller than 583 are taken to be in the current millennium (2000+).
A value of undefined is returned if a date earlier than October 15, 1582 is specified. Because of leap years, this routine is only accurate for dates up to Dec 31 29999.
For example:

DURATION  =  JULN(4, 8, 0) - BEGINDAT
ENDPROJ = JUNL(TMON, TDAY, TYEAR)

KEYNAME

str = KEYNAME (rtnum, keynum)

Returns the name of the specified keyfield for the specified record type. RTNUM is the record number. KEYNUM is the number of the keyfield, i.e. 1 is the case id, 2 is the first key field in the record type, etc.

KEYORDER

str = KEYORDER (rtnum, varname_string)

Returns "A" or "D" for the sort order of the specified keyfield. The variable name argument is an expression.

LEN

num = LEN( strX )

Returns an integer value that is the length, in characters, of the string strX, leading and trailing blanks included.

LG10

num = L10( X )

See ALOG10 function.

LINES

num = LINES(filename)

Returns number of lines remaining on current page being written to a file.

LN

num = LN( X )

See ALOG function.

LOG

num = LOG( X )

See ALOG function.

LOG10

num = LOG10( X )

See ALOG10 function. (LG10 is also allowed.)

LOWER

str = LOWER( string )

Returns the string with all characters converted to lower case.

LST

num|str = LST(X1 , X ,....., Xn)

Returns the last value in the list of up to 128 variables that is not missing or undefined.

LSTR

num|str = LSTR( X )

Returns the last value of X encountered in a PROCESS REC or PROCESS ROWS loop that is not missing or undefined.

MAKEDIR

num = MAKEDIR(name)

Creates a new directory using the name. Returns -1 if the directory cannot be created.

MAX

num|str = MAX(X1 , X ,....., Xn)

Returns the maximum value in the list of up to 128 variables.

MAXR

num|str = MAXR( varname )

Returns the maximum value of the specified variable encountered during a PROCESS REC or PROCESS ROWS loop that is not missing or undefined.

MAXRECS

num = MAXRECS( rectype )

Returns the maximum number of records allowed for this record type.

MEAN

num = MEAN(X1 , X ,....., Xn)

Returns the mean (arithmetic average), of the values within the list that are not missing or undefined. The maximum number of variables allowed in the argument list is 128.

MEANR

num = MEANR( varname )

Returns the mean (arithmetic average), for the values of the specified variable encountered during a PROCESS REC or PROCESS ROWS loop that are not missing or undefined.

MEMCOUNT

num = MEMCOUNT(famname)

Returns the count of members in the named family of the default procfile.

MEMINFO

num = MEMINFO(member_name,info_type)

Returns information about the named member. The member name can include the :type qualifier. The function returns missing if the member does not exist.

The INFOTYPES are:

  1. TYPE - returns 1 for :T; 2 for :E; 4 for :O ; 8 for :V
    If the member type is not given in the member name, and there is more than one type for this name then the sum of the types is returned. e.g. SYSPROC.MENU.ABOUT is a :t and an :o so
    MEMINFO ("SYSPROC.MENU.ABOUT",1) returns 5
    MEMINFO ("SYSPROC.MENU.ABOUT:O",1) returns 4
    MEMINFO ("SYSPROC.MENU.ABOUT:E",1) returns missing.
  2. SECURITY returns 0 (no password), 1 (password & public), 2 (password & not public).
  3. LENGTH returns the number of bytes in the member (note there is some condensing going on here).
  4. CREATE DATE returns the creation date as a Julian date integer.
  5. CREATE TIME returns the creation time as number of seconds since midnight.
  6. MOD DATE returns the last modification date as a Julian date integer.
  7. MOD TIME returns the last modification time as number of seconds since midnight.
  8. STATUS (mainly for :e :o and :v types):
    0 - good
    -1 incorrect version of SIR
    -2 Default database not connected
    -3 Database creation date/time mismatch
    -4 incorrect PQL Retrieval version
    -5 CIR/Record Schema level mismatch.

MEMNAME

str = MEMNAME(famname,n)

Returns the name of the nth members in the named family of the default procfile.

MIN

num|str = MIN(X1 , X ,..., Xn)

Returns the minimum value in the list of up to 128 variables.

MINR

num|str = MINR( varname )

Returns the minimum value of the specified variable encountered during a PROCESS REC or PROCESS ROWS loop that is not missing or undefined.

MISNUM

num = MISNUM( X )

If X is undefined, 0 is returned. If X is missing, the missing type is returned (1 to 3). If X is neither missing nor undefined, undefined is returned. X may be a numeric or string variable.

MISS

str = MISS (rtnum, varname_str , n)

Returns the original value for undefined and first, second and third missing values (as a string), where n is 0, 1, 2, or 3. If the record number (rtnum) is negative, the function applies to a summary variable; if rtnum is one more than the maximum record count (i.e. NRECS(0)+1) then this applies to a standard variable.

MISSING

num|str = MISSING(varname)

Returns the original value of a variable if it is missing, otherwise undefined is returned. If the variable is a time, date, or categorical integer, the original string value is returned. If the variable is an integer or floating point variable, the original numeric value is returned. If the argument is not a single variable name, undefined is returned.

MKEYSIZE

num = MKEYSIZE ( dummy )

Returns the maximum key size in bytes for the database. The key for a record is comprised of the case identifier (in a case structured database), the record type number, and the keyfields defined for the record type (if any). Refer to the schema definition command MAX KEY SIZE for more information about maximum key size.

MOD

See AMOD function.

MRECSIZE

num = MRECSIZE (dummy)

Returns the size of the largest record type in the database. Size is expressed in the number of double words that are equivalent to eight characters.

MSGTXT

str = MSGTXT (num)

Returns the text of the error or warning massage given by the number num.

NARG

num = NARG( num )

Returns numeric arguments from the command parameter list. (String parameters are retrieved with the SARG function.)

The argument is the position of the parameter in the list. An argument value of zero returns the number of parameters in the list. If the argument is greater than the number of parameters in the parameter list or the argument is a string, undefined is returned. For example, to return the value of the third argument of the parameter list (which must be numeric):

COMPUTE ARG4 = NARG(3)

NBRANCH

num = NBRANCH (control_id,node)

Returns number of branches of the given node in a tree control.

NEXTROW

num = NEXTROW (conid,statid)

Client/server function. Steps through the rows one at a time. This must be issued before getting data for the first row. Returns the row number or zero if no more rows.

NGET

num = NGET( varname_str )

Returns the value of the specified numeric variable. The variable name is specified as a string variable, quoted string constant or string expression whose value is the name of a common, record or program variable.

NGLOBAL

num = NGLOBAL( C )

Returns the value of numeric global parameters. C is a character variable, constant or expression whose value specifies the name of the global parameter. If C is not a defined global parameter, undefined is returned. String global parameters are retrieved with SGLOBAL. For example, to set the variable NVAL to the value of global parameter RACETIME:

COMPUTE NVAL = NGLOBAL ('RACETIME')

NKEYS

num = NKEYS ( rtnum )

Returns the number of keyfields (sort-ids) for the specified record type (excluding the case id).

NLABELS

num = NLABELS ( rtnum , varname_str )

See NVALLAB.

NMAX

num = NMAX ( rtnum , varname_str )

Returns the highest valid numeric value for the specified variable. If the record number (rtnum) is negative, the function applies to a summary variable; if rtnum is one more than the maximum record count (i.e. NRECS(0)+1) then this applies to a standard variable.
See VAR RANGES for more information about valid ranges.

NMIN

num = NMIN (rtnum, varname_str)

Returns the lowest valid numeric value for the specified variable. If the record number (rtnum) is negative, the function applies to a summary variable; if rtnum is one more than the maximum record count (i.e. NRECS(0)+1) then this applies to a standard variable.
See VAR RANGES for more information about valid ranges.

NOFCASES

num = NOFCASES ( dummy )

Returns the current maximum number of cases as defined in the schema See N of CASES for more information.

NOW

num = NOW( dummy )

Returns a "time integer" representing the current time of day as the number of seconds since midnight. The argument is a dummy argument, specify zero.

NPUT

num = NPUT ( A , Y )

Stores the value of numeric argument Y in numeric variable A. A is a string variable name, quoted string constant or string expression whose value is the name of a common, record, or program variable. The value returned by the function is the value actually stored in A (possibly undefined, missing, etc.). If A refers to a common or record variable, the Retrieval must be in update mode. The following example stores 175 in the variable Height:

COMPUTE DUMMY = NPUT('HEIGHT', 175)

NREAD

num = NREAD( strX )

Pops up a box on the screen with a prompt and returns a number from the user.

If a non-numeric field is entered, a message is issued and the user is prompted again.

NRECS

num = NRECS ( dummy )

Returns the maximum number of record types for the database. This is the maximum possible number of record types, not the actual number of record types defined for the database.

NSUBDIR

str = NSUBDIR (n)

Returns the name of the nth sub-directory.

NUMBR

num = NUMBR( strX )

Returns the numeric value of the string strX. strX is a string constant, variable name or expression and contains only numerical characters, at most one decimal point and a plus or minus sign or is in E+exponent format.

NUMCASES

num = NUMCASES ( dummy )

Returns the number of cases in the database. Same as functions SYSTEM(24) or NUMRECS(0).

NUMRECS

num = NUMRECS ( rtnum )

Returns the number of records of the specified record type.

NVALID

num = NVALID ( rtnum , varname_str )

Returns the number of valid values for the specified variable. If the record number (rtnum) is negative, the function applies to a summary variable; if rtnum is one more than the maximum record count (i.e. NRECS(0)+1) then this applies to a standard variable.

NVALLAB

num = NVALLAB ( rtnum , varname_str )

Returns the number of value labels defined for a variable. NLABELS is a synonym. If the record number (rtnum) is negative, the function applies to a summary variable; if rtnum is one more than the maximum record count (i.e. NRECS(0)+1) then this applies to a standard variable.
See VALUE LABELS for more information about value labels.

NVARDOC

num = NVARDOC ( rtnum , varname_str )

Returns the number of lines of documentation defined for a variable. Variable documentation does not apply to a summary variables. (Just use comment lines in programs for documentation.) See VAR DOC for more information about variable documentation.

NVARS

num = NVARS ( rtnum )

Returns the number of variables (not Common) defined in the specified record type.

NVARSC

num = NVARSC ( rtnum )

Returns the number of variables (including Common) defined in the specified record type.

NVVAL

num = NVVAL ( rtnum , varname_str , n )

Returns the value of the nth valid value of a numeric variable. If the record number (rtnum) is negative, the function applies to a summary variable; if rtnum is one more than the maximum record count (i.e. NRECS(0)+1) then this applies to a standard variable.

ODBCCOLS

num = ODBCCOLS (conid,statid,tabname)

Client/server function. Does an ODBC query that produces a result set that contains a list of columns from the named table on the data source and can be interrogated using the standard functions.

ODBCTABS

num = ODBCTABS (conid,statid)

Client/server function. Does an ODBC query that produces a result set that contains a list of tables on the data source and can be interrogated using the standard functions.

OUTFNAME

str = OUTFNAME ( 0 )

Returns the name of the default output file.

PACK

str = PACK ( strX )

Returns a string with leading and trailing blanks deleted and multiple blanks compressed into one blank. The argument strX may be a string constant, variable name or string expression.

PAD

str = PAD( input, pad , len , trunc)

Pads the input string with the specified pad character to the pad length and then truncates the string to the truncation length.

PAGELEN

n = PAGELEN(filename)

Returns the current setting for page length for specified file.

PAGENO

n = PAGENO(filename)

Returns the current page number on specified file.

PAGEWID

n = PAGEWID(filename)

Returns the current setting for page width on specified file.

PATTERN

num = PATTERN (strX , pattern_str)

Returns 1 if the pattern specified by pattern_str is in strX, otherwise 0. Both arguments are strings and can be variables, constants or expressions. The pattern can contain the match anything character "@". Undefined is returned if either argument is missing or undefined. For example, the following returns 1.
THERE = PATTERN ('Mr. Ralph Jones', 'Mr.@Jones@')

PFORMAT

str = PFORMAT(num, picture)

Formats a number according to a picture, returning a string. A picture is a string of characters, enclosed in quotes. Within the picture certain characters have special meanings. The meanings are identical to those used on the output specification of the WRITE command as per the following:

Each digit can be represented by a "9", a "z", a "*" or a "$". "9" specifies that leading zeros are replaced by blank; "z" specifies that leading zeros are written; "*" specifies that leading zeros are replaced by "*"; "$" after an initial "$" character, represents a floating dollar sign where leading zeros are suppressed. If the field has a value of zero, a picture of all "9"s results in blanks and all "$"s results in a single "$" since all leading zeros are suppressed; if a single zero is wanted, specify a single "z" as the last character of the picture.
A period represents the decimal point and separates the specification into characters before and after the decimal point. There can only be one decimal point (period) in the picture. If there are insufficient digits to display the integer portion of the field (including any minus sign when negative and $ when specified), the field is written as all 'X's. The decimal component is rounded to match the number of decimal digits specified. If there are no decimal digits in the picture, the field is rounded to the integer value.
Specify comma (,) to insert this character. If leading zeros are suppressed (by blanks or a floating dollar), any leading commas are suppressed. If a single dollar sign is specified, it is output in that position. If multiple dollar signs are specified, these suppress leading zeros and result in a floating dollar sign that is output in front of the first significant digit. After the decimal point, the special characters "9", 'Z', "$" and "*" are all equivalent and specify a digit. Any other characters are treated as any other special character.
Negative numbers, by default, are output with a minus sign ahead of the first significant character. If an explicit minus sign is included as the last character in the picture, and the number is negative, the minus is written at that point. Any other characters are output at the position specified in the picture. For example:

PROGRAM
write ["'"+PFORMAT(2500,'$zzzz.zz')+"'"] 40t                      "'$2500.00'"
write ["'"+PFORMAT(12345.67,'zzzzzzzz.zzzzz')+"'"] 40t            "'00012345.67000'"
write ["'"+PFORMAT(SQRT(99),'999999.9999999')+"'"] 40t            "'     9.9498744'"
write ["'"+PFORMAT(12345.67,'z z z z z.ZZZZ')+"'"] 40t            "'1 2 3 4 5.6700'"
write ["'"+PFORMAT(12345.67,'ZZZZZ')+"'"]          40t            "'12346'"
write ["'"+PFORMAT(12345.67,'*********.**')+"'"] 40t              "'****12345.67'"
write ["'"+PFORMAT(12345.67,'9,999,999.99')+"'"] 40t              "'   12,345.67'"
write ["'"+PFORMAT(12345.67,'9,9,9,9,9,9,9,9.9,9,9')+"'"] 40t     "'      1,2,3,4,5.6,7,0'"
write ["'"+PFORMAT(-9,'ZZZ')+"'"] 40t                             "'-09'"
END PROGRAM

PICTURE

num = PICTURE(str, picture)

Validates a string according to a specified picture. A picture is a string of characters, enclosed in quotes. string. Within the picture certain characters have special meanings: Note: the character codes are lower case. They are:

a - any letter
d - any digit
n - any letter or digit
s - numeric value components (0-9, decimal point,+,+"",E)
u - any uppercase letter
l - any lowercase letter
x - any character

The first example returns a 0 showing the string matches the picture. The second example returns a 6 to show that the string does not match the picture in the sixth position:

X = PICTURE ('123-45-6789','ddd-dd-dddd')
X = PICTURE ('123-45-67',  'ddd-d-ddd')

PROCFILE

str = PROCFILE(0)

Returns the attribute of the default procfile. In SIR/XS this is always PROCFILE.

PROCNAME

str = PROCNAME(0)

Returns the filename of the default procfile (e.g.: c:\SIRXS\company.sr4)

PROGRESS

num = PROGRESS ( type,percent )

Controls the display of a progress bar.
x = PROGRESS (0,0) initiates the display.
x = PROGRESS (1,n) displays progress up to n where n is a percentage from 1 to 100.
x = PROGRESS (2,0) closes the display.
The initiation, updating and closing do not have to be in the same VisualPQL program. Once initiated in a program, the progress display is closed only by this function, not automatically at the end of the program and thus can be used to display progress through a suite of programs. If the progress display has not been initiated, the function has no effect.

RACCESS

num = RACCESS ( dummy )

Returns the read security access level of the current user. That is the level corresponding to the read security password of the user.

RAND

num = RAND( dummy )

Returns a uniform random number between 0 and 1. The normal way to call the function is with a dummy argument of zero. Multiple calls then return a sequence of random numbers. If the function is called with a number as the argument, this resets the seed and returns the first random number generated from that seed. For a given seed, the same sequence of random numbers is generated. You can also alter the default seed by specifying a seed on the RETRIEVAL or PROGRAM command.

RANF

See RAND function.

REAL4

num = REAL4(real*8)

Converts a real*8 into a real*4 number.

RECDOC

num = RECDOC(recno,lineno)

Returns the nth line of documentation for the record. If the line number is zero, the function returns the record label. If the record number is zero, the function returns the nth line of database level documentation and if both record and line number are zero then the DATABASE LABEL is returned.

RECDOCN

num = RECDOCN(recno)

Returns the number of lines of documentation for the record. If the record number is zero, the function returns the number of lines of database level documentation.

RECLEVEL

num = RECLEVEL( dummy )

Returns the update level of the current record (when it was last written to the database). The update level changes with each modification to the record (during a RETRIEVAL UPDATE, Batch Data Input run, FORMS updating session, etc.). This function can only be used in a PROCESS REC loop.

RECLOCK

num = RECLOCK(locktype)

Changes the lock type for the current record for concurrent operations and attempts to read the current record from the database. See SYSTEM(36) function to determine if current record is locked. The locktype codes are (all other values set concurrent read):

1 & 6 = Exclusive
2 = Concurrent Read
3 = Concurrent Write
4 = Protected Read
5 = Protected Write

RECNAME

str= RECNAME( rtnum )

Returns the name of the specified record type. If rtnum is 0, "CIR" is returned. Only used in a RETRIEVAL.

RECNUM

num= RECNUM( recname )

Returns the number of the specified record name. If the name does not exist, returns undefined. Only used in a RETRIEVAL.

RECSIZE

num = RECSIZE ( rtnum )

Returns the record size for the specified record type in double words. For example, to find the length of record type 1:

EMPSIZE = RECSIZE (1)

REGEXP

num = REGEXP(string,regular_expression,nth,style)

Searches a string for the nth occurrence of a substring as specified by the regular expression. Returns a negative number if there is an error in the regular expression, 0 if not found in string or n where n is start position of nth occurrence of found string.

A regular expression is one where special characters describe the matching that is required. The meaning of the special characters needs to be specified and there is a standard for regular expressions used by many packages. SIR has had its own regular expression processor and these functions REGEXP/REGREP allow you to choose whether to use standard PERL or POSIX expressions or SIR expressions. A Style of 1 specifies SIR expression, 2 specifies PERL and 3 specifies POSIX. PERL is the default. Please see standard documentation for PERL and POSIX for a full explanation of the syntax of their regular expressions.

SIR Expressions
A SIR expression consists of the following:
c literal character (eg: "Name:")
? any character except end of line (eg: "?and");
% beginning of line (eg: "%first");
$ end of line (null string before end of line) (eg: "last.$");;
[...] character class (any one of 'these' characters)(eg: [a-zA-Z0-9#@%_]);
[!...] negated character class (all but these characters) (eg: [!a-z]);
* closure (zero or more occurrences of the previous pat)(eg: [a-z]*);
+ closure (one or more occurrences of the previous pat)(eg: [a-z]+);
@c escaped character (eg: @%, @[, @*);

Any special meaning of characters in an expression is lost when escaped, inside [...] or in the following cases:
% not at the beginning ( eg: [0-9.]+%);
$ not at the end (eg: $[0-9.]+);
* at the beginning of a pattern;
+ at the beginning;

A character class consists of zero or more of the following elements, surrounded by [ and ]:
c literal character, including [
a-c range of characters (digits, lower or upper case)
! negated character class (if at beginning)
@c escaped character (@!, @-, @@, @])
Special meaning of characters in a character class is lost when escaped or for:
! not at the beginning
- at the beginning or end

Any part of expression may be specified to be 'tagged':
< start a tagged substring
> end a tagged substring
(Tagged substrings are numbered from left to right. See the substitution expression for replacement of tagged substrings.)
A substitution pattern consists of zero or more of the following elements:
c literal character
& ditto, i.e. whatever was matched
@c escaped character (@&)
@n tagged substring insertion
An escape sequence consists of the character @ followed by a single character:
@n end of line
@t tab character
@c any other character (including @@)

Examples:

1) Mark numbers with []s:
PROGRAM
c
c Put numbers in square brackets
c
. STRING*80 TEXT
. SET TEXT ("this is 123 or 456 test")
. COMPUTE TEXT = REGrep(TEXT,"[0-9]+","[&]",1,1)
. WRITE TEXT
END PROGRAM
2) Swap Last name and first name + possible initial:
RETRIEVAL
. PROCESS CASES
.   PROCESS RECORD 1
.     GET VARS NAME
.     WRITE [REGREP(NAME,"<[A-Za-z'-]*><[ A-Z]*> <[A-Za-z'-]*>","@3   "+CHAR(9)+"@1 @2 ",1,1)]
.   END RECORD
. END CASE
END RETRIEVAL
3) Find each word in a sentence. In POSIX, the expression \w*(\W|$) matches any number of letters (\w*) followed by a non-letter (\W) or (|) end of line ($). The expression \w(\W|$) will find a single letter followed by a non-letter and so point to the end of a word.
PROGRAM
c
c Find words in a string
c
STRING*80 TEXT
SET TEXT ("Find the words in a string")
SET N (1)
LOOP
. COMPUTE POS1 = REGEXP(TEXT,"\w*(\W|$)",N,3)
. COMPUTE POS2 = REGEXP(TEXT,"\w(\W|$)",N,3)
. IF (POS1 EQ 0) EXIT LOOP
. WRITE "WORD# " N [SBST(TEXT,POS1,1+POS2-POS1)]
. COMPUTE N = N + 1
END LOOP
END PROGRAM

4) Verify entry of an email address. From the start of the line (^) to the @ must contain one or more (+) alphanumeric characters or ._%- ([A-Za-z0-9._%-]) then one or more alphanumeric or . - ([A-Za-z0-9.-]). a literal . (\.) followed by two to four ({2,4}) alphabetic characters ([A-Za-z]).
PROGRAM
c
c Check an email address
c
STRING*80 TEXT
SET TEXT ("")
LOOP
. DISPLAY TEXTBOX "Enter a valid email address" response RC,TEXT
. IFNOT (RC GT 0) EXIT LOOP
. IFTHEN (REGEXP(TEXT,"^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$",1,3) EQ 0)
.   DISPLAY ERRORBOX " is an invalid email address"
.   NEXT LOOP
. ELSE
.   DISPLAY INFOBOX  "Thank you"
.   EXIT LOOP
. ENDIF
END LOOP
END PROGRAM

REGREP

str = REGREP(string,match_regular_expression,replace_regular_expression,nth,style)

Searches a string for the nth occurrence of a substring as specified by the regular expression and replaces that substring as specified by the replace regular expression. The function returns the updated string. If any errors are found, the unmodified string is returned. Please see the previous REGEXP function for details on SIR regular expressions.

REPLACE

str = REPLACE(original,search,replace,times,offset,anchor)

If the search string is found in the original string, occurrences are replaced by the replace string. The number of times the string is replaced, the offset for the next starting position, and an anchor column are also specified. The following example returns "CABCBCBBAA" if INLINE is "AABABABBAA".
INLINE = REPLACE (INLINE, 'A','C',3,2,0) When anything but 0 is specified as the anchor, the string is only replaced once, at the anchor position. The following example returns "AABCBABBAA" if INLINE is "AABABABBAA".
INLINE = REPLACE (INLINE, 'A','C',3,2,4)

REVERSE

str = REVERSE (str)

Reverses a string.

RKEYSIZE

num = RKEYSIZE (rtnum)

Returns the key length a record type. This is the sum of the key fields of the record type plus the case identifier in case structured databases.

RND

num = RND( X [,n ])

Returns X rounded to n decimal places. Express n as powers of 10, negative for numbers smaller than 1. Omit n or specify 0 to round to integers. Rounding is done by adding 0.5*10n to positive numbers, subtracting 0.5*10n from negative then truncating.

RNMFILE

num = num = RNMFILE (oldname_str,newname_str)

Renames a file or directory from oldname_str to newname_str. Returns 0 for a success and -1 for fail.

ROWCOUNT

num = ROWCOUNT (conid,statid)

Client/Server function. Returns a count of rows created by the execute command. When using ODBC, this depends on the ODBC source and may not be available (returns -1).

RRECSEC

num = RRECSEC (rtnum)

Returns the read security level for a record type.

RVARSEC

num = RVARSEC (rtnum, varname_str)

Returns the read security level for a variable.

SARG

str = SARG( num )

Returns string arguments from the parameter list. The argument is the position in the list. If it is greater than the number of parameters in the list, undefined is returned. (Numeric parameters are retrieved with the NARG function. NARG(0) returns the number of parameters in the list.)

SBST

str = SBST( input_str , start_pos , num_chars )

Returns a substring of the input string. The second argument, start_pos, specifies the position within the input string where the substring begins. The third argument specifies the number of characters to retrieve from the input string. If any of the arguments are undefined or missing, undefined is returned. If the starting position is larger than the length of the input string, undefined is returned.

SCROLLAT

num = SCROLLAT(id)

Returns current line number of scrollable GUI control.

SCROLLTO

num = SCROLLTO(id,line)

Sets current line number of scrollable GUI control.

SEEK

num = SEEK(attribute_exp,position)

Sets position of currently open file where position is the number of characters to move from the current location in the file. If position is -1 it moves to EOF; if position is -2 then it doesn't move and just returns current position; if position is -3 it moves to the start of the file. To move to an absolute position, first move to the start of the file and then to the position.

The return value is the new pointer position. The attribute expression is the attribute associated with this file. To specify this directly (as opposed to specifying a variable name which contains the attribute), enclose the name in quotes.

SERADMIN

n = SERADMIN (function_type,server_client_id,password)

Client function for PQLServer. Server administration function.
Function types:
1 - number of server clients
2 - server client id of nth client
3 - close server client id (not us) (password)
4 - server client id logon time
5 - server client id last message time
6 - shutdown server
7 - shutdown server when no clients (password)
The server client id is required on function types 3,4 and 5. Server client ids are returned by function type 2. Use the nth client number as the client id on function type 2 (0 returns our server client id). Use 0 on function types 1,6 and 7.
Do not use SERADMIN function type 3 to close this client.

SERADMIS

str = SERADMIS (function_type,client_id,password)

Client function for PQLServer. Server admin functions that return a string value.
Function types:
1 - address/name of client id (0 returns our name)

SEREXEC

n = SEREXEC (wait_factor)

Send to server to execute previous sent commands.
0 Wait means return without waiting;
1 means wait one interval, 2 two intervals, etc. The basic server timeout interval can be set on the sir.ini file- the setting is called server.timeout. If not set, the default is 5 seconds.
Returns completion code:
-1 - Timeout. Note that the server continues to run the request - it is just taking longer than expected. The SERTEST function can be used subsequently to inquire as to status.
0 Completed OK
1 Completed with warnings
2 Completed with errors
Other values can set by user program on server using the SETRC (RC) function (note user return codes are returned as positive numbers so should avoid values of 1 or 2).

SERGET

str = SERGET (number_of_lines_to_skip)

Returns a single line of output. If the number of lines to skip is 0, the next line is returned, otherwise it is the line after the skipped lines.

SERLINES

n = (dummy)

Returns the number of lines left. If this function is invoked after lines are returned or skipped, it returns the remaining number of lines.

SERLOG

n = SERLOG (Server_name, Password)

Logs on/off to the server. This first logs off any current connection then, if the name of the server to logon to is not blank, this is used to try to log on to. Returns -1 if the logon fails. A string containing the password is required. If the server is started with UPASS specified then the password must match the server administration password. Note that while specified as a string or string variable, the password is a SIR/XS name and is uppercase if not a non-standard name in curly brackets {}.

SERNOOUT

num = SERNOOUT (n)

PQLServer side function that controls SERVER NOOUTPUT flag. If flag is set on, then any output directed to standard output is thrown away. The flag is set off initially for each client execution. The setting is still maintained once the program that uses this function ends.
n = 0 returns setting 1 - On 0 Off
n = 1 sets no output on
n = -1 sets no output off

SERSEND

n = SERSEND (string)

Sends string to the server. The string is a line of input.

SERSENDB

n = SERSENDB (buffer_name)

Sends contents of buffer to the server.

SERTEST

n = SERTEST (wait_factor)

Use if haven't waited for SEREXEC to complete or had a timeout on the execution. Returns same completion codes as SEREXEC

SERWRITE

num = SERWRITE (string)

PQLServer side function that writes lines to output regardless of setting of SERVER NOOUTPUT flag

SETAKL

n = SETAKL(time,password)

Sets the client autokill limit in minutes. If a client is idle for the given number of minutes then they will be automatically disconnected by master. If master has been started with a password, this must match the quoted password, otherwise any name can be used.

SETDFC

n = SETDFC(time,password)

Sets the master difference file copy interval in minutes. If master has been started with a password, this must match the quoted password, otherwise any name can be used.

SETDIR

n = SETDIR(directory_name)

Sets the default directory.

SETPOS

n = SETPOS(id,pos)

Sets the position of a multi-line GUI control.

SETRANGE

n = SETRANGE(id,min,max)

Sets the range of a GUI spin/slider/progress control.

Sets the maximum number of characters allowed in an edit or text field (ignoring the minimum parameter).

SETRC

n = SETRC(numeric_return_code)

Sets the return code SIR/XS sends to the operating system when it finishes.

SGET

str = SGET( varname_str )

Returns the value of the specified string variable. The argument is a string variable, quoted string constant or string expression whose value is the name of a common, record or program variable.

SGLOBAL

str = SGLOBAL( varname_str )

Returns the string value of a global variable. The argument is a string variable, constant or expression that specifies a global variable name. If it is not the name of a defined global variable, undefined is returned. Use the NGLOBAL function for numeric global variables.

SIGN

num = SIGN( num_X , num_Y )

Transfers the sign (positive or negative) of num_Y to the absolute value of num_X. Zero is positive.

SIN

num = SIN( radnum )

Returns the trigonometric sine of radnum, where radnum is specified in radians.

SIRUSER

name = SIRUSER( name )

Sets/returns the current SIR/XS user name. This is written to the database journal to identify the person who entered particular sets of database updates. Specify a name (up to 32 characters). No translation (upper/lower case, etc.) is done. Simply to return the current user name, pass either a missing name or a zero length name.

USER = SIRUSER ('') returns existing name to string variable USER
USER = SIRUSER ('Mr. J. Smith') sets the name and returns it to string variable USER.

SMAX

str = SMAX ( rtnum , varname_str )

Returns the maximum valid string value for the specified variable. If the record number (rtnum) is negative, the function applies to a summary variable; if rtnum is one more than the maximum record count (i.e. NRECS(0)+1) then this applies to a standard variable.

SMIN

str = SMIN ( rtnum , varname_str )

Returns the minimum valid string value for the specified variable. If the record number (rtnum) is negative, the function applies to a summary variable; if rtnum is one more than the maximum record count (i.e. NRECS(0)+1) then this applies to a standard variable.

SPREAD

str = SPREAD ( input_str )

Returns a string with a blank inserted between each character of the input string.

SPUT

str = SPUT (varname_str, str )

Stores the value of string argument str in the specified string variable. The variable name argument is a string variable name, quoted string constant or string expression whose value is the name of a common, record or program variable. The value returned by the function is the value stored in the variable (possibly undefined, missing, etc.). If the variable refers to a common or record variable, the Retrieval must be in UPDATE mode.

SQRT

num = SQRT( X )

Returns the square root of X. Missing is returned for negative values.

SRCH

num = SRCH( varX , varY , Z )

Returns the location of the value Z in the table of values VarX to VarY, where VarX and VarY are local numeric variables defined in the program from VarX to VarY. These cannot be arrays or string variables. The values in the variables must be in ascending order.

For example, if Z matched the fourth value in the table, SRCH returns 4. If no match is found, a negative value is returned. The value indicates the correct position for Z for in the table. For example:

SET INCOME1 TO INCOME8 (1,1.5,2.2,2.5,3,3.1, 3.5, 4)
COMPUTE LOC = SRCH (INCOME1,INCOME8,SALARY)

If SALARY has the value 3.5, the function returns 7, because the seventh variable has the value 3.5. If SALARY has the value 2, the function returns the value -3 indicating that the value is not present, and that the correct place in the list is in the third position.

SREAD

str = SREAD(prompt)

Pops up a box on the screen with the specified prompt and returns a string from the user. The maximum input is 4094 characters; long strings are scrolled horizontally.

SRST

num = SRST (strX ,strY)

Returns the column number within strX that matches strY. If strY is delimited by characters other than letters or numbers, SRST returns a positive number, otherwise SRST returns a negative value. If strY is not a substring of strX, SRST returns a zero value. The length of strX must be greater than or equal to the length of strY. For example:

POS1 = SRST ('BUBBLE GUM','GUM') results in: POS1 = 8
POS2 = SRST ('ANITA TINKLE',' ') results in: POS3 = -6

STATTYPE

num = STATTYPE ( rtnum , varname_str )

Indicates if the variable is a control or observation variable. If the record number (rtnum) is negative, the function applies to a summary variable; if rtnum is one more than the maximum record count (i.e. NRECS(0)+1) then this applies to a standard variable.
0 = not a control or observation variable
1 = observation var
2 = control var

STDEV

num = STDEV(X1 , X ,...., Xn)

Returns the standard deviation for the values in the list that are not missing or undefined. If fewer than 2 values are not missing or undefined, a value of undefined is returned.

STDEVR

num = STDEVR( varname )

Returns the standard deviation for the values of the specified variable encountered during a PROCESS REC or PROCESS ROWS loop that are not missing or undefined. If fewer than 2 values are not missing or undefined, a value of undefined is returned.

STDNAME

name = STDNAME(name)

Checks if name is standard and puts curly brackets around non-standard names. The function ignores leading and trailing spaces and any trailing characters over legal name length. If the name has leading or trailing quotes or curly brackets, these are stripped off. A standard name starts with an uppercase letter and contains only uppercase letters, digits or the four characters $, #, @, and _. If it is a standard name, it is returned left justified. (Note that this function does NOT translate lower case letters to uppercase. Any lowercase means that the name is non-standard.
If it is a non-standard name, it is wrapped in curly brackets and returned left justified. If a name has embedded curly brackets, undefined is returned.

SUBDIR

str = SUBDIR (dir_str,sub_str)

Concatenates a subdirectory name to a directory path in correct system specific manner
e.g.: DIR = SUBDIR(CURDIR(0),"data") returns a string like C:\SIR_XS\data\ under windows or /usr/SIR/XS/data/ under unix.

SUBSTR

str = SUBSTR(string,start,len)

Same as SBST function. Returns a null string if the starting position is outside the length of the string.

SUM

num = SUM(X1 , X ,...., Xn)

Returns the sum of the values in the list that are not missing or undefined. The maximum number of variables allowed in the argument list is 128. Arguments must be numeric.

SUMR

num = SUMR( X )

Returns the sum of the values of X encountered during a PROCESS REC or PROCESS ROWS loop that are not missing or undefined.

SVVAL

str = SVVAL ( rtnum , varname_str , n )

Returns the value of the nth valid value of a categorical string variable. If the record number (rtnum) is negative, the function applies to a summary variable; if rtnum is one more than the maximum record count (i.e. NRECS(0)+1) then this applies to a standard variable.

SYSTEM

num = SYSTEM( X )

Extracts a wide variety of information from an executing VisualPQL program set. Some return undefined if not in a RETRIEVAL.

NumberReturn Value
SYSTEM(1) The CPU time elapsed since beginning of run

SYSTEM(2) A platform number, for example:
4 Sun Risc Solaris
7 Compaq Tru64 Unix
8 Compaq Alpha OpenVMS
10 IBM AIX
12 HP 9000 HP-UX
13 Silicon Graphics IRIX
9 Intel Linux
27 MS Windows
28 Macintosh

29 Intel Solaris

SYSTEM(3) The update level for the current case/record. This is the update level at which this was last written. If it has previously been updated in the current update run, it is 1 greater than the database update level (system(23)).

SYSTEM(4) 1 if current case is available for processing, returns a 0 if current case is not available for processing

SYSTEM(5) 1 if current case has been modified, returns a 0 is current case has not been modified

SYSTEM(6) 1 if current record is available for processing, returns a 0 if current record is not available for processing

SYSTEM(7) 1 if current record has been modified, returns a 0 if current record has not been modified

SYSTEM(8) If current case is available for processing, returns the number of records of all types belonging to the current case

SYSTEM(9) The current output file page number

SYSTEM(10) The lines remaining on current output file page

SYSTEM(11) The total number or errors in the session

SYSTEM(12) The number of errors during the current task

SYSTEM(13) The number of warnings during the current task

SYSTEM(14) 1 if last CASE IS block was executed, returns a 0 if last CASE IS block was not executed

SYSTEM(15) 1 if last CASE IS block created a case, returns a 0 if last CASE IS block did not create a case

SYSTEM(16) 1 if last RECORD IS block was executed, returns a 0 if last RECORD IS block was not executed

SYSTEM(17) 1 if last RECORD IS block created a record, returns a 0 if last RECORD IS block did not create a record

SYSTEM(18) The current row block number

SYSTEM(19) The current row block position. Can be used to save a row position and retrieve the data with an OLD ROW IS AT (block,pos)

SYSTEM(20) The number of cases (CIRs) created during current run

SYSTEM(21) The number of cases (CIRs) updated during current run

SYSTEM(22) The number of cases (CIRs) deleted during current run

SYSTEM(23) The database update level

SYSTEM(24) The number of cases in database

SYSTEM(25) The number of data records in database

SYSTEM(26) The line width of current output page

SYSTEM(27) 1 if the last ROW IS block was executed, returns a 0 if the last ROW IS block was not executed

SYSTEM(28) 1 if the last ROW IS block created a row, returns a 0 if the last ROW IS block did not create a row

SYSTEM(29) 1 if the current row is available for processing, returns a 0 if the current row is not available for processing

SYSTEM(30) 1 if the current row was modified, returns a 0 if the current row was not modified

SYSTEM(31) The row ordinal of the current row

SYSTEM(32) The number of rows in the table

SYSTEM(33) Not used

SYSTEM(34) The amount of table space, in SIR double words, used for the VisualPQL execution stack

SYSTEM(35) The amount of table space, in SIR double words, used for the program schema maps

SYSTEM(36) 1 if the current record is available. A 0 (zero) is returned if access to the current record is denied for concurrent operations because the record is locked by another process with a non-compatible lock type

SYSTEM(37) 1 if the current CIR is available. A 0 (zero) is returned if access to the current CIR is denied because the CIR is locked by another process with a non-compatible lock type

SYSTEM(38) 1 if the session is a concurrent session using Master. A 0 (zero) is returned if this is a normal, single-user session

SYSTEM(39) The ordinal number of the default database. No connected database returns 0

SYSTEM(40) Indicates the number of connected databases. This returns the size of the connected database table that may include entries for disconnected databases since the position number associated with a particular connected database never changes.

SYSTEM(41) The default string size

SYSTEM(42) The Editor Type setting number

SYSTEM(43) The Error Limit setting (num)

SYSTEM(44) Encryption on for database (1 on, 0 off)

SYSTEM(45) The current user has DBA rights (1 yes ,0 no)

SYSTEM(46) The Page Length setting (num)

SYSTEM(47) The Page Width setting (num)

SYSTEM(48) The Loading Factor setting (num)-real

SYSTEM(49) The Sort Number (SORTN) setting (num)

SYSTEM(50) The Sort option (Obsolete)

SYSTEM(51) The Warning Limit setting (num)

SYSTEM(52) The Number of Attribute settings

SYSTEM(53) The Number of Global variables set

SYSTEM(54) The number of database data files. 0=standard

SYSTEM(55) The Century split year

SYSTEM(56) The number of Buffers defined

SYSTEM(57) The number of families in the default procfile

SYSTEM(58) Printback (1 on, 0 off)

SYSTEM(59) Printback dorepeat (1 on, 0 off)

SYSTEM(60) Printback calls (1 on, 0 off)

SYSTEM(61) Printback task stats (1 on, 0 off)

SYSTEM(62) Printback remarks (1 on, 0 off)

SYSTEM(63) Printback skipped commands (1 on, 0 off)

SYSTEM(64) Printback user created attributes (1 on, 0 off)

SYSTEM(65) Printback quiet (1 on, 0 off)

SYSTEM(66) Master Backup Interval

SYSTEM(67) Backup Count

SYSTEM(68) Number of Master clients

SYSTEM(69) Number of Master attached databases

SYSTEM(70) Password on default member? (1 Yes, 0 No)

SYSTEM(71) Default member type (1 :T; 2 :E; 3 :P; 4 :O; 5 :V; 6 :M)

SYSTEM(72) Default member public (1 Yes, 0 No)

SYSTEM(73) Length in bytes of default member

SYSTEM(74) Creation date of default member

SYSTEM(75) Creation time of default member

SYSTEM(76) Modification date of default member

SYSTEM(77) Modification time of default member

SYSTEM(78) Family password on default family? (1 Yes, 0 No)

SYSTEM(79) Lines in default member

SYSTEM(80) Status of window paging. Paging on returns 1

SYSTEM(81) Default Database "In Use" flag. Returns 1 for on.

SYSTEM(82) Default Database creation date as a Julian integer.

SYSTEM(83) Default Database creation time as an integer.

SYSTEM(84) Default Database modification date as a Julian integer.

SYSTEM(85) Default Database modification time as an integer.

SYSTEM(86) Default Procfile security. Returns 1 if the procfile has a password.

TABINDN

str = TABINDN (fn,tn,in)

Returns the index name of nth index. See TABINDS.

TABINDS

num = TABINDS(fn,tn)

Returns the number of indexes on nth table.

TABINDT

str = TABINDT (fn,tn,in,vn)

Returns the variable name and sort sequence of nth variable on index.

TABINDU

num = TABINDU (fn,tn,in)

Returns whether nth index is unique 0 - Not unique, 1 - Unique.

TABINDV

num = TABINDV (fn,tn,in)

Returns the number of variables in nth index.

TABNAME

str = TABNAME(fn,tn)

Returns the name of nth table. TFTABS(fn) returns number of tables on nth tabfile.

TABRECS

n = TABRECS(fn,tn)

Returns the number of rows on the nth table. TFTABS(fn) returns number of tables on nth tabfile.

TABVARS

num = TABVARS(fn,tn)

Returns the number of variables in nth table.

TABVINFN

num = TABVINFN(fn,tn,vn,n)

Returns various numeric data about the nth variable in nth table. The type of data is set by the fourth parameter as follows:

  1 = Count of value labels
  2 = leading zero
  3 = print this column
  4 = null not allowed
  5 = ON if value labels printed
  6 = set break variable
  7 = option G on break
  8 = option C on break
  9 = option P on break
 10 = var label as col heading
 11 = unique flag
 12 = subtotal title to the left
 13 = count of ranges
 14 = SIR data type

TABVINFS

str = TABVINFN(fn,tn,vn,n)

Returns various string data about the nth variable in nth table. The type of data is set by the fourth parameter as follows:

 1 = variable label
 2 = LNEG
 3 = LPOS
 4 = NULL
 5 = ZERO
 6 = TNEG
 7 = TPOS
 8 = SEPARATE
 9 = date/time format (COL should have date/time type)
 10= break string

TABVNAME

str = TABVNAME(fn,tn,vn)

Returns the variable name for vnth var on tnth table.

TABVRANG

str = TABVRANG(fn,tn,vn,rn)

Returns a string representation of the value(s) for the rnth range for vnth var on tnth table. String starts with keyword VALID or MISSING to indicate the type of range. Then string may have two values separated by :. Also may contain keywords BLANK, LOWEST and HIGHEST.

TABVTYPE

str = TABVTYPE(fn,tn,vn)

Returns the variable type for vnth var on tnth table.

TABVVALI

n = TABVVALI(fn,tn,vn,expr)

Validates the value in the expression (numeric or string) against the vnth var on tnth table. Returns a code indicating whether a value is allowed in a variable. The codes are:

0 = Valid value
Negative = Error detected
2 = Violation of specified valid values or ranges
3 - n Missing value 0 to n
4 = Missing value 1
5 = Missing value 2, etc.

TABVVLAB

str = TABVVLAB(fn,tn,vn,vln)

Returns the label for the vlnth value label for vnth var on tnth table.

TABVVVAL

str = TABVVVAL(fn,tn,vn,vln)

Returns the value for the vlnth value label for vnth var on tnth table.

TAN

num = TAN( X )

Returns the trigonometric tangent of X, where x is in radians. If X is an odd integral multiple of p/2 (e.g., p/2, 3p/2, 5p/2, etc.), the value of undefined is returned.

TANH

num = TANH( X )

Returns the hyperbolic tangent of X.

TFACCESS

str = TFACCESS(fn)

Returns the access type a(uto),r(ead) w(rite) of nth tabfile.

TFATTR

str = TFATTR(fn)

Returns the internal attribute name of nth tabfile. This is the same as the tabfile name.

TFCOUNT

num = TFCOUNT(dum)

Returns the number of connected tabfiles.

TFFILE

str = TFFILE(fn)

Returns the filename of nth tabfile.

TFGRNAME

str = TFGRNAME(fn)

Returns the group name of nth tabfile.

TFGRPW

str = TFGRPW(fn)

Returns the group password of nth tabfile.

TFJNNAME

str = TFJNNAME(fn)

Returns the journal name of nth tabfile.

TFNAME

str = TFNAME(fn)

Returns the name of nth tabfile.

TFTABS

num = TFTABS(fn)

Returns the number of tables on nth tabfile.

TFUSNAME

str = TFUSNAME(fn)

Returns the user name of nth tabfile.

TFUSPW

str = TFUSPW(fn)

Returns the user password of nth tabfile.

TIME

num = TIME( X )

Returns an integer that is the number of seconds from midnight. The input argument, X, is an integer in the range 0 - 235959; the first two digits are hours, the next two are minutes and the last two are seconds. For example, to calculate the number of seconds from midnight to 8:30 AM.
SLEEPSEC = TIME(083000)

TIMEC

str = TIMEC( X , time_format)

Converts an integer, X, into a time formatted string. See time formats for a complete description. Values of X that are out of range are returned as undefined. For example:

WAKESTR = TIMEC(ALARM, 'HH:MM:SS')

TIMEMAP

str = TIMEMAP ( rtnum, varname_str )

Returns a string with the time format (map) of the specified time variable. If the variable is not a time variable, undefined is returned. For example, TIMESTR equals "HH:MM:SS" if time variable INTIME has that time format. If the record number (rtnum) is negative, the function applies to a summary variable; if rtnum is one more than the maximum record count (i.e. NRECS(0)+1) then this applies to a standard variable.

TIMESTR = TIMEMAP (1, 'INTIME')

TODAY

num = TODAY( dummy )

Returns the "date integer" representation of the current date. The argument is a dummy numeric argument (specify 0).

TRIM

str = TRIM(string_expression)

Deletes trailing blanks from the string expression.

TRIML

str = TRIML(string_expression)

Deletes leading blanks from the string expression.

TRIMLR

str = TRIMLR(string_expression)

Deletes leading and trailing blanks from the string expression.

TRIMR

str = TRIMR(A)

See TRIM function.

TRUNC

num = (X [,n])

See AINT function.

TSTODT

date = TSTODT (timestamp)

Takes a real*8 timestamp (produced by DTTOTS and returns the date integer component.

TSTOTM

time = TSTOTM (timestamp)

Takes a real*8 timestamp (produced by DTTOTS and returns the time integer component.

TWRITE

str = TWRITE(string_expression)

Writes the specified string expression to the scrolled output window. This function can be useful when a program is run with an alternate output file (i.e., with the interactive SET OUTPUT command) and can only be used during an interactive session.

UPDLEVEL

num = UPDLEVEL (0)

Returns the current database update level. (Same as SYSTEM(23).)

UPGET

str = UPGET (key_str)

Gets string value (User Preference) identified by key_str (from sir.ini file)
e.g. COMPUTE TITLE= UPGET('SIR.TITLE')

UPPER

str = UPPER(string_expression)

Changes lowercase letters to uppercase.

UPSET

num = UPSET (key_str,val_str)

Sets string value (User Preference) identified by key_str (in sir.ini file). Returns zero for success, -1 for failure.
e.g. COMPUTE rc= UPSET('SIR.TITLE','SIR/XS')

VALIDATE

num = VALIDATE (rtnum, varname_str ,value)

Returns a code indicating whether a value is allowed in a variable. If the record number (rtnum) is negative, the function applies to a summary variable. The codes are:

0 = Valid value
1 = Wrong data type/Not valid value
2 = Violation of specified valid values or ranges
3 = Missing value 0 (Undefined or system missing value)
4 = Missing value 1
5 = Missing value 2
6 = Missing value 3
7 = String too long / extra data after number - truncated

VALLAB

str = VALLAB( varname )

Returns a character string containing the value label for the current value of the specified variable. If there is no label defined for the value, a zero length string is returned. The argument is a variable name, not a constant or expression.

VALLABSC

str = VALLABSC (rtnum,varname_str,value)

Returns the value label (up to 78 characters) for the specified value of a variable. If the record number (rtnum) is negative, the function applies to a summary variable; if rtnum is one more than the maximum record count (i.e. NRECS(0)+1) then this applies to a standard variable.
The value can be numeric or string.

For example, suppose the fourth value label for a variable DIVISION in record type 2 has value 10, label 'Head Office' then:

THISPOS = VALLABSC (2, 'DIVISION',10)
returns 'Head Office'.

VALLABSN

str = VALLABSN ( rtnum, varname_str , n)

Returns the nth value label for a variable (up to 78 characters). If the record number (rtnum) is negative, the function applies to a summary variable; if rtnum is one more than the maximum record count (i.e. NRECS(0)+1) then this applies to a standard variable.
Note that the number of labels is returned by NVALLAB.

For example, suppose the fourth value label for a variable DIVISION in record type 2 has value 10, label 'Head Office' then:

THISPOS = VALLABSN (2, 'DIVISION',4)
returns 'Head Office'.

VALLABSP

n = VALLABSP ( rtnum, varname_str , value)

Returns the position (nth) of the specified value associated with value labels for a variable. If the record number (rtnum) is negative, the function applies to a summary variable; if rtnum is one more than the maximum record count (i.e. NRECS(0)+1) then this applies to a standard variable.
The value can be numeric or string.

For example, suppose the fourth value label for a variable DIVISION in record type 2 has value 10, label 'Head Office' then:

POS = VALLABSP (2, 'DIVISION',10)
returns 4.

VALLABSV

str = VALLABSV ( rtnum, varname_str , n)

Returns the nth value associated with value labels for a variable. If the record number (rtnum) is negative, the function applies to a summary variable; if rtnum is one more than the maximum record count (i.e. NRECS(0)+1) then this applies to a standard variable.
Note that the number of labels is returned by NVALLAB.

For example, suppose the fourth value label for a variable DIVISION in record type 2 has value 10, label 'Head Office' then:

THISPOS = VALLABSV (2, 'DIVISION',4)
returns '10'.

VARDOCSN

str = VARDOCSN ( rtnum, varname_str,line_no )

Returns the nth line of documentation for a variable. Use the NVARDOC function to find total number of lines. (Note that variable documentation does not apply to summary variables. Simply use comment lines in programs to document.) In the following example, if MARSTAT in record type 1 has a single line of variable documentation of "Current marital status of employee", then COLDESC is set to that string value.".
COLDESC = VARDOCSN (1, 'MARSTAT', 1)

VARGET

str = VARGET (expression)

Returns a string representation of the value in the variable named in the expression. This works on all variable types. It converts catvar, date, time, integer and real to a string according to the format of the specified variable as per the VFORMAT function. Specify a string variable or expression that contains the name of another variable. For example:

INTEGER*1 INT1
STRING*8 STR1 STR2
COMPUTE INT1 = 1; STR1 = 'INT1'
COMPUTE STR2 = VARGET (STR1)
WRITE STR1 STR2

Output is:   INT1       1

Note: VARGET does not return original missing values. If you need to get the original missing value of a variable named at run time then you could either use the EVALUATE command (slow) or use SGET/NGET to copy the variable into a predefined variable with known missing values. Then use the MISNUM function on these known variables and MISS on the original variable with the result of MISNUM:
real* 8 temp#
string  temp$
missing values temp# (blank,blank,blank)
missing values temp$ (blank,blank,blank)
...
c 
c Get the original missing value of local variable who's name is in the variable VARNAME
c
. IFTHEN (VTYPE(-1,varname) gt 1)
.   COMPUTE temp#=NGET(varname); COMPUTE missnum =MISNUM(temp#)
. ELSE
.   COMPUTE temp$=SGET(varname); COMPUTE missnum =MISNUM(temp$)
. ENDIF
. IF (EXISTS(missnum) = 0 or missnum > 0) WRITE [FST(VARGET(varname),MISS(-1,varname,missnum))]
...

VARLAB

str = VARLAB( varname )

Returns the variable label (up to 78 characters) for a variable. If there is no label defined for the variable, the variable name is returned. The argument is a variable name, not a constant or expression. If the function is compiled in a record block, a record variable can be specified. If the function is compiled in a case block, a common variable can be specified. If the function is outside and record or case block, then specify a local, summary variable.

VARLABSC

str = VARLABSC ( rtnum, varname_str )

Returns the label (up to 78 characters) for a variable. If there is no label defined for the variable, the variable name is returned. The first argument is the record number where the variable occurs or 0 for common variables. Use a negative value to specify a local, summary variable. The second argument is a constant (in quotes) or an expression that resolves to a variable name. In the following example, if MARSTAT in record type 1 has a variable label of "Marital Status", then COLHEAD equals "Marital Status".
COLHEAD = VARLABSC (1, 'MARSTAT')

VARNAME

string = VARNAME (rtnum,varnum)

Returns the name of the specified variable. The first argument is the record number where the variable occurs or 0 for common variables. Use a negative value to specify a local, summary variable. The second argument is the number of the variable (not including common vars). Variables are numbered in the order they are defined in the record schema definition. If the name is a non-standard name, it is returned enclosed in curly brackets {}.

VARNAMEC

string = VARNAMEC (rtnum,varnum)

Returns the name of the specified variable. The first argument is the record number where the variable occurs; the second argument is the number of the variable (including common vars). Variables are numbered in the order they are defined in the record schema definition.

VARLENG

num = VARLENG (rtnum,varname)

Returns the data length of the specified variable. The first argument is the record number where the variable occurs; the second argument is the name of the variable.

VARPOSIT

num = VARPOSIT (rtnum,varname)

Returns the position in the data record of the specified variable. The first argument is the record number where the variable occurs; the second argument is the name of the variable.

VARPUT

num = VARPUT(var_exp,string)

Places the value from the second argument into the first argument converting from a string to a numeric value if necessary. Var_exp contains the name of a variable. If the variable is a numeric variable, the string is converted to the appropriate numeric value and stored in the variable.

Returns the same numeric values as VALIDATE.

0 = Valid value
1 = Wrong data type/Not valid value
2 = Violation of specified valid values or ranges
3 = Missing value 0 (Undefined or system missing value)
4 = Missing value 1
5 = Missing value 2
6 = Missing value 3
7 = String too long / extra data after number - truncated

For example:

COMPUTE RES = VARPUT ('BIRTHDAY','12/31/50')

VARTYPE

num = VARTYPE( varname_str )

Returns an integer code representing the type of the specified variable. The argument is a string variable, quoted string constant or string expression whose value is the name of a common, record or local variable. Codes are:

0         if variable is string
1         if variable is numeric
undefined if variable is undefined

VFORMAT

str = VFORMAT ( rtnum , varname_str )

Returns a string representing the format of the specified variable (for example, A20, F9.2, D'MMIDDIYY', etc.) If the record number (rtnum) is negative, the function applies to a summary variable; if rtnum is one more than the maximum record count (i.e. NRECS(0)+1) then this applies to a standard variable.
In the following example, if variable NEWSAL in record type 3 is a four digit integer, then XFMT equals "I4".

XFMT = VFORMAT (3, 'NEWSAL')

VSCALE

num = VSCALE( rtnum , varname_str )

Returns the scaling factor of the variable if the variable is a scaled integer. Otherwise it returns 0 for a non scaled variable or undefined if the variable does not exist.

SFAC = VSCALE (3,'AMOUNT')

VSCHFMT

str = VSCHFMT( rtnum , varname_str )

Returns the variable format exactly as specified in the schema DATA LIST. This is different from VFORMAT in that VFORMAT returns an external print format whereas the formats in the DATA LIST are a mix of input formats (eg DATE'MM/DD/YYYY')) and internal formats (eg I2 a two byte integer). A negative rtnum will return a schema like format for a local variable.

SCHFMT = VSCHFMT (1,'BIRTHDAY')

VTYPE

num = VTYPE ( rtnum , varname_str )

Returns an integer code representing the type of the variable, where:

1 = string
2 = categorical
3 = date
4 = time
5 = integer
6 = real (single precision)
7 = real (double precision)
8 = scaled variable
If the record number (rtnum) is negative, the function applies to a summary variable; if rtnum is one more than the maximum record count (i.e. NRECS(0)+1) then this applies to a
standard variable.

VXLEN

int = VXLEN( rtnum , varname_str )

Returns the number of character required to print or display a variable.

If the record number (rtnum) is negative, the function applies to a summary variable; if rtnum is one more than the maximum record count (i.e. NRECS(0)+1) then this applies to a standard variable.

LEN = VXLEN (1,'SALARY')

WACCESS

num = WACCESS ( dummy )

Returns the write security access level of the current user (the level corresponding to the write security password entered).

WINCNT

num = WINCNT (0)

Returns the number of lines in the output window

WINLIN

str = WINLIN (n)

Returns the nth line from the output window

WINMOVE

num = WINMOVE (x,y,w,h)

Moves and resizes the main window. The window is placed at horizontal position x,vertical position y, size width w by height h. The horizontal units are 1/4 of the average width for the font being used. The vertical units are 1/8 font height. If w or h is zero the window is minimized; if w or h < 0, the window is restored to its original position (before being minimised).

WINPOS

num = WINPOS (line,pos,len)

Moves to line in output window and highlights from pos to len on that line

WINSELL

num = WINSELL(n)

Returns the line selected. 0 returns the current cursor line. 1 returns beginning line of selection. 2 returns ending line of selection.

WINSELP

num = WINSELP(n)

Returns the position in the line selected. 0 returns the current cursor position. 1 returns beginning position of selection. 2 returns ending position of selection.

WRECSEC

num = WRECSEC ( rtnum )

Returns the write security level for a record type.

WVARSEC

num = WVARSEC ( rtnum , varname_str )

Returns the write security level for a variable.

YESNO

num = YESNO( strX )

Displays a question box with the specified text and returns response. 1 indicates Yes; 0 indicates No.

homecontents start chapter top of pagebottom of pagenext page index