Page 1 of 1

using string in decision "block" ?

Posted: Sun Aug 31, 2008 1:31 pm
by v3n0m
Hello folks.

I'm a new flowcode user, and I really like it :) but I've got a strange problem, which I can't seem to sort out.

I built a program (for an atmega168) which reads the serial port, fills a string with the incoming data, until a termination character is received.
the string is split in 2 with the string manipulation block (format is: string [space] value, and this just takes them apart), but now I want to do this:

the first part of the string (which is put in a variable, called "stringL") determines what to do with the value.

I created a decision block, and changed the properties as below:

Code: Select all

stringL[]="speed"
which gives me a syntax error.
if I place a number between the brackets (0, 1... 5... doesn't seem to make a difference), it gives me the same error.
if I remove the brackets completely, it gives me an error about an invalid array index.

what am I missing? it can't be that hard, can it?

thanks in advance,

v3n0m

Re: using string in decision "block" ?

Posted: Sun Aug 31, 2008 3:12 pm
by jmccorison
As a new user myself, I too ran into this right away. The decision block can not do string functions. You may compare byte and int variables, but not string. In order to do a string comparison, first use a string function block with the compare$ macro, then a decision block, like this:

results = compare$(stringL, "speed", 0)
if results = 0
then do stuff....

Results is byte variable. The third parameter to compare$ specifies if the compare is to be case sensitive or not. Compare$ will return 0 if the string are equal. For more details check out the Strings Manipulation Functions help file.

-Jim

Re: using string in decision "block" ?

Posted: Sun Aug 31, 2008 4:44 pm
by v3n0m
thanks :) thought of that myself, but I expected a more straight-forward way to do it :) but now the programming job can be continued :)

thanks a lot