renoise.song().selected_note_column_index

hey,

i noticed that while the API documentation states this:

renoise.song().selected_note_column_index  
 -> [number or nil (when an effect column is selected)]  

it actually returns 0, when an effect column is selected.

the same goes for renoise.song().selected_effect_column_index, when a note column is selected.

i am unsure if this changed or if the documentation is simply incorrect.

cheers

Nil is not the same as 0, but if you code conditions like “if not renoise.song().selected_note_column_index then” it doesn’t matter whether the false condition is either 0 or nil.

Really? :blink:
I honestly thought that it was one of Lua’s peculiarities that the number zero is actually “true”, and not “false”. Are you 100% sure on this, Vv?

It might also be the case that I’ve misunderstood the “if not” testing.

–EDIT: Sorry, misunderstood! Thanks Vv for explaining. Won’t obfuscate thread by replying, but will instead obfuscate my obfuscated post here. :)

Yes, nil != 0.

0 results into “true” in if statements too:

  
local number = 0  
if (number) then print "if 0:yes" else print "if 0:no" end  
number = nil  
if (number) then print "nil:yes" else print "if nil:no" end  
  

Makes sense, but indeed is not how many other languages behave.


Re selected_note_column_index:

Seems to be fixed in the 3.0 Lua docs already.
Docs at https://code.google.com/p/xrnx/source/browse/trunk/Documentation/Renoise.Song.API.lua are still wrong though.
Will be updated once Renoise 3 goes into release candidate or final state.

In Lua Nil is not the same as 0.

I’m speaking of this contrast:

  
local mynil = nil  
local mynul = 0  
  
if mynul < 1 then  
 print('condition met')  
end  
  
if mynil < 1 then  
 print('i wonder why lua pops up with an error instead')  
end  
  

While this works fine:

  
local mynil = nil  
  
  
if not mynil then  
 print('mynil < 1')  
else  
 print('mynil > 0')  
end  
  
  
mynil = 0  
if not mynil then  
 print('mynil < 1')  
else  
 print('mynil > 0')  
end  
  
mynil = 1  
if not mynil then  
 print('mynil < 1')  
else  
 print('mynil > 0')  
end