Strings
- jollybv
- Flowcode v5 User
- Posts: 376
- Joined: Thu Feb 12, 2009 5:20 am
- Location: Cape Town
- Has thanked: 81 times
- Been thanked: 25 times
Strings
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
Regards
Brian
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- jollybv
- Flowcode v5 User
- Posts: 376
- Joined: Thu Feb 12, 2009 5:20 am
- Location: Cape Town
- Has thanked: 81 times
- Been thanked: 25 times
Re: Strings
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
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
- jollybv
- Flowcode v5 User
- Posts: 376
- Joined: Thu Feb 12, 2009 5:20 am
- Location: Cape Town
- Has thanked: 81 times
- Been thanked: 25 times
Re: Strings
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
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.
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Strings
Hiya jollybv.
Take a look here:
http://www.matrixmultimedia.com/mmforum ... =26&t=6936
Especially the 7th post down. It covers missing semicolon errors.
Take a look here:
http://www.matrixmultimedia.com/mmforum ... =26&t=6936
Especially the 7th post down. It covers missing semicolon errors.
Martin
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Strings
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
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Strings
That's great!
If you don't mind me asking, caused the errors, as it could help other people with same errors?
If you don't mind me asking, caused the errors, as it could help other people with same errors?
Did you solve this as well?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
Martin
- jollybv
- Flowcode v5 User
- Posts: 376
- Joined: Thu Feb 12, 2009 5:20 am
- Location: Cape Town
- Has thanked: 81 times
- Been thanked: 25 times
Re: Strings
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
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
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Strings
Do you mean you want to send a string that has an array of three so, is three bytes and not bits?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
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
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Strings
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.
Hope this helps.
- Attachments
-
- Flowcode V3 rs232 sending string2.fcf
- (4.5 KiB) Downloaded 1313 times
Martin
- jollybv
- Flowcode v5 User
- Posts: 376
- Joined: Thu Feb 12, 2009 5:20 am
- Location: Cape Town
- Has thanked: 81 times
- Been thanked: 25 times
Re: Strings
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
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
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- jollybv
- Flowcode v5 User
- Posts: 376
- Joined: Thu Feb 12, 2009 5:20 am
- Location: Cape Town
- Has thanked: 81 times
- Been thanked: 25 times
Re: Strings
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
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
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Strings
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.
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
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Strings
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.
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 1125 times
Martin
- jollybv
- Flowcode v5 User
- Posts: 376
- Joined: Thu Feb 12, 2009 5:20 am
- Location: Cape Town
- Has thanked: 81 times
- Been thanked: 25 times
Re: Strings
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
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
- jollybv
- Flowcode v5 User
- Posts: 376
- Joined: Thu Feb 12, 2009 5:20 am
- Location: Cape Town
- Has thanked: 81 times
- Been thanked: 25 times
Re: Strings
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
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Strings
Your welcome Brian,
So long as it's what you are after.
Glad I could help.
Thank you for letting us know.
So long as it's what you are after.
Glad I could help.
Thank you for letting us know.
Martin
- jollybv
- Flowcode v5 User
- Posts: 376
- Joined: Thu Feb 12, 2009 5:20 am
- Location: Cape Town
- Has thanked: 81 times
- Been thanked: 25 times
Re: Strings
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
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
- 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
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.
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 1099 times
-
- 4. Inputting a password.fcf
- (8.5 KiB) Downloaded 1084 times
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- jollybv
- Flowcode v5 User
- Posts: 376
- Joined: Thu Feb 12, 2009 5:20 am
- Location: Cape Town
- Has thanked: 81 times
- Been thanked: 25 times
Setup Routine
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
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
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel