Issue I429 [80,enhancement,med-high,resolved] Define behavior of adj_elect[i] and adj_electXX for non-existent electrode numbers and #adj_elect. As of 8.0.5-TEST2, adj_elect[i] returns nil if i is a non-existant electrode. Writing to adj_elect[i], for non-existant electrode i, raises an error. #adj_elect returns the number of adjustable electrodes having consecutive numbers starting at 1 (note: electrode 0 or electrodes following skipped numbers are not counted, so #adj_elect is not always useful). This all is largely consistent with Lua conventions. If your user program is not sure whether an electrode exists and is able to be written to, it may use code like this: if adj_elect[20] then adj_elect[20] = 10 end Prior to 8.0.5-TEST2, this behavior was undefined. However, in practice, reading or writing to a non-existance electrode raised an error (except in cases of skipped electrodes (Issue I414), where no error was generated). Here is a workaround that can be used in versions prior to 8.0.5-TEST2 for detecting electrodes: -- Returns true/false whether electrode # n exists in active PA. local function exists_electrode(n) return (pcall(function() return adj_elect[n] end)) end --Note also: adj_elect[0] returns electrode 0 even if not exist. --adj_elect[0] = 0 may crash if electrode 0 not exist Request based on tbraun-20070810/200801 http://www.simion.com/discuss/viewtopic?p=1803 As of 8.0.5-TEST26, this is also support in PRG code. "0 arcl adj_elect" is supported. Storing to a non-existant electrode results in an error, even skipped electrodes are used (Issue I414). Reading from a non-existant electrode now always returns 0. Implemented in 8.0.5-TEST2.
