--[[
---------------------------------------------------------------------------
Remote Train Control Program for Windows

© Copyright 2026 by Mark DiVecchio

	This file is part of Remote Train Control.

	Remote Train Control is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	Remote Train Control is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with Remote Train Control.  If not, see <http://www.gnu.org/licenses/>.

 Home Page : http://www.silogic.com/trains/RTC_Running.html
---------------------------------------------------------------------------]]
-- Semicolons are not required in Lua code
title = "Lashup Data Test"
require([[defines]]);
require([[functions]]);
--
-- This tests the access of the Lashup Name and the Lashup Engine List

local Terminate = false;
--[[---------------------------------------------------------------------------------------]]
function setup(Engine, TIU)
	print("setup() Running");
	-- Access each engine and print the information
	for iEngineNo = 1, 99 do
		local PS;
		EngineName, PS = GetName(iEngineNo);
		local EX = Exists(iEngineNo);
		print("Engine Number #" .. iEngineNo .. "   -   Name = " .. EngineName .. "   -   PS" .. PS .. "   -   Exists = " .. tostring(EX));
		Sleep(0.01);	-- short sleep needed to keep the UI responsive - here 10 ms
		end;
	
	-- Access each lashup and print the information
	for iLashUpNo = 101, 120 do
		LashupName, EngineList = GetName(iLashUpNo);
		local EX = Exists(iLashUpNo);
		print("LashUp #" .. iLashUpNo .. "   -   Name = " .. LashupName .. "   -   Engine List = " .. type(EngineList) .. "   -   Exists = " .. tostring(EX));
		if (type(EngineList) == "table" and EX) then
			for i,v in ipairs(EngineList) do
				print("            Engine List [" .. i .. "] = " .. v);
				end;
			end;
		Sleep(0.01);	-- short sleep needed to keep the UI responsive - here 10 ms
		end;

	return true;		-- false=setup failed, true=setup succeeded
	end
--[[---------------------------------------------------------------------------------------]]
function cleanup(Engine, TIU)
	-- this function is called once when the user presses the [STOP] button or the Stop() function is called
	print("cleanup() Running");
	Terminate = true;
	return true;		-- false=cleanup failed, true=cleanup succeeded
	end
--[[---------------------------------------------------------------------------------------]]

