4-113
MELFA-BASIC V functions
4MELFA-BASIC V
4.1.6 Expressions and operations
The following table shows the operators that can be used, their meanings, and statement examples.
(1) List of operator
Class
Operato
r
Meaning
Statement example
Substituti
on
=
The right side is
substituted in the left
side.
P1=P2
P5=P_Curr
P10.Z=100.0
M1=1
STS$="OK"
’Substitute P2 in position variable P1.
’Substitute the current coordinate value in current position variable P5.
’Set the position variable P10 Z coordinate value to 100.0.
’Substitute value 1 in numeric variable M1.
’Substitute the character string OK in the character string variable
STS$.
Numeric
value
operation
+
Add
P10=P1+P2
Mov P8+P9
M1=M1+1
STS$="ERR"+"001"
’GSubstitute the results obtained by adding the P1 and P2 coordinate
elements to position variable P10.
’Move to the position obtained by adding the position variable P8 and
P9 coordinate elements.
’Add 1 to the numeric variable M1.
’Add the character string 001 to the character string ERR and
substitute in character string variable STS$.
-
Subtract
P10=P1-P2
Mov P8-P9
M1=M1-1
’Substitute the results obtained by subtracting the P2 coordinate
element from P1 in position variable P10.
’ Move to the position obtained by subtracting the P9 coordinate
element from the position variable P8.
’Subtract 1 from the numeric variable M1.
*
Multiply
P1=P10*P3
M1=M1*5
’Substitute the relative conversion results from P10 to P3 in position
variable P1.
’Multiple the numeric variable M1 value by 5.
/
Divide
P1=P10/P3
M1=M1/2
’Substitute the reverse relative conversion results from P10 to P3 in
position variable P1.
’Divide the numeric variable M1 value by 2.
^
Exponential operation M1=M1^2
’Square the numeric variable M1 value.
\
Integer division
M1=M1\3
’Divide the numeric variable M1 value by 3 and make an integer
(round down).
MOD
Remainder operation
M1=M1 Mod 3
’Divide the numeric variable M1 value by 3 and leave redundant.
-
Sign reversal
P1=-P1
M1=-M1
’Reverse the sign for each coordinate element in position variable P1.
’Reverse the sign for the numeric variable M1 value.
Comparis
on
operation
=
Compare whether
equal
If M1=1 Then *L1
If STS$="OK" Then *L2
’Branch to step *L1 if numeric variable M1 value is 1.
’Branch to step *L2 if character string in character string variable STS$ is
OK.
<>
or
><
Compare whether not
equal
If M1<>2 Then *L3
If STS$<>"OK" Then *L4
’Branch to step *L3 if numeric variable M1 value is 2.
’Branch to step *L4 if character string in character string variable STS$
is not OK.
<
Compare whether
smaller
If M1< 10 Then *L3
If Len(STS$)<3 Then *L4
’Branch to step *L3 if numeric variable M1 value is less than 10.
’Branch to step *L4 if No. of characters in character string STS$
variable is less than 3.
>
Compare whether
larger
If M1>9 Then *L3
If Len(STS$)>2 Then *L4
’Branch to step *L3 if numeric variable M1 value is more than 9.
’Branch to step *L4 if No. of characters in character string variable
STS$ is more than 2.
=<
or
<=
Compare whether
equal to or less than
If M1<=10 Then *L3
If Len(STS$)<=5 Then *L4
’Branch to step *L3 if numeric variable M1 value is equal to or less
than 10.
’Branch to step *L4 if No. of characters in character string variable
STS$ is equal to or less then 5.
=>
or
>=
Compare whether
equal to or more than
If M1=>11 Then *L3
If Len(STS$)>=6 Then *L4
’Branch to step *L3 if numeric variable M1 value is equal to or more
than 11.
’Branch to step *L4 if No. of characters in character string variable
STS$ is equal to or more than 6.