1
Ваши вопросы / Re: Временная таблица в скриптах
« : 29 Октября 2025, 16:30:06 »
Решил проблему через DataSet
Официальный форум Simple-Scada.
В этом разделе можно просмотреть все сообщения, сделанные этим пользователем.
//
// Этот скрипт вызывается когда пользователь кликнул
// кнопку "ЗАДЕЙСТВОВАТЬ"
//
var
aIndex: Integer;
aQuery: string;
tblTempRecipes: TM_Table;
begin
aIndex := tblRecipes.RowIndex; // получаем индекс выделенной строки в таблице рецептов
if aIndex = -1 then // если строка не выбрана
begin
ShowMessageClient(GetClientName, 'Рецепт не выбран!', 'Сначала выберите рецепт который нужно задействовать.');
Exit;
end;
IDValue.Value := tblRecipes.GetCell(0, aIndex).Text;
// формируем запрос из таблицы "recipes"
aQuery := 'SELECT * FROM `recipes` WHERE `id`=' + QuotedStr(tblRecipes.GetCell(0, aIndex).Text);
tblTempRecipes.RunSQL(aQuery, tsSaveFixRow);
// записываем значения (из выделенной строки таблицы рецептов) в переменные
txtRecipeName.Text := tblTempRecipes.GetCell(1, 1).Text;
vrK1.Value := StrToInt(tblTempRecipes.GetCell(3, 1).Text);
vrK2.Value := StrToInt(tblTempRecipes.GetCell(4, 1).Text);
vrK3.Value := StrToInt(tblTempRecipes.GetCell(5, 1).Text);
txtRecipeName.Hint := tblTempRecipes.GetCell(6, 1).Text;
end.
var
i : integer;
begin
for i := 0 to Table1.RowCount do
if GetBit(Table1.VariableEx.AsInt, i) then
begin
Table1.GetCell(4, i).Text := 'Вкл';
Table1.GetCell(4, i).Color := clGreen;
end
else
begin
Table1.GetCell(4, i).Text := 'Выкл';
Table1.GetCell(4, i).Color := clRed;
end;