Terminal Input

Hello Blynkers !!

I am trying to input few Strings and int from terminal.

  if (String("ADD") == param.asStr()) {
// function();

This is working fine. But later i will have to input number like 1-25.
But the function accepts only ```int``` not ```String```. So is there a way like once i enter ADD and later when the function is called i should be able to input the 1-25 as int. 

String tInput; - for alphabets. 
int cInput; - for 1-25

How to tell the terminal that i am sending input as ```int``` ??

Probably much easier to grab everything as a string then handle it from there, extracting the numeric parts with string manipulation.

You’d need to add an ‘add flag’ which is set to true if the last data from the terminal was ‘ADD’ and which then tells you to expect the next data from the terminal to be a numeric range. Once you’ve verified that it is, then you can split the numbers out of the string and handle them as you wish.


1 Like

I thought of it… But i wanted to know if there was a better way of doing it. I thought placing a flag is a crude method.
i tried
String input;
int = xyz;
xyz = input.toInt();
without any success…

Sorry for the late reply.

Hello !

int num = 0;
int ID = 0;
  int num = param.asInt();
  num = ID;

V10 is for terminal input. Whatever value(numbers) i send from the terminal widget, it returns “0” in the serial monitor. Can anyone tell me what is wrong ?

Look at your code.
num is being set to the value from the terminal widget.
This is then being replaced with the value of ID (which you’ve defined as zero)
You are then printing both num and ID, which are both zero.

Code does what you tell it to!


Oops my bad…