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: 331
Joined: Thu Feb 12, 2009 5:20 am
Has thanked: 75 times
Been thanked: 23 times
Contact:

Strings

Postby jollybv » Wed Oct 20, 2010 12:01 pm

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: 14130
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4325 times
Been thanked: 4070 times
Contact:

Re: Strings

Postby Benj » Wed Oct 20, 2010 4:10 pm

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: 331
Joined: Thu Feb 12, 2009 5:20 am
Has thanked: 75 times
Been thanked: 23 times
Contact:

Re: Strings

Postby jollybv » Fri Oct 22, 2010 5:19 am

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: 331
Joined: Thu Feb 12, 2009 5:20 am
Has thanked: 75 times
Been thanked: 23 times
Contact:

Re: Strings

Postby jollybv » Fri Oct 22, 2010 6:42 am

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.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8323
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2380 times
Been thanked: 3391 times
Contact:

Re: Strings

Postby medelec35 » Fri Oct 22, 2010 9:09 am

Hiya jollybv.
Take a look here:
viewtopic.php?f=26&t=6936

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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8323
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2380 times
Been thanked: 3391 times
Contact:

Re: Strings

Postby medelec35 » Fri Oct 22, 2010 4:54 pm

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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
jollybv
Flowcode v5 User
Posts: 331
Joined: Thu Feb 12, 2009 5:20 am
Has thanked: 75 times
Been thanked: 23 times
Contact:

Re: Strings

Postby jollybv » Sat Oct 23, 2010 8:40 am

Thanks Ive sorted the problem

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8323
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2380 times
Been thanked: 3391 times
Contact:

Re: Strings

Postby medelec35 » Sat Oct 23, 2010 9:10 am

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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
jollybv
Flowcode v5 User
Posts: 331
Joined: Thu Feb 12, 2009 5:20 am
Has thanked: 75 times
Been thanked: 23 times
Contact:

Re: Strings

Postby jollybv » Sun Oct 24, 2010 11:36 am

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

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8323
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2380 times
Been thanked: 3391 times
Contact:

Re: Strings

Postby medelec35 » Sun Oct 24, 2010 12:40 pm

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:
viewtopic.php?f=5&t=7440&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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8323
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2380 times
Been thanked: 3391 times
Contact:

Re: Strings

Postby medelec35 » Sun Oct 24, 2010 12:58 pm

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 895 times
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
jollybv
Flowcode v5 User
Posts: 331
Joined: Thu Feb 12, 2009 5:20 am
Has thanked: 75 times
Been thanked: 23 times
Contact:

Re: Strings

Postby jollybv » Mon Oct 25, 2010 5:51 am

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: 14130
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4325 times
Been thanked: 4070 times
Contact:

Re: Strings

Postby Benj » Mon Oct 25, 2010 8:19 am

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: 331
Joined: Thu Feb 12, 2009 5:20 am
Has thanked: 75 times
Been thanked: 23 times
Contact:

Re: Strings

Postby jollybv » Wed Dec 29, 2010 10:11 am

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

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8323
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2380 times
Been thanked: 3391 times
Contact:

Re: Strings

Postby medelec35 » Wed Dec 29, 2010 11:34 am

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.
These users thanked the author medelec35 for the post:
jollybv (Thu Dec 30, 2010 6:29 am)
Rating: 5.56%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
jollybv
Flowcode v5 User
Posts: 331
Joined: Thu Feb 12, 2009 5:20 am
Has thanked: 75 times
Been thanked: 23 times
Contact:

Re: Strings

Postby jollybv » Wed Dec 29, 2010 11:50 am

Hi Martin

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

Brian

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8323
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2380 times
Been thanked: 3391 times
Contact:

Re: Strings

Postby medelec35 » Wed Dec 29, 2010 1:53 pm

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 868 times
These users thanked the author medelec35 for the post:
jollybv (Thu Dec 30, 2010 6:29 am)
Rating: 5.56%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
jollybv
Flowcode v5 User
Posts: 331
Joined: Thu Feb 12, 2009 5:20 am
Has thanked: 75 times
Been thanked: 23 times
Contact:

Re: Strings

Postby jollybv » Thu Dec 30, 2010 6:22 am

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: 331
Joined: Thu Feb 12, 2009 5:20 am
Has thanked: 75 times
Been thanked: 23 times
Contact:

Re: Strings

Postby jollybv » Thu Dec 30, 2010 6:27 am

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

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8323
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2380 times
Been thanked: 3391 times
Contact:

Re: Strings

Postby medelec35 » Thu Dec 30, 2010 9:48 am

Your welcome Brian,
So long as it's what you are after.
Glad I could help.
Thank you for letting us know.
These users thanked the author medelec35 for the post:
jollybv (Tue Jan 18, 2011 3:46 am)
Rating: 5.56%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
jollybv
Flowcode v5 User
Posts: 331
Joined: Thu Feb 12, 2009 5:20 am
Has thanked: 75 times
Been thanked: 23 times
Contact:

Re: Strings

Postby jollybv » Thu Feb 17, 2011 2:27 am

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: 14130
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4325 times
Been thanked: 4070 times
Contact:

Re: Strings

Postby Benj » Mon Feb 21, 2011 1:26 pm

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 819 times
4. Inputting a password.fcf
(8.5 KiB) Downloaded 813 times

User avatar
jollybv
Flowcode v5 User
Posts: 331
Joined: Thu Feb 12, 2009 5:20 am
Has thanked: 75 times
Been thanked: 23 times
Contact:

Setup Routine

Postby jollybv » Tue Feb 22, 2011 4:36 am

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: 14130
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4325 times
Been thanked: 4070 times
Contact:

Re: Strings

Postby Benj » Tue Feb 22, 2011 9:38 am

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: 331
Joined: Thu Feb 12, 2009 5:20 am
Has thanked: 75 times
Been thanked: 23 times
Contact:

Re: Strings

Postby jollybv » Wed Feb 23, 2011 4:42 pm

Hi Guys

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

Brian