GCodeLine GCodeInterpreter::AssignGFuncParams(map<char, vector<float>>& data, GFunction& fun, size_t line)
{
	GCodeLine func;
	func.function = fun;
	func.line = line;
	FunctionArguments args = functionPrototypes[fun];
	if(args.size() == 0)
	{
		//Function with no parameters
		if(fun.second == -1)
			func.data[fun.first] = data[fun.first][0];
		else
			func.data[fun.first] = fun.second;
		return func;
	}
	auto iterator = find_if(args.begin(), args.end(), [&] (vector<char>& a)->bool
	{
		return MatchesArgumentList(a, data);//there are no arguments
	});
	if(iterator == args.end())//Match didn't found, use  previous arguments
		iterator = find_if(args.begin(), args.end(), [&] (vector<char>& a)->bool
		{
			return MatchesArgumentListWithOldVariables(a, data);
		});
	if(iterator == args.end())
		throw exception("Funkci nebyly pøedány správné argumenty");
	//Copy arguments
	if(fun.second == -1)
		func.data[fun.first] = data[fun.first][0];
	else
		func.data[fun.first] = fun.second;
	for_each(iterator->begin(), iterator->end(), [&](char c)
	{
		auto argIter = data.find(c);
		if(argIter != data.end())
		{
			if(argIter->second.size() > 1)
				throw exception("Vícenásobný argument");
			func.data[c] = data[c][0];
			return;
		}
		auto argIter2 = lastValue.find(c);
		if(argIter2 != lastValue.end())
		{
			if(coordType == INC && IsAxis(c))
			{
				func.data[c] = 0;
			}
			else
				func.data[c] = lastValue[c];
			return;
		}
		throw exception("Nebyly pøedány všechny argumenty");
	});
	return func;
}