How to use a string variable?

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
F22-Raptor
Posts: 13
Joined: Fri Nov 20, 2009 2:58 pm

How to use a string variable?

Post by F22-Raptor »

Hello All,

This might be a stupid question but how do I use the string variables?

Let me give you an example.

Let's say I have a string variable MSG, when you create this variable it is an array of size 20 (MSG[20]) max.

Now if I want to my string to be for ex. "Flowcode 4 rocks" (and later use that as output for an LCD), how do I make MSG="Flowcode 4 rocks"?
What happens if my text is longer than 20 characters?

Also, is there a way to add comments to variables when creating them in the Variables manager (e.g. LCD_OUT //This variable will be displayed on LCD)?

I'm not sure I explained this very well but if it doesn't make sense let me know and I'll try again.

Thanks

D.

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: How to use a string variable?

Post by medelec35 »

Basically to create a string, Drag the string manipulation box on your flowchart.
Double click box after it had been dragged.
Click on 'Variables', then click 'Add New Variable'
Select 'String', then type your variable name, the default string size is 20 so if you want a smaller size e.g 10 then put 10 within square brackets straight after variable name e.g. MSG[10]
Message[4]
etc
Click on 'Use Variable'
Then use an equals sign followed by string value within speech marks. Finally you can add comments by using //
e.g
Message[15] = "Flowcode 4 is the best"//well until V5 is out :-P
or you can add comments by using comment box (just below the C Box) on the left tool bar.
There is a lot you can do with strings. e.g just displaying first four characters or converting to integers etc.
While you can click on 'Variables', you can also click on 'Functions' for a full list of functions.
If you assign a string with a length of 5 instead of 15 using the above example, then Message string = "Flowc" all the rest will be ignored.

If you are going to add comments, best advice would be follow this:
http://www.matrixmultimedia.com/mmforum ... =29&t=6781
At lest then you would be able to see them!
Finally take a look at flowcode 4 examples. See:
http://www.matrixmultimedia.com/Flowcode3a-X.php
Scroll down to Flowcode 4 examples.
Also download other flowcharts form other flowcode users (especially Benj steve and sean) to give you a better idea on how to use flowcode. It will certainly pay off

Hope this helps
Martin

F22-Raptor
Posts: 13
Joined: Fri Nov 20, 2009 2:58 pm

Re: How to use a string variable?

Post by F22-Raptor »

Thanks medelec,

I will have to try that tonight when I get home.

I've been looking at other examples and have been lurking on this forum for a while but I'm really new at FC so most likely I'll be asking some more stupid questions soon.

I really appreciate your quick reply.

Regards

D.

Post Reply