Compile function Tool_Class_Services(@Service, @Params)
#pragma precomp SRP_PreCompiler
$insert LOGICAL
$Insert SERVICE_SETUP

$Insert TOOL_CLASS_EQUATES

Declare subroutine Error_Services
Declare function Error_Services, Database_Services

GoToService

Return Response or ""

//-----------------------------------------------------------------------------
// SERVICES
//-----------------------------------------------------------------------------

Service GetNumberOfPointsForPattern(ToolClass, PatternName)
	If Unassigned(ToolClass) or ToolClass EQ '' then
		Error_Services('Add', 'invalid tool class')
	end
	
	If Error_Services('NoError') then
		If Unassigned(PatternName) or PatternName EQ '' then
			Error_Services('Add', 'invalid pattern name')
		end
	end
	
	Convert @LOWER_CASE to @UPPER_CASE in ToolClass
	
	If Error_Services('NoError') then
		ToolClassRecord = Database_Services('ReadDataRow', 'TOOL_CLASS', ToolClass)
		If Error_Services('HasError') then
			Error_Services('Add', 'tool class record not found')
		end
		If Error_Services('NoError') then
			Locate PatternName in ToolClassRecord<TOOL_CLASS_PATTERN$> using @VM Setting idx then
				Response = ToolClassRecord<TOOL_CLASS_PATTERN_SIZE$, idx>
			end
			
			NumberOfPatterns = DCount(ToolClassRecord<TOOL_CLASS_PATTERN$>, @VM)
			If idx GT NumberOfPatterns then
				Error_Services('Add', 'pattern name not found')
			end
			PatternSizeCount = DCount(ToolClassRecord<TOOL_CLASS_PATTERN_SIZE$>, @VM)
			If idx GT PatternSizeCount then
				Error_Services('Add', 'number of points not found')
			end
		end
	end    
End Service

