4MELFA-BASIC IV
Logic numbers 4-144
4.4 Logic numbers
Logic numbers indicate the results of such things as comparison and input/output.
If not 0 when evaluated with an Integer, then it is true, and if 0, it is false. When substituted, if true, 1 is
assigned. The processes that can use logic numbers are shown in Table 4-9.
Table 4-9:Values corresponding to true or false logic number
4.5 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-10.
Table 4-10:List of built-in functions
Items expressed with logic number "1" Items expressed with logic number "0"
*Result of cmparison operation (if true)
*Result of logic operation (if true)
*Switch ON
*Input/output signal ON
*Hand open (supply current to the hand)
*Settings for enable/valid such as for interrupts
*Result of comparison operation (if false)
*Result of logic operation (if false)
*Switch OFF
*Input/output signal OFF
*Hand close (do not supply current to the hand)
*Settings for disable/invalid such as for interrupts
Class Function name (format) Functions
Page
Result
Numeric func-
tions
Abs (<Numeric expression>) Produces the absolute value
308 Numeric
value
Cint (<Numeric expression>) Rounds off the decimal value and converts into an integer.
313
Deg (<Numeric expression:radian>) Converts the angle unit from radian (rad) to degree (deg).
316
Exp (<Numeric expression>) Calculates the value of the expression's exponential function
317
Fix (<Numeric expression>) Produces an integer section
318
Int (<Numeric expression>) Produces the largest integer that does not exceed the value in the
expression.
320
Len(<Character string expression>) Produces the length of the character string.
322
Ln (<Numeric expression>) Produces the logarithm.
323
Log (<Numeric expression>) Produces the common logarithm.
323
Max (<Numeric expression>...) Obtains the max. value from a random number of arguments.
324
Min (<Numeric expression>...) Obtains the min. value from a random number of arguments.
325
Rad (<Numeric expression: deg.>) Converts the angle unit from radian (rad) to degree (deg).
329
Sgn (<Numeric expression>) Checks the sign of the number in the expression
336
Sqr (<Numeric expression>) Calculates the square root
337
Strpos(<Character string expres-
sion>, <Character string expres-
sion>)
Obtains the 2nd argument character string position in the 1st argu-
ment character string.
337
Rnd (<Numeric expression>) Produces the random numbers.
331
Asc(<Character string expression>) Provides a character code for the first character of the character
string in the expression.
310
Cvi(<Character string expression>) Converts a 2-byte character string into integers.
315
Cvs(<Character string expression>)
Converts a 4-byte character string into a single-precision real number. 315
Cvd(<Character string expression>)
Converts an 8-byte character string into a double-precision real number. 316
Val(<Character string expression>) Converts a character string into a numeric value.
339
Trigonometric
functions
Atn(<Numeric expression>) Calculates the arc tangent. Unit: radian
Definition range: Numeric value, Value range: -PI/2 to +PI/2
310 Numeric
value
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
310