Strings

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

Moderators: Benj, Mods

User avatar
jollybv
Flowcode v5 User
Posts: 374
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times
Contact:

Strings

Post by jollybv »

Hi I am busy with ( An introduction to micro-controller programming ) in the section with string and memory i am having a problem with defining the length of a string can someone please give me an example or tell me how this is don

Regards
Brian

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Strings

Post by Benj »

Hello Brian,

The string size is defined in the variables window in side square brackets. You can edit this by clicking Edit -> Variables -> Select your variable -> Rename.

eg

string[20] is a variable named string with room for 20 characters.

User avatar
jollybv
Flowcode v5 User
Posts: 374
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times
Contact:

Re: Strings

Post by jollybv »

Hi benj

Thanks for your prompt response I have another small problem how will i send data from one pick to another using RS232 ?? I have an example program but cant finger out where i must insert the data to be sent

Regards
Brian

User avatar
jollybv
Flowcode v5 User
Posts: 374
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times
Contact:

Re: Strings

Post by jollybv »

Hi Again

I am trying to program the chip and I am getting these error messages as i have no clue of whats going on
the message is
H:\Flowcode Stuuff\Keypad 2.c(1120): error: missing right paren
H:\Flowcode Stuuff\Keypad 2.c(1120): error: missing semicolon
H:\Flowcode Stuuff\Keypad 2.c(1120): error: missing right paren
H:\Flowcode Stuuff\Keypad 2.c(985): error: failure

Here is the Code
1112 {
1113 //Calculation
1114 //Calculation:
1115 // Numarray[0] = 0
1116 // Numarray[1] = 0
1117 // Numarray[2] = 0
1118 FCV_NUMARRAY[0] = 0;
1119 FCV_NUMARRAY[1] = 0;
1120 FCV_NUMARRAY[2] = 0;

what i am trying to do is on exit clear the string


can someone please help
Last edited by jollybv on Fri Oct 22, 2010 11:14 am, edited 2 times in total.

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

Re: Strings

Post by medelec35 »

Hiya jollybv.
Take a look here:
http://www.matrixmultimedia.com/mmforum ... =26&t=6936

Especially the 7th post down. It covers missing semicolon errors.
Martin

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

Re: Strings

Post by medelec35 »

Since your last edit was after my latest post, I am assuming you have checked the connections of your component. If it is not that and you don't mind sharing your flowchart, then if you post it then I can check it for you.
Martin

User avatar
jollybv
Flowcode v5 User
Posts: 374
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times
Contact:

Re: Strings

Post by jollybv »

Thanks Ive sorted the problem

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

Re: Strings

Post by medelec35 »

That's great!
If you don't mind me asking, caused the errors, as it could help other people with same errors?
jollybv wrote:I have another small problem how will i send data from one pick to another using RS232 ?? I have an example program but cant finger out where i must insert the data to be sent

Regards
Brian
Did you solve this as well?
Martin

User avatar
jollybv
Flowcode v5 User
Posts: 374
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times
Contact:

Re: Strings

Post by jollybv »

Hi again
There was 2 places on my program where i never put a value into the string eg MyString[]
I was wondering if i could send you my program and you could see if I am on the rite track with sending the data via RS232.In my program the string is 3 bits long how will i output that as one number eg bit 1= 2 bit 2= 5 bit 3= 9 (259)..??

Thanks
Brian

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

Re: Strings

Post by medelec35 »

jollybv wrote:In my program the string is 3 bits long how will i output that as one number eg bit 1= 2 bit 2= 5 bit 3= 9 (259)..??

Thanks
Brian
Do you mean you want to send a string that has an array of three so, is three bytes and not bits?
If so take a look here 1st:
http://www.matrixmultimedia.com/mmforum ... 40&p=18982
Download the attachment on the last post by Benj and see if that suits your requirements.
You can go into the variables manager and change the length of string from the default 20 to 3
It is up to you if you post it on here for the public domain, or send via pm to keep it private.
Either way I'm sure we can help you achieve what you have set out to to do.
Martin

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

Re: Strings

Post by medelec35 »

What I have done for you is modified the Flowchart Ben posted to suit your application. It should work for any length of string (within flowcode limits), not just 3.
Hope this helps.
Attachments
Flowcode V3 rs232 sending string2.fcf
(4.5 KiB) Downloaded 1181 times
Martin

User avatar
jollybv
Flowcode v5 User
Posts: 374
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times
Contact:

Re: Strings

Post by jollybv »

Hi Again

Thanks for that modified code it works like a dream my only question is which pin on the processor is that data transmitted as i see no outputs or am i having a blond moment??

Regards
Brian

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Strings

Post by Benj »

Hello Brian,

Ifyou click on View -> Chip then you should get a diagram of the chip being used in your program. The RS232 hardware pins are marked on the chip diagram as TX and RX.

User avatar
jollybv
Flowcode v5 User
Posts: 374
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times
Contact:

Re: Strings

Post by jollybv »

Hi Guys

I have a quick question if i have a string say the value is "145" after i have keyed it in from the keypad how would I put that "145" into a variable so i can use it as a value for "Decision" eg if variable-1 = variable-2 then execute.

Regards
Brian

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

Re: Strings

Post by medelec35 »

Hiya jollybv,

What I would do is first convert string to an integer
then use a decision branch if int=1 do something,
if int=45 do something else etc
Here is how you can convert string to integer (much easier with V4 as you have string to int function):
Number = ( Input_string[0] - 48 ) * 100 + ( Input_string[1] - 48 ) * 10 + ( Input_string[2] - 48 )

If you get stuck, post your flowcode an I will alter it to convert string to integer for you.
Martin

User avatar
jollybv
Flowcode v5 User
Posts: 374
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times
Contact:

Re: Strings

Post by jollybv »

Hi Martin

Thanks for the reply where would I put this calculation just under the get key..??

Brian

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

Re: Strings

Post by medelec35 »

The calculation is after you have got the whole string.
Take a look at this example within attached flowchart.
I have set it up so you enter 678 to light LED connected to port A0
812 to turn LED off
After entering three digits, key # to accept
or * to re-enter the three digits.
This is just a staring point. you can adapt for any number of digits, so long as you dont go over 32767.
Attachments
String to number Flowcode V3.fcf
(11 KiB) Downloaded 1053 times
Martin

User avatar
jollybv
Flowcode v5 User
Posts: 374
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times
Contact:

Re: Strings

Post by jollybv »

Hi Martin

Thanks for the help again, turning it into an "int" helped me a lot should of don that in the beginning re-wrote the whole program was a breeze now working well and program a lot smaller thanks again.


Brian

User avatar
jollybv
Flowcode v5 User
Posts: 374
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times
Contact:

Re: Strings

Post by jollybv »

jollybv wrote:Hi Martin

Thanks for the help again, turning it into an "int" helped me a lot should of don that in the beginning re-wrote the whole program was a breeze now working well and program a lot smaller thanks again.


Brian
:P

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

Re: Strings

Post by medelec35 »

Your welcome Brian,
So long as it's what you are after.
Glad I could help.
Thank you for letting us know.
Martin

User avatar
jollybv
Flowcode v5 User
Posts: 374
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times
Contact:

Re: Strings

Post by jollybv »

Hi guys

What I'm trying to do is, I have a string 4 places long what I'm trying to do is, the first bit of the string (string [0]) must be insert it from a variable then the next 3 (string 1,2,3) need to be imputed from a keypad is this possible. :?:
Brian

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Strings

Post by Benj »

Hello Brian,

Yes this is possible.

You can assign the string value with a variable using a calculation icon like this.

string_var[0] = byte_var

See here for an example of inputting a password into a string using a keypad. - Edit sorry it uses switches, im sure there was a keypad example somewhere. Ill have a dig.
Attachments
5. Validating a password.fcf
(15.5 KiB) Downloaded 998 times
4. Inputting a password.fcf
(8.5 KiB) Downloaded 1005 times

User avatar
jollybv
Flowcode v5 User
Posts: 374
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times
Contact:

Setup Routine

Post by jollybv »

Thanks Ben

Have just got my copy of FlowCode 4.3 and trying to understand it. what I'm trying to do is create a set-up routine say for instance the default code is 1234 to go into the set-up, once in the routine I want have an option to change the default code or just leave it and carry on setting up has anyone got any examples how to do this as I'm stuck.

Brian

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Strings

Post by Benj »

Hello Brian,

What you could do it something like this.

Start by using a string manipulation to store "1234" into your string.

string_var = "1234"

Then print a message to the LCD etc saying for example press * on the keypad to change defaults.

Go into a loop that waits say 10ms and loops 200 times to give you a delay of around 2 seconds.

Inside the loop read the keypad and if the keypad returns "*" then leave the loop initialise your index variable to 0 and enter a second loop that runs 4 times.

Inside this new loop wait for the keypad to be equal to 255 eg so you have released the "*" key and then wait for the keypad to be less then 255 eg until a key has been pressed. Once the key has been pressed then simply use a calculation to assign the keypress to the variable.

string_var[index] = keypress

Then add 1 to your index variable and loop for the next keypress.

Hope this helps.

User avatar
jollybv
Flowcode v5 User
Posts: 374
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times
Contact:

Re: Strings

Post by jollybv »

Hi Guys

Is there anyone out there who can show me how turn an "Int" back into a "string"

Brian

Post Reply