Added the ability to have floating point values in the options.txt file.

This commit is contained in:
Stephen White 2018-06-12 19:03:29 +10:00
parent 113653a1ce
commit ee289159b6
2 changed files with 18 additions and 0 deletions

View file

@ -17,6 +17,8 @@
// along with Pi1541. If not, see <http://www.gnu.org/licenses/>.
#include "options.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <ctype.h>
@ -158,6 +160,13 @@ Options::Options(void)
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE) \
Name = nValue; \
}
#define ELSE_CHECK_FLOAT_OPTION(Name) \
else if (strcasecmp(pOption, #Name) == 0) \
{ \
unsigned nValue = 0; \
if ((nValue = GetFloat(pValue)) != INVALID_VALUE) \
Name = nValue; \
}
void Options::Process(char* buffer)
{
@ -267,6 +276,14 @@ unsigned Options::GetDecimal(char* pString)
return nResult;
}
float Options::GetFloat(char* pString)
{
if (pString == 0 || *pString == '\0')
return 0;
return atof(pString);
}
const char* Options::GetRomName(int index) const
{
switch (index)

View file

@ -76,6 +76,7 @@ public:
const char* GetLCDName() const { return LCDName; }
static unsigned GetDecimal(char* pString);
static float GetFloat(char* pString);
private:
unsigned int deviceID;