void SelectFileFromList()

in src/configuration/AxisConfiguration.cpp [425:530]


void SelectFileFromList( CHOICELIST * psChoiceList, int iChoiceCount, LIST * psDLLNames, int * piConfigInfoArray, char ** ppsDefaultParamList, LIST * psFileNameList, char * pszAxisCpp_Deploy)
{
	cout << endl << "Select the filename for the " << psChoiceList[iChoiceCount].pszElementDescription << "." << endl;

	int		iDLLCount = 0;
	LIST	sDLLOffsetList;
	bool	bHTTPTransportFound = false;

	memset( &sDLLOffsetList, 0, sizeof( LIST));

	do
	{
		char *	pszUpper = new char[strlen( psChoiceList[iChoiceCount].pszElement) + 1];

		strcpy( pszUpper, psChoiceList[iChoiceCount].pszElement);

		StringToUpper( pszUpper);

		char *	pszExtn = strchr( pszUpper, '.');

		if( pszExtn != NULL)
		{
			*pszExtn = '\0';
		}

		while( iDLLCount < psDLLNames->iCount)
		{
			DLLNAMEINFO *	pszDLLNameInfo = ((DLLNAMEINFO *) psDLLNames->ppArray[iDLLCount]);

			if( pszDLLNameInfo->pszDLLName != NULL &&
				strstr( pszDLLNameInfo->pszDLLName, pszUpper) != NULL)
			{
				int *	piDLLOffset = (int *) GetNextListElement( &sDLLOffsetList, sizeof( int));

				*piDLLOffset = iDLLCount;

				cout << sDLLOffsetList.iCount << ".\t" << pszDLLNameInfo->pszDLLFilename << endl;
			}

			iDLLCount++;
		}

		free( pszUpper);

		if( ppsDefaultParamList[psChoiceList[iChoiceCount].eConfigType] != NULL &&
			FileExists( ppsDefaultParamList[psChoiceList[iChoiceCount].eConfigType]))
		{
			piConfigInfoArray[psChoiceList[iChoiceCount].eConfigType] = PopulateNewDLLNameInfo( psDLLNames, NULL, ppsDefaultParamList[psChoiceList[iChoiceCount].eConfigType], true);

			bHTTPTransportFound = true;

			cout << "Choices have been overridden by input parameter." << endl;
		}
		else
		{
			if( StringCompare( ppsDefaultParamList[eQueryMissingFiles], "ON"))
			{
				if( sDLLOffsetList.iCount > 0)
				{
					if( sDLLOffsetList.iCount > 1)
					{
						cout << "Select an index between 1 and " << sDLLOffsetList.iCount << " : ";

						int	iChoice;

						cin >> iChoice;

						if( iChoice < 1 || iChoice > sDLLOffsetList.iCount)
						{
							cout << "Number was out of range." << endl;
						}
						else
						{
							((DLLNAMEINFO *) psDLLNames->ppArray[*((int *) sDLLOffsetList.ppArray[iChoice - 1])])->bAddToClientConfig = true;
							piConfigInfoArray[psChoiceList[iChoiceCount].eConfigType] = *((int *) sDLLOffsetList.ppArray[iChoice - 1]);
							bHTTPTransportFound = true;
						}
					}
					else
					{
						cout << "Automatically selected " << ((DLLNAMEINFO *) psDLLNames->ppArray[*((int *) sDLLOffsetList.ppArray[0])])->pszDLLFilename << endl;

						((DLLNAMEINFO *) psDLLNames->ppArray[*((int *) sDLLOffsetList.ppArray[0])])->bAddToClientConfig = true;
						piConfigInfoArray[psChoiceList[iChoiceCount].eConfigType] = *((int *) sDLLOffsetList.ppArray[0]);
						bHTTPTransportFound = true;
					}
				}
				else
				{
					cout << "There are no recognised file names for the type of file/library." << endl << "You will have to modify the configuration file namually." << endl << endl;

					bHTTPTransportFound = true;
				}
			}
			else
			{
				bHTTPTransportFound = true;
			}
		}
	} while( !bHTTPTransportFound);

	for( int iCount = 0; iCount < sDLLOffsetList.iCount; iCount++)
	{
		free( sDLLOffsetList.ppArray[iCount]);
	}
}