Page 1 of 1

InputBox previous value if invalid entry entered

Posted: Sat Jan 02, 2021 6:18 pm
by Moray
I was just doing some testing with a KFlop triggered InputBox, and have just realised if you enter an invalid value, although KMotionCNC pops up another message box saying you've entered an invalid value, it will return the previously valid inputbox value, and return a value of 0, telling the KFlop everything was OK.

I would have thought if an invalid value was entered, the InputBox should at least return a value of 1 (cancel) so it's aware the value supplied might be wrong?


The code I was using to test this was -

Code: Select all

#include "KMotionDef.h"
#define TMP 10 // which spare persist to use to transfer data
#include "KFLOPToKMotionCNCFunctions.c"

float inputResult;
void main()
{
	//DoPCFloat(PC_COMM_SET_X,1);
	printf("Running...\n");
	int Answer = InputBox("Enter a number",&inputResult);
	printf("Answer:%d\n",Answer);
			if (Answer){
				printf("Operator Canceled\n");
			} else {
				printf("Operator Entered Value of %.3f\n",inputResult);
				
			}
}

Re: InputBox previous value if invalid entry entered

Posted: Sat Jan 02, 2021 6:58 pm
by TomKerekes
Hi Moray

That's a bug. Thanks.

In SetValue.cpp a return should be added to not exit the dialog.

Code: Select all

		AfxMessageBox("Invalid Entry");
		return;