
Models 707B and 708B Switching Matrix Reference Manual
Section 5: Remote commands
707B-901-01 Rev. A / August 2010
5-7
When the response is a comma-delimited string, the individual return items can be identified by
iterating through the list using the comma delimiters. For example, the Lua code below will start at the
beginning of a string and break the string into individual items at each comma. The
tonumber()
function is used on each item to determine if it is a number or not. In either case, the value is printed.
index1 = 1
index2 = 1
text = "123,abc,hello,4.56"
endIndex = string.len(text)
while index2 ~= endIndex do
index2 = string.find(text, ",", index1)
if not index2 then
index2 = endIndex
end
subString = string.sub(text, index1, index2 - 1)
if not number(subString) then
print(subString)
else
print(tonumber(subString))
end
index1 = 1
end