Advertising banner:
 
 
 A327
 
81203_43854_21.png 81203_43840_19.png


Function
Definition
Syntax
Example
Abs
Computes the absolute value of a numeric expression.
Abs(numeric expression)
Abs returns the unsigned magnitude of any numeric expression. For example, Abs(-21) returns 21 and Abs(21) returns 21. The return value from the Abs function will be of the same type as that of the argument.
Sub Main()
        Print "Absolute value of .3456 is:",
Abs(.3456)
        Print "Absolute value of -.3456 is:",
Abs(.3456)
End Sub
Asc
Returns the ANSI numeric value for the first character in a string expression.
Asc(string expression)
The string expression argument can be any valid string; however, only the first character in the string expression will be evaluated. Any subsequent characters will be ignored.
See the code Example for the Chr internal function.
Atn
Computes the arctangent of a number.
The return value of Atn is expressed in radians. The return type for Atn is Double.
Atn(numeric expression)
Chr
Returns a string containing the character represented by the ANSI numeric code argument.
Chr(numeric expression)
Sub Main()
        Dim i as Integer
        Dim c as String
        For i = 1 to 255
        c = Chr(i)
                Print "character:", c
End Sub
Cos
Computes the cosine of a number.
The return value of Cos is expressed in radians. The return type for Cos is Double.
Cos(numeric expression)
DateSerial
Returns a date value given the year, month, and day as arguments.
If an invalid date has been specified, the system will display an error.
DateSerial(year, month, day)
The arguments for this function accept any numeric expression which evaluates to the following integer values:
       year - 100 to 9999 inclusive
       month - 1 to 12 inclusive
       day - 1 to 31 inclusive.
Sub Main ()
        Dim myyear As Integer
        Dim mymonth As Integer
         Dim myday As Integer
        Dim mybirthday As Date
        myyear = 1971 : mymonth = 7 : myday = 9
        mybirthday = DateSerial(myyear, mymonth, myday)
                Print "My birthday is:", mybirthday
End Sub
DateValue
Returns a date value given a string argument.
DateValue(string expression)
The argument for this function is any string expression that represents a valid date. If an invalid string has been specified, the system will display an error.
Sub Main()
        Dim mydatestr As String
        Dim mybirthday As Date
         mydatestr = "7/9/71"
        mybirthday = DateValue (mydatestr)
                Print "My birthday is:", mybirthday
End Sub
Day
Returns the day of the month (1-31) for any valid date expression.
Day(date expression)
Sub Main()
        Dim d As Date
        Dim daynum As Integer
        d = Today
        daynum = Day(d)
        Select Case daynum
                Case 1, 21, 31
                         Print "Today is the "; daynum; "st of the month"
                Case 2, 22
                        Print "Today is the "; daynum; "nd of the month"
                 Case 3, 23
                        Print "Today is the "; daynum; "rd of the month"
                Case Else
        End Select
End Sub
Exp
Returns the natural logarithm base number e raised to the power of a numeric argument.
The return value is a floating-point number.
Exp(numeric expression)
The argument for this function can be any valid numeric expression.
Fix
Removes the fractional part of a number and return the truncated value as an integer (or a long).
This is identical to the Int function.
Fix(numeric expression)
The argument may be any valid numeric expression.
Sub Main()
        Dim mynum As Double
        mynum = 3.1415
                 Print "The whole number part of 'mynum' is:"; Fix (mynum)
                Print "...and the decimal part of the number is:"; mynum - Fix(mynum)
End Sub
Hex
Returns the string containing the hexadecimal value of a number.
Hex(numeric expression)
The numeric expression argument is rounded to an integer value before being evaluated.
Sub Main()
        Dim i As Integer
        Dim hexval As String
        For i = 0 to 256
                hexval = Hex(i)
                        Print "decimal:", i
                        Print "hex:", hexval
        Next i
End Sub
Hour
Returns an integer (0-23) that represents the hour from any valid date expression.
Hour(date expression)
Sub Main()
        ...
        Dim secnum As Integer, minnum As Integer,
         hournum As Integer
        ...
        secnum = Second(d)
                Print "The current second is "; secnum
End Sub
IIf (immediate if)
Evaluates the expression and returns one of two possible values.
IIf can only be used to return either of two values rather than directing programmatic flow. The return type of IIf is the same as that of the value that is returned.
IIf(conditional expression, trueval, falseval)
The trueval and falseval arguments can be of any type. These arguments do not need to be the same data type.
Sub Main()
        Dim i As Integer
        For i = 1 to 10
                 Print "the value of i is";
IIf(i<=5, "less than or equals", "greater than"); "5"
        Next i
End Sub
InStr
Returns the position of the first occurrence of one string (searchstring) within another (sourcestring).
InStr([start,]) sourcestring, searchstring [case])
The optional start argument is a valid numeric expression used to offset the starting position of the search in sourcestring. If the start argument is omitted, the default starting offset is 1. The optional case argument is used to determine the case sensitivity of the comparison.

If case is 0, the comparison is case sensitive, for example, "a"<>"A". If case is 1, the comparison is case insensitive, for example, "a"="A". If the case argument is omitted, the default behavior is case sensitive comparisons. If the case argument is used, the start argument is required.

If searchstring is found within the sourcestring, this function returns an integer that indicates the character position of the first occurrence of the string. If searchstring was not found, InStr returns 0. If searchstring is a zero-length string, start is returned.
Sub Main()
        Dim s As String, Ioc As Integer
        s = "the quick brown fox jumps over the lazy dog"
        Ioc = InStr(s, "fox")
        If Ioc<>0 Then
                Print "The string 'fox' was first found at character position "; Ioc
        Else
                Print "The string 'fox' was not found in the search string"
        End If
End Sub
Int
Removes the fractional part of a number and returns the truncated value as an integer (or a long).
Int(numeric expression)
The argument can be any valid numeric expression.
Sub Main()
        Dim mynum As Double
        mynum = 3.1415
                 Print "The whole number part of 'mynum' is:"; Int(mynum)
                Print "...and the decimal part of the number is:"; mynum - Int(mynum)
End Sub
IsArray
Determines whether the supplied argument is an array. It returns TRUE or FALSE depending on whether the supplied argument is an array.
IsArray(variablename)
Sub Main()
        Dim i As Integer
        Dim arr(10) As Integer
        If IsArray(arr) Then
                For i = LBound(arr) To UBound(arr)
                        arr(i) = i
                Next i
        End If
End Sub
IsDate
Determines whether the supplied argument is a valid date. It returns TRUE or FALSE depending on whether the supplied argument is a valid date.
IsDate (date expression)
The date expression argument may be a string, date, or any numeric data type.
Sub Main()
        Dim d As Date
        Dim s As String
        s = "1/2/97"
        If IsDate(s) Then
                d=s
                Print "Valid date format"
         Else
                Print "Invalid date format"
        End If
End Sub

IsNumeric
Determines whether the supplied argument is numeric. It returns TRUE or FALSE depending on whether the supplied argument is a valid numeric expression.
IsNumeric(expression)
LaunchURL
Launches a URL (http, ftp, fcp, mailto...) on the FirstClass client.
LaunchURL(URL string)
Supply the desired URL as a string to the command and it will be launched in the registered browser, mail client, or other applicable application.
Sub Main()
        LaunchURL ("http://www.firstclass.com")
End Sub
LBound
Returns an integer indicating the lower bound of an array.
If the variable is not an array, an error occurs.
LBound(array variable)
Sub Main()
        Dim i As Integer
        Dim arr(10) As Integer
        If IsArray(arr) Then
                For i = LBound(arr) To UBound(arr)
                        arr(i) = i
                Next i
        End If
End Sub
LCase
Returns a string argument converted to all lowercase letters.
LCase(string expression)
Sub Main()
        Dim s As String
        s = LCase ("hEllo wOrld")
         Print s
'displays "hello world"
        Print LCase("THIS IS NOW LOWERCASE")
'displays "this is now lowercase"
End Sub
Left
Returns a string containing the leftmost characters of a string argument.
Left(string expression, numeric expression)
The numeric expression argument can be any valid integer value greater than or equal to 0. If numeric expression is greater than or equal to the length of string expression, the entire string is returned.
Sub Main()
        Dim s As String, Ioc As Integer
        s = "the quick fox jumps over the dog"
         Ioc = InStr(s, " ")             'find the first occurrence of a space character
        If Ioc<>0 Then
                Print "The first word in the sentence is:"; Left(s, Ioc - 1)
                 Print "The rest of the sentence is:"; Right(s, Len(s) - Ioc)
        Else
                print "Invalid sentence (no spaces)."
        End If
End Sub
Len
Returns the length of a string argument (as an integer), or the number of bytes required to create a variable.
Len (string expression|variable name)
The argument string expression can be any valid string expression.
Sub Main()
        Dim s As String, length As Integer
        Dim x As Long, y As Double
         s = "the quick brown fox jumps over the lazy dog"
        length = Len(s)
        ...
                Print "The size of Double is"; Len(y); "bytes"
End Sub
Log
Computes the natural logarithm of a number.
Log(numeric expression)
LTrim
Returns a string with all leading space and tab characters removed.
LTrim(string expression)
The argument string expression can be any valid string.
Sub Main()
        Dim s As String
        s = "           test string     "
                Print "(" & LTrim(s) &  ")"     
        'prints (test string            )
End Sub
Mid
Returns a substring from within a string expression.
Mid(string expression, start offset [,length])
The string expression argument can be any valid string. The start  offset argument specifies the character offset from which to retrieve the substring. The optional length argument indicates the number of characters to return. If the length argument is omitted, Mid returns all characters from the start offset to the end of the string. If length is longer than the remaining number of characters in the string, all characters from the start and offset to the end of the string are returned.
Sub Main()
        Dim s As String
        Dim loc As Integer, loc2 As Integer
         s = "the quick fox runs fast"
        loc = InStr(1, s, " ")
        loc2 = InStr(loc + 1, s, " ")
                Print "token:"; Mid(s, loc + 1, loc2 - loc - 1);" ' "
End Sub
Minute
Returns an integer (0-59) that represents the minute from any valid date expression.
Minute(date expression)
See the code example for the Second internal function.
Month
Returns the month of the year for any valid date expression.
Month(date expression)
Sub Main()
        Dim d As Date
        Dim monthnum As Integer
        d = Today
        monthnum = Month(d)
                Select Case monthnum
                         Case 1
                                Print "This is the "; monthnum; " month of the year"
                        ...
                         Case Else
                                Print "This is the   "; monthnum; " month of the year"
                End Select
End Sub
MsgBoxResponse
Returns the value of the last user input to the MsgBox BASIC command.
MsgBoxResponse returns one of these constant values:
       fcOK - user clicked the OK button
       fcCancel - user clicked the Cancel button
       fcYes - user clicked the Yes button
       fcNo - user clicked the No button.
MsgBoxResponse
See the code example for the Sgn internal function.
Now
Returns a date value containing the current time and date from the server's system clock.
Now
Sub Main()
        Dim d As date
        d = Now
        Print "The current time and date is: ", d
End Sub
Oct
Returns a string containing the octal value of a number.
Oct(numeric expression)
The numeric expression argument is rounded to an integer value before being evaluated.
See the code example for the Hex internal function.
Randomize
Initializes the random number generator to seed new random numbers.

81203_42521_14.png        Note
If the Randomize command is not used the Rnd function will return the same list of random numbers every time it is run. The optional argument seed indicates the numeric key from which to generate the random number list. Using the same seed value each time a program is run will generate the same list of random numbers. If the seed argument is omitted, Randomize generates a random number list using the Timer function.
Randomize [seed]
The following example demonstrates how the Randomize function can be used to create a new list of random numbers each time the program is run.

Sub Main ()
        Dim i As Integer
        Randomize
        Print "Generating 25 random numbers from 1 to 100*
        For i = 1 to 25
                Print (100 * Rnd) + 1
        Next i
End Sub
Replace
Searches the source string for all occurrences of the search string. Each time the search string is found, it is replaced with the defined replacement string.
Replace(sourcestring, searchstring, replacestring)
The sourcestring, searchstring, and replacestring arguments can be any valid string expressions.
Sub Main()
        Dim s As string
        s = "one, two, three, four, five"
         s = Replace(s, ",", ";")
        ' s is now assigned "one; two; three; four; five"
        Print s
End Sub
Right
Returns a string containing the right-most characters of a string argument.
Right(string expression, numeric expression)
numeric expression can be any valid integer value greater than or equal to 0. If numeric expression is greater than or equal to the length of the string expression, the entire string is returned.
See the code example for the Left internal function.
Rnd
Returns a random fractional number from 0 to 1.
81203_42521_14.png        Note
To seed the Rnd function with new values, use the Randomize BASIC command.
Rnd
See the code example for the Randomize command.
Round
Removes the fractional part of a number and returns the rounded value as an integer (or a long). Numbers with fractional parts greater than or equal to 0.5 will be rounded up to the nearest integer value. Numbers with fractional parts less than 0.5 will be rounded down.
Round(numeric expression)
The argument can be any valid numeric expression.
Sub Main()
        Dim mynum As Double
        Dim i as integer
         For I = 1 to 20
                mynum = i/10
                        Print "The value of 'mynum' is: "; mynum
                        Print "The rounded value of 'mynum' is: ";
Round(mynum)
        Next i
End Sub 
RTrim
Returns a string with all trailing space and tab characters removed.
RTrim(string expression)
The argument string expression can be any valid string.
Sub Main()
        Dim s As String
        s = "                  test string
                Print "(" & RTrim(s) & ")"
                'prints (           test string)
End Sub 
Second
Returns an integer value that represents the seconds from any valid date expression.
Second(date expression)
Sub Main()
        Dim d As Date
        Dim secnum As Integer, minnum As Integer, hournum As Integer
        d = Time
        hournum = Hour (d)
        minnum = Minute (d)
        secnum = Second (d)
                Print "The current hour is  "; hournum
                Print "The current minute is  "; minnum
                Print "The current second is  "; secnum
End Sub 
Sgn
Returns an integer value indicating the sign of a number.
Sgn(numeric expression)
The numeric expression argument can be any valid numeric expression. If the value of a numeric expression is less than 0, Sgn returns -1. If the value of a numeric expression is greater than 0, Sgn returns 1. If the value of a numeric expression is 0, Sgn returns 0.
Sub Main()
        Dim dbl As Double
        Dim mysign As Integer
        dbl = 3.1415
        mysign = Sgn (dbl)
        If mysign < 0 Then
                Print "The value of 'dbl' is negative"
        Else
                If mysign > 0
                        Print "The value of 'dbl' is positive"
                Else
                        Print "The value of 'dbl' is zero"
                End If
        End If
End Sub
Shell
Runs an executable program on the server.
Programs run on the server may have command line arguments passed to them, however, no additional input may be provided to the running program. Operating system shell commands may also be run from this function. Shell returns an integer value that is the command interpreter's error code. 0 indicates that the command interpreter was able to begin processing the request. Non-zero indicates an error.
Shell(string expression)
The argument must be the full path and executable name of the program to be run on the server.
Sub Main()
        Dim rc As Integer
        rc = Shell ("Copy C:\FCPO\LogFiles\*.* C:\Backup\LogFiles")
        If rc = 0 Then
                Print "Copy has started successfully."
        Else
                 Print "Could not begin copy."
        End If
End Sub 
Sin
Computes the sine of a number.
The return value of Sin is expressed in radians. The return type for Sin is Double.
Sin(numeric expression)
Space
Returns a string containing a number of space characters indicated by the argument.
Space(numeric expression)
The argument can be any valid numeric expression.
Sub Main()
        Dim MyStringVariable As String
        MyStringVariable = Space(15) ' returns a string with 15 spaces
        'to the variable MyStringVariable
                Print MyStringVariable
Spawn
Runs a process or application on the FirstClass server.
This function has several advantages over the Shell() function and, where possible, should be used in place of that function.
Spawn(application name [fcWait | fcNoWait])
application name contains a text string which is the application name to be executed, including any command line arguments.
The second argument is a constant, which specifies whether the application should wait until the called process has completed (fcWait: synchronous; can block the FirstClass server) or whether the application should launch the process and continue executing (fcNoWait: asynchronous; never blocks the FirstClass server).
Spawn ("C:\Acrobat3\Reader\AcroRd32.exe", fcNoWait) 'launches a program on the server and immediately resumes processing the application'
End Sub
Sqr
Returns the square root of any valid numeric expression (as a floating-point number).
Sqr(numeric expression)
Sub Main()
        Print "The square root of 2 is:", Sqr(2)
End Sub
StartupString
Returns the startup string (command line argument) for an application.
This is used to differentiate different installations of an application or to seed an FCAS program with initial values.
StartupString
Sub Main()
        Print "The command line argument for this application is";
        StartupString
End Sub
Str
Returns a string representation of a number (for any valid numeric expression).
Str(numeric expression)
Sub Main()
        Dim cost As String
        Dim output As String
        cost = Str(5000)
        output = "the total cost is: " & cost
                Print output
End Sub
StrComp
Compares two string expressions.
StrComp(string1, string2,[, case])
The optional case argument is used to determine the case sensitivity of the comparison. If case is 0, the comparison is case sensitive ("a" <> "A"). If case is 1, the comparison is case insensitive ("a" = "A"). If the case argument is omitted, the default behavior is case-sensitive comparisons ("a" <> "A"). StrComp returns the following integer values based on the comparison evaluation:
       -1 string1 < string2
       0 string1 = string2
       1 string1 > string2
        undefined       NULL string.
Sub Main()
        Dim s As String
        s = "aaa"
        Select Case StrComp(s, "bbb")
        Case -1
                Print "Source string is less than comparison string."
         ...
        End Select
End Sub
StrFill
Creates a string of repeating characters of a specified length.
StrFill(numeric expression, character expression)
The numeric expression argument specifies the number of characters in the result string. The character expression argument can be either a string representation or the ANSI code of a character. If the character is passed as a string representation, only the first character of the string is used.
Sub Main()
        Dim MyStringVariable As String
        MyStringVariable = StrFill(5, "@") ' returns "@@@@@
        Print MyStringVariable
        ...
End Sub
StrSplit
This command is exactly like StrToken except that it will not skip double delimiters.
StrToken
Parses a delimited string into its component substring tokens. This enhances FCAS's ability to quickly and easily parse delimited strings.
StrToken(sourcestring, delimiters, tokennumber)
StrToken takes 3 arguments:
       sourcestring -  contains a delimited list of substring tokens
       delimiters - a text string which specifies all of the delimiters to use when separating tokens
       tokennumber - the ordinal number of the substring to return (starting with 1 for the first string).
This Example gets the last login time of the administrator and breaks the resulting batch administration reply up into its constituent substrings. This code uses both the space character and the double-quote character (Chr(34)) as delimiters for the delimiters argument. Batch administration replies without quotes will not need the Chr(34) as delimiters for the delimiter argument. Batch administration replies without quotes will not need the Chr(34) delimiter and can simply use the space or other delimiter as needed.
Sub Main()
        BatchAdmin ("Get User Admin 123 +d")
        Print "source string:"; fcBatchAdminReply
        Print "substring 1:"; StrToken (fcBatchAdminReply, " " & Chr(34), 1)
        Print "substring 2:" ; StrToken(fcBatchAdminReply, " " & Chr(34), 2)
        Print "substring 2:" ; StrToken(fcBatchAdminReply, " " & Chr(34), 3)
        Print "substring 2:" ; StrToken(fcBatchAdminReply, " " & Chr(34), 4)
End Sub
Running this code gives you the following output (dates and times will vary on your system):
        source string: 1230 14 "2000/01/04  13:30:39"
        substring 1: 1230
        substring 2: 14
        substring 3: 2000/01/04
        substring 4: 13:30:39
Tab
Returns a string containing the Tab character.
Tab
Sub Main()
        Dim s As String
        s = "apple" & Tab & "orange" & Tab & "grape"
        Print s 'creates a tab-delimited list of strings and displays them to output window
End Sub
Tan
Computes the tangent of a number.
The return value of Tan is expressed in radians. The return type for Tan is Double.
Tan(numeric expression)
TCase
Returns a string argument converted to title case.
TCase(string expression)
Sub Main()
        Dim s As String
        s = TCase("jon q. public")
         Print s                         'displays "jon q. public"
End Sub
Time
Returns the current time from the server's system clock.
Time
See the code example for the Second internal function.
Timer
Returns the number of seconds that have elapsed since 12:00 AM. This is useful for benchmarking application operations.
Timer
Sub Main()
        Dim timestart As Integer, timefinish As Integer
        timestart = Timer
         MsgBox("How fast can you click OK?")
        timefinish = Timer
                Print "It took you "; timefinish - timestart; "seconds to click OK"
End Sub
TimeSerial
Returns a date data type value given the hour, minute, and second as arguments.
If an invalid time has been specified, the system will display an error.
TimeSerial(hour, minute, second)
The arguments for this function accept any numeric expression that evaluates to the following integer values:
       hour - 0 to 23 inclusive
       minute - 0 to 59 inclusive
       second - 0 to 59 inclusive.
Sub Main()
        Dim meethour As Integer
        Dim meetmin As Integer
         Dim meetsec As Integer
        Dim mymeeting As Date
        meethour = 14: meetmin = 15: meetsec = 0
        mymeeting = TimeSerial(meethour, meetmin, meetsec)
         Print "I have a meeting at:", mymeeting
End Sub
TimeValue
Returns a date data type, given a string argument.
TimeValue(string expression)
The argument for this function is any string expression that represents a valid time. If an invalid time string has been specified, the system will display an error.
Sub Main()
        Dim mytimestr As String
        Dim mymeeting As Date
         mytimestr = "2:15:00 PM"
        mymeeting = TimeValue(mytimestr)
        Print "I have a meeting at: ",mymeeting
End Sub
Today
Returns the current date from the server's system clock.
Today
See the code example for the Day internal function.
Trim
Returns a string with all leading and trailing space and tab characters removed.
Trim(string expression)
The argument string expression can be any valid string.
Sub Main()
        Dim s As String
        s="     test string     "
        Print "(" & Trim(s) & ")"
        'prints (test string)
End Sub
UBound
Returns an integer indicating the upper bound of an array.
If the variable is not an array, an error occurs.
UBound(array variable)
See the code example for the IsArray internal function.
UCase
Returns the string argument converted to all uppercase letters.
UCase(string expression)
Sub Main()
        Dim s As String
        s = UCase(hELlo wOrld")
                 Print s 'displays "HELLO WORLD"
                Print UCase ("this is now uppercase")
'displays "THIS IS NOW UPPERCASE"
End Sub
Val
Returns the numeric value of a string argument.
Val(string expression)
The string expression argument can be any string that represents a number. If string expression contains the decimal point character, Val returns a floating-point value, otherwise Val returns an integer value.
Sub Main()
'this program converts string "50" into a number and then uses the number in a math calculation
        Dim s As String
         Dim num As Integer
        s = "50"
        num = Val(s)
                Print "The numeric value of 's' times 5 is: ",num *5
End Sub
Weekday
Returns a number indicating the day of the week for any valid date expression.
Weekday(date expression)
Sub Main()
        Dim d As Date
        Dim daynum As Integer
        Dim mydays(1 to 7) As String
        mydays(1) = "Sunday": mydays(2) = "Monday":...
        d = today
        daynum = Weekday(d)
                Print "Today, the day of the week is"; mydays(daynum)
End Sub
Year
Returns the year from any valid date expression.
Year (date expression)
Sub Main()
        Dim d As Date
        Dim yearnum As Integer
        d = Today
        yearnum = Year(d)
                Print "This year is"; yearnum; "A.D."
End Sub


hirosue Shino Web Site