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

Method getDataFromTextField

lib/hidapi/testgui/test.cpp:317–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

315}
316
317size_t
318MainWindow::getDataFromTextField(FXTextField *tf, char *buf, size_t len)
319{
320 const char *delim = " ,{}\t\r\n";
321 FXString data = tf->getText();
322 const FXchar *d = data.text();
323 size_t i = 0;
324
325 // Copy the string from the GUI.
326 size_t sz = strlen(d);
327 char *str = (char*) malloc(sz+1);
328 strcpy(str, d);
329
330 // For each token in the string, parse and store in buf[].
331 char *token = strtok(str, delim);
332 while (token) {
333 char *endptr;
334 long int val = strtol(token, &endptr, 0);
335 buf[i++] = val;
336 token = strtok(NULL, delim);
337 }
338
339 free(str);
340 return i;
341}
342
343/* getLengthFromTextField()
344 Returns length:

Callers

nothing calls this directly

Calls 1

textMethod · 0.45

Tested by

no test coverage detected