MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / getLengthFromTextField

Method getLengthFromTextField

lib/hidapi/testgui/test.cpp:348–370  ·  view source on GitHub ↗

getLengthFromTextField() Returns length: 0: empty text field >0: valid length -1: invalid length */

Source from the content-addressed store, hash-verified

346 >0: valid length
347 -1: invalid length */
348int
349MainWindow::getLengthFromTextField(FXTextField *tf)
350{
351 long int len;
352 FXString str = tf->getText();
353 size_t sz = str.length();
354
355 if (sz > 0) {
356 char *endptr;
357 len = strtol(str.text(), &endptr, 0);
358 if (endptr != str.text() && *endptr == '\0') {
359 if (len <= 0) {
360 FXMessageBox::error(this, MBOX_OK, "Invalid length", "Enter a length greater than zero.");
361 return -1;
362 }
363 return len;
364 }
365 else
366 return -1;
367 }
368
369 return 0;
370}
371
372long
373MainWindow::onSendOutputReport(FXObject *sender, FXSelector sel, void *ptr)

Callers

nothing calls this directly

Calls 3

lengthMethod · 0.80
errorFunction · 0.50
textMethod · 0.45

Tested by

no test coverage detected