InputBox previous value if invalid entry entered

Moderators: TomKerekes, dynomotion

Post Reply
Moray
Posts: 226
Joined: Thu Apr 26, 2018 10:16 pm

InputBox previous value if invalid entry entered

Post by Moray » Sat Jan 02, 2021 6:18 pm

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);
				
			}
}

User avatar
TomKerekes
Posts: 1515
Joined: Mon Dec 04, 2017 1:49 am

Re: InputBox previous value if invalid entry entered

Post by TomKerekes » Sat Jan 02, 2021 6:58 pm

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;
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply