RMCLink COM Component

RMCLink.ReadLFile_Script Method

Reads one or more integer (L) registers from the controller. This method is only for use in VBScript or JScript. Use the ReadLFile method with other languages. ReadLFile_Script is typically used to read RMC100 registers (which are all integer registers), or to read RMC70, RMC150, or RMC200 registers in integer format.

Syntax

Visual Basic (Declaration)

Function ReadLFile_Script ( _

   file As Long, _

   element As Long, _

   count As Long _

) As Variant

 

Visual Basic (Usage)

Dim instance As RMCLink

Dim file As Long

Dim element As Long

Dim count As Long

Dim returnValue As Variant

 

returnValue = instance.ReadLFile_Script(file, element, count)

Parameters

file

File number of the first register to be read. See the RMCLink Register Reference for details.

element

Element number of the first register to be read. See the RMCLink Register Reference for details.

count

The number of registers to read.

Return Value

This variant will be filled with the data read from the controller. The variant data type will be a single-dimension 0-based array of Variant elements, each which in turn holds a Long. The length is determined by count.

Remarks

The only difference between ReadLFile_Script and ReadLFile is the format of the data returned in the Variant return value. For ReadLFile, the Variant holds a single-dimension 0-based array of Long elements. For ReadLFile_Script, the Variant holds a single-dimension 0-based array of Variant elements, and each Variant element in turn holds a Long. This extra layer of indirection is required by some scripting languages (VBScript and JScript, for example), but is other less efficient and should be avoided when ReadLFile is supported by your language.

Notice that JScript arrays are not directly compatible with the arrays returned by ReadLFile_Script. Therefore, before using the array elements, you must call JScript's toArray method on the variable returned by ReadLFile_Script. See the JScript example below.

For details on integer (L) and floating-point (F) registers and how to read from and write to both, see RMC100 Register Data Types or RMC70, RMC150, and RMC200 Register Data Types.

This method is synchronous, which means that it will not return until the read is completed, which may take several seconds. If this method is called on the main thread, then the application will likely be unresponsive until this method completes. For applications where this is not acceptable, this and other synchronous methods should be called from a worker thread, and may use the CancelRequest method to cancel an in progress request.

Exceptions

Error Code

Description

rmcEOutOfMemory = 5

Out of memory.

rmcEInvalidArg = 7

One of the file, element, or counts parameters are out of range.

rmcEDisconnecting = 1002

Link is being disconnected by another thread.

rmcEDisconnected = 1005

The link has not been connected.

rmcESocketInternal = 1008

Internal socket error.

rmcECancelled = 1010

Operation cancelled by call to CancelRequest.

rmcETimeout = 1011

Operation timed out.

rmcESocketGracefullyClosed = 1014

TCP/IP connection closed by remote device.

rmcESocketReadError = 1015

Connection error while waiting for response from the remote device.

rmcESocketInvReadLen = 1016

Connection error while waiting for response from the remote device.

rmcESocketWriteError = 1017

Connection error while sending request to the remote device.

rmcESocketInvWriteLen = 1018

Connection error while sending request to the remote device.

rmcESerialIOE = 1021

Serial IOE error.

rmcESerialFramingError = 1022

Serial framing error.

rmcESerialBreak = 1023

Serial Break error.

rmcESerialOverrun = 1024

Serial overrun.

rmcESerialRxOverrun = 1025

Serial receive overrun.

rmcESerialParityError = 1026

Serial parity error.

rmcESerialTxFull = 1027

Serial transmitter full.

rmcEConnectionBroken = 1028

Connection broken.

rmcEPartialWrite = 1029

Unable to send full request to the remote device.

rmcEBadAddress = 1032

Attempt to read beyond the end of a file.

rmcEUSBInternal1 = 1051

Internal USB driver error.

rmcEUSBOperationAborted = 1053

Unsuccessful transfer of data between the PC and the controller. Ensure that the physical connection between the PC and controller is still intact.

rmcEUSBDisconnected = 1054

The controller appears to have been disconnected from the USB port. Ensure that the physical connection between the PC and controller is still intact.

Example

The following code example illustrates the use of the ReadLFile_Script method.

VBScript

Option Explicit
Dim srv, rmc, data
 
' First we need to create the RMCLinkServer COM object.
Set srv = CreateObject("RMCLink.RMCLinkServer")
 
' Use our RMCLinkServer to create the correct type of RMCLink object.
' NOTE: VBScript does not support enumerations, so we use the literal value (dtRMC100=1).
Set rmc = srv.CreateEthernetLink(1, "192.168.0.28")
 
' Establish the connection.
rmc.Connect
 
' Read L0:1-2 (Axis 0 Target and Actual Positions)
data = rmc.ReadLFile_Script(0,1,2)
WScript.Echo "Target Pos. = " & data(0) & ", Actual Pos. = " & data(1)
 
' Close the connection.
rmc.Disconnect

 

JScript

// First we need to create the RMCLinkServer COM object.
var srv = new ActiveXObject("RMCLink.RMCLinkServer");
 
// Use our RMCLinkServer to create the correct type of RMCLink object.
// NOTE: JScript does not support enumerations, so we use the literal value (dtRMC100=1).
var rmc = srv.CreateEthernetLink(1, "192.168.0.28");
 
// Establish the connection.
rmc.Connect();
 
// Read L0:1-2 (Axis 0 Target and Actual Positions)
var data = rmc.ReadLFile_Script(0,1,2).toArray();
WScript.echo("Target Pos. = " + data[0] + ", Actual Pos. = " + data[1]);
 
// Close the connection.
rmc.Disconnect();

 

See Also

RMCLink Class | RMCLink COM Component | ReadLFile | ReadFFile_Script


Send comments on this topic.

Copyright (c) 2024 Delta Computer Systems, Inc. dba Delta Motion