DestroyTable (и Clear) закрывает скрипт вместо таблицы

Страницы: 1
RSS
DestroyTable (и Clear) закрывает скрипт вместо таблицы, Тема описана в Названии и в Тексте сообщения
 
Версия Quik 12.5.0.20. Код скрипта
Код
function OnStop (signal)
  StopFlag = true
  return 1000 -- Тайм-аут 1 сек вместо стандартных 5
end

function Create (caption, rowNum, cols)
  local t_id = AllocTable()
  for i = 1, #cols do         -- name       *    type       width  
    assert (1==AddColumn (t_id,i,cols[i][1],true,cols[i][2],cols[i][3])
      ,string.format ("%2d %s %s %s", i, tostring(cols[i][1])
        ,tostring (cols[i][2]), tostring (cols[i][3])))
  end -- * false - all cells invisible
  assert (1 == CreateWindow (t_id))
  assert (SetWindowCaption (t_id, caption))
  local top, left, bottom, right = GetWindowRect (t_id)
  local totalWidth = right - left + 10 -- Эмпирика |
  local frameHeight = 60                      --"- |
  local rowHeight   = 20                      --"- |
  for i = 1, rowNum do
    local row = InsertRow (t_id, -1)
    assert (row == i)
    assert (SetCell (t_id, row, 1, "row".. i))
    for j = 2, #cols do
      local val = i * 10 + j
      assert (SetCell (t_id, row, j, tostring(val), val))
    end
  end
  assert (SetWindowPos (t_id, left, top
    ,totalWidth, frameHeight + rowHeight * rowNum))
  return t_id
end -- Cre ate ()

 function main()
  local rowNum = 2
  local cols = {
    {"Column1", QTABLE_STRING_TYPE, 10,}
   ,{"Column2", QTABLE_INT_TYPE,    10,}
   ,{"Column3", QTABLE_DOUBLE_TYPE, 10,}
  }
  local t_id = Create ("Caption", rowNum, cols)
  while not IsWindowClosed (t_id) do
    if StopFlag then
      message ("Destroying ".. t_id)
      if DestroyTable (t_id) then -- Завершение!
        message ("Destroying success ".. t_id)
      else
        message ("Destroying failed ".. t_id)
      end
      break
    end
    sleep (10)
  end -- while
end -- main()

---
Страницы: 1
Читают тему
Наверх