4MELFA-BASIC V
MELFA-BASIC V functions
4-112
4.1.5 Communication
Data can be exchanged with an external device, such as a personal computer.
*Command word
*Statement example
*Related functions
Command word
Explanation
Open
Opens the communication line.
Close
Closes the communication line.
Print#
Outputs the data in the AscII format. CR is output as the end code.
Input#
Inputs the data in the AscII format. The end code is CR.
On Com GoSub
Defines the subroutine to be called when an interrupt is generated from the communication line.
The interrupt is generated when data is input from an external device.
Com On
Enables the interrupt process from the communication line.
Com Off
Disables the interrupt process from the communication line. The interrupt will be invalid even if it
occurs.
Com Stop
Stops the interrupt process from the communication line. If there is an interrupt, it is saved, and
is executed after enabled.
Statement example
Explanation
Open "COM1:" AS #1................................
Opens the communication line COM1 as file No. 1.
Close #1 ....................................................
Closes file No. 1.
Close .........................................................
Closes all files that are open.
Print#1,"TEST" ..........................................
Outputs the character string "TEST" to file No. 1.
Print#2,"M1=";M1 ......................................
Output the character string "M1=" and then the M1 value to file No. 2.
Output data example: "M1 = 1" + CR (When M1 value is 1)
Print#3,P1..................................................
Outputs the position variable P1 coordinate value to file No. 3.
Output data example: "(123.7, 238.9, 33.1, 19.3, 0, 0)(1, 0)" +CR
(When X = 123.7, Y=238.9, Z=33.1, A=19.3, B=0, C=0, FL1=1, FL2=0)
Print#1,M5,P5............................................
Outputs the numeric variable M5 value and position variable coordinate value to file No. 1.
M5 and P5 are separated with a comma (hexadecimal, 2C).
Output data example: "8, (123.7, 238.9, 33.1, 19.3, 0, 0)(1, 0)"+CR
(When M5=8, P5 X=123.7, Y=238.9, Z=33.1, A=19.3, B=0, C=0, FL1=1, FL2=0)
Input#1,M3 ................................................
Converts the input data into a value, and substitutes it in numeric variable M3.
Input data example: "8" + CR (when value 8 is to be substituted)
Input#1,P10 ...............................................
Converts the input data into a value, and substitutes it in position variable P10.
Input data example: "8, (123.7, 238.9, 33.1, 19.3, 0, 0)(1, 0)"+CR
(P5 will be X= 123.7, Y=238.9, Z=33.1, A=19.3, B=0, C=0, FL1=1, FL2=0)
Input#1,M8,P6 ...........................................
Converts the first data input into a value, and substitutes it in numeric variable M8. Converts the data
following the command into a coordinate value, and substitutes it in position variable P6. M8 and P6 are
separated with a comma (hexadecimal, 2C)
Input data example: "7,(123.7, 238.9, 33.1, 19.3, 0, 0)(1, 0)"+CR
(The data will be M8 = 7, P6 X=123.7, Y=238.9, Z=33.1, A=19.3, B=0, C=0, FL1=1, FL2=0)
On Com(1) GoSub *SUB3.........................
Defines to call step *SUB3 subroutine when data is input in communication line COM1.
On Com(2) GoSub *RECV ........................
Defines to call subroutine at label RECV step when data is input in communication line COM2.
Com(1) On.................................................
Enables the interrupt from communication line COM1.
Com(2) Off.................................................
Disables (prohibits) the interrupt from communication line COM2.
Com(1) Stop ..............................................
Stops (holds) the interrupt from communication line COM1.
Function
Explanation page
Subroutine........................................................................................................
Interrupt............................................................................................................