Skip to main content
Skip table of contents

25.5 Lua Warnings

Lua will provide warnings to help you avoid common problems. Below is a list of warning and the recommended solutions.

Truncation: Possible truncation error.

A script tried to access a 32-bit integer. Depending on the value transferred, some precision may have been lost. See the floating point section in Section 25.0 for more details. To access a 32-bit value, use an array function of the LabJack Lua library to access it as two 16-bit numbers.


Read the Ethernet IP as a single 32-bit number - lua

Ethernet_IP = MB.readName("ETHERNET_IP")
print("Read IP as a 32-bit integer: ", string.format("%08X", Ethernet_IP))

Read the Ethernet IP as two 16-bit numbers - lua

Eth_IP = {}
Eth_IP = MB.readNameArray("ETHERNET_IP", 2, 0)
print("Read IP as two 16-bit integers:", string.format("%04X", Eth_IP[1]), string.format("%04X", Eth_IP[2]))


  • Read IP as a 32-bit Integer: 0xC0A80100
  • Read IP as two 16-bit Integers: 0xC0A8 0x016A

When the IP was read as a 32-bit integer the 0x16A was lost.

Suppressing Possible truncation error.

This warning can be suppressed by writing 1 to LUA_NO_WARN_TRUNCATION:

Suppress Truncation Warning Example - lua

error = MB.writeName("LUA_NO_WARN_TRUNCATION", 1)
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.