Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The available() should return Current!=null; #13

Open
MikeBlueIce opened this issue Oct 31, 2016 · 3 comments
Open

The available() should return Current!=null; #13

MikeBlueIce opened this issue Oct 31, 2016 · 3 comments

Comments

@MikeBlueIce
Copy link

For variable number of arguments, this code will not work:

while (cmdMessenger.available())
{
      int curNo=cmdMessenger.readInt16Arg();
      
      // Do something with this number.
}

It will skip 1 parameter at a time. Was this function intended for this?

@thijse
Copy link
Owner

thijse commented Jan 12, 2017

Honestly, if forgett why I available goes to the next parameter. I do not see samples using it. I will think on your suggestion.

@Palatis
Copy link
Contributor

Palatis commented Feb 5, 2017

I find this "feature" annoying, too... :-P

@sigmaeo
Copy link

sigmaeo commented Mar 13, 2018

Me too.
Instead of:
if( cmdMessenger.available() ) { value1 = cm.readInt32Arg(); if( cmdMessenger.available() ) value2 = cm.readInt32Arg(); }

One have to do it this way:
ui32 = cm.readInt32Arg(); if( cm.isArgOk() ) { value1 = ui32; ui32 = cm.readInt32Arg(); if( cm.isArgOk() ) ui32 = cm.readInt32Arg(); }

If I send the command string (command-id=0):
0,1,2,3,4,5;

The first example catches:
value1=2 and
value2=4

The second example catches:
value1=1 and
value2=2
as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants