next up previous contents
Next: 2.4.2 Pointers to IDispatch Up: 2.4 Type Conversion Previous: 2.4 Type Conversion   Contents


2.4.1 Boolean values

Lua uses the nil value as false and non-nil values as true. As LuaCOM gives a special meaning for nil values in the parameter list, it can't use Lua convention for true and false values; instead, LuaCOM uses the C convention: the true value is a number different from zero and the false value is the number zero. Here follows a sample:

-- This function alters the state of the of the window.
-- state is a Lua boolean value
-- window is a LuaCOM object

function showWindow(window, state)

  if state then
    window.Visible = 1

    -- this has the same result
    windows.Visible = -10
  else
    window.Visible = 0
  end

end

-- Shows window
showWindow(window, 1)

-- Hides window
showWindow(window, nil)


Vinicius da Silva Almendra 2003-06-04