String Manipulation Error ?

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
EddieB
Posts: 55
Joined: Tue Jan 30, 2007 7:17 pm
Contact:

String Manipulation Error ?

Post by EddieB »

Hello,

I think I have found an error within the flowcode string manipulation box ( Flowcode version 3 studen edition with latest update. )

I had a string "output" and an integer "input".

When I tried to do this:

output = output + ToString$(input)

it wouldn't let me..

So I had to create a third string variable "swap". This is a small work around I made..

swap = ToString$(input)
output = output + swap

Is this a bug? Or is there a reason for this? ..

Cheers

User avatar
Steve
Matrix Staff
Posts: 3422
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Post by Steve »

Hello Eddie,

Thanks for pointing this out. It is not a bug - it's more like a limitation. Here's the reason:

String "concatenation" (i.e. adding 2 strings together with the '+' symbol) is limited to only working with string variables or literal strings (e.g. "hello").

Creating a temporary string like you have done is the best way to get around this limitation.

EddieB
Posts: 55
Joined: Tue Jan 30, 2007 7:17 pm
Contact:

Post by EddieB »

Hello,

Yeah I should of said limitation :P...

Im a C++/C programmer so going from that to flow charts is strange, not being able to use == in If box's is a pane as well :P but i'll live...

One more thing:

I have made a program which compares an input to a password... I have password stored as "123" in a string variable sized 20... when I get an input I add it to another string ( output ) size 20...

When I do a print out of the var on the lcd screen it is exactly "123" but when I compare it to "123" with the compare function, I get 1 returned... where I should be getting 0...

Cheers

User avatar
Steve
Matrix Staff
Posts: 3422
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Post by Steve »

Check you've got the latest version (v3.1) - I've recently fixed a bug similar to this. If you have the latest version and still have this bug, please send a small sample program (fcf and c files) to out support email and we'll have a look.

EddieB
Posts: 55
Joined: Tue Jan 30, 2007 7:17 pm
Contact:

Post by EddieB »

Hey,

It's version 3.1 but I think the error is more down to my program layout.

Im basically trying to do this:

Everytime a keypad button is pressed ( if it 9 or lower ) add it into a string..

So say I pressed 1,2,3.. I would have a string like "123".

Then when they press the star key ( 10 ).. Check that string against another like 123 for example... and then perform anything I need to do.

Its such a simple task but as Im not too good with flowcode is a difficult one :P

Cheers

User avatar
Steve
Matrix Staff
Posts: 3422
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Post by Steve »

Ok, one thing would be to make sure the string is terminated - i.e. once you have a complete string, at a NULL character to the end of it.

You can do this via the "Calculation" icon (NOT the string manipulation icon) like this:

Code: Select all

MyString[3] = 0
(this assumes MyString contains 3 characters).

If that does not solve the problem and it looks like a bug, please send the program to us so we can check it out.

EddieB
Posts: 55
Joined: Tue Jan 30, 2007 7:17 pm
Contact:

Post by EddieB »

Hello,

The null termination worked :D

Thanks Steve!

Post Reply