Avisaro Online Documentation - Wiki
Impressum Kontakt Sitemap

GET

Description

The GET command can be used to read data from a file, network connection or I/O interface. GET needs two arguments. The first argument is a handle number that designates the source and the second one is the target variable, which should be filled by GET. The maximum number of bytes that will be read with one call depends on the size of the target variable. For a 32 bit signed integer, GET reads up to four bytes. For a 1000 bytes byte-array, get will read up to 1000 bytes.

GET knows the following sources:

(0...100) File handles. Any file that is open for reading.

(101...200) TCP connections. Any established TCP connections.

(201...300) UDP channels. Any UDP channel that is open.

(-3) The current selected I/O interface. New since version 3.36

(-4) The auxiliary RS232 port. 

(-5) The auxiliary IIC port using stop conditions.

(-6) The auxiliary IIC port but without using stop conditions.

(-7) The primary CAN interface (complete frames). The module must have CAN as I/O protocol enabled.

(-8) The auxiliary CAN interface. The program must enable this port with AUXOPEN

(-100...-105) An edit control of the web page.

(-201...-224) Digital I/O lines.  New since version 3.48

(-301...-324) Analog I/O lines. New since version 3.51

GET can use the following targets:

A complete array, either byte- or integer-based

A single element of a byte- or integer array

A string variable

A 32 bit signed integer variable

Example

The following example opens an UDP channel. Incoming data is transferred into the array a which then is printed to the console:

DIM a(500)
LET x = RESOLV ("255.255.255.255")
UDPOPEN 201, x, 25, 25, 5, 0
DO
   GET 201, a
   IF BYTESREAD <> 0 THEN
      FOR n=0 TO BYTESREAD
         PRINT a(n)
       NEXT
   END IF
LOOP

Remarks

GET sets the LASTERR and BYTESREAD pseudo variables to let the program know what happened. If GET encounters an error, LASTERR will become an error value other than 0 (ERR_OK). After GET returns and LASTERR is 0, BYTESREAD contains the number of bytes that were actually transferred. This can be a value in the range from 0 (nothing transferred) to the size of the target variable (all requested bytes have arrived).

Handles -4, -5 and -6 are available only when the according I/O interface was activated with AUXOPEN. For handles -201...-224, pin functions must be properly set by using the command interface's PORT command.

Digital and Analog I/O ports can only be read into signed integer variables.
See also the PUT command.