4-160 Functions
4MELFA-BASIC V
4.7 Functions
A function carries out a specific operation for an assigned argument, and returns the result as a numeric
value type or character string type. There are built-in functions, that are preassembled, and user-defined
functions, defined by the user.
(1) User-defined functions
The function is defined with the Def FN statement.
Example) Def FNMADD(MA, MB)=MA+MB
...........The function to obtain the total of two values is defined with FNMADD.
The function name starts with FN, and the data type identification character (C: character string, M: numeric
value, P: position, J: joint) is described at the third character. The function is designated with up to eight
characters.
(2) Built-in functions
A list of assembled functions is given in Table 4-11.
Table 4-11:List of built-in functions
Class Function name (format) Functions
Page
Result
Numeric func-
tions
Abs (<Numeric expression>) Produces the absolute value
398 Numeric
value
Cint (<Numeric expression>) Rounds off the decimal value and converts into an integer.
405
Deg (<Numeric expression:radian>) Converts the angle unit from radian (rad) to degree (deg).
408
Exp (<Numeric expression>) Calculates the value of the expression's exponential function
409
Fix (<Numeric expression>) Produces an integer section
410
Int (<Numeric expression>) Produces the largest integer that does not exceed the value in the
expression.
412
Len(<Character string expression>) Produces the length of the character string.
414
Ln (<Numeric expression>) Produces the logarithm.
415
Log (<Numeric expression>) Produces the common logarithm.
415
Max (<Numeric expression>...) Obtains the max. value from a random number of arguments.
416
Min (<Numeric expression>...) Obtains the min. value from a random number of arguments.
417
Rad (<Numeric expression: deg.>) Converts the angle unit from radian (rad) to degree (deg).
421
Sgn (<Numeric expression>) Checks the sign of the number in the expression
428
Sqr (<Numeric expression>) Calculates the square root
432
Strpos(<Character string expres-
sion>, <Character string expres-
sion>)
Obtains the 2nd argument character string position in the 1st argu-
ment character string.
432
Rnd (<Numeric expression>) Produces the random numbers.
423
Asc(<Character string expression>) Provides a character code for the first character of the character
string in the expression.
401
Cvi(<Character string expression>) Converts a 2-byte character string into integers.
407
Cvs(<Character string expression>)
Converts a 4-byte character string into a single-precision real number. 407
Cvd(<Character string expression>)
Converts an 8-byte character string into a double-precision real number. 408
Val(<Character string expression>) Converts a character string into a numeric value.
434
SplSpd(<Spline No.>) Obtains the maximum speed which can be specified without an
error from the path point data registered in a random spline file.
431
Trigonometric
functions
ACos(<Numeric expression>) Calculates the arc cosine. Unit: radian
Definition range: -1.0 to +1.0, Value range: 0 to PI
399 Numeric
value
ASin(<Numeric expression>) Calculates the arc sine. Unit: radian
Definition range: -1.0 to +1.0, Value range: -PI/2 to +PI/2
402
Atn(<Numeric expression>) Calculates the arc tangent. Unit: radian
Definition range: Numeric value, Value range: -PI/2 to +PI/2
402
Atn2(<Numeric expres-
sion>,<Numeric expression>)
Calculates the arc tangent. Unit: radian
THETA=Atn2(delta y, deltax)
Definition range: Numeric value of delta y or delta x that is not 0
Value range: -PI to +PI
402