Best tactic: how to split data sentences?

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

Moderator: Benj

MJU
Posts: 430
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 105 times
Been thanked: 94 times
Contact:

Best tactic: how to split data sentences?

Postby MJU » Tue Oct 13, 2015 2:52 pm

What is the common way to split a sentence of data in data blocks?

For use in a GPS project I have to split a data stream into several parts.
The data sentence is separated with commas ',' and each block represents a certain part of the data I need.
So for instance $GPGGA,11111.11,222.22,3,444,5555555555,66,,7
Must become:
- variable1= $GPGGA
- variable2= 11111.11
- variable3= 222.22
- variable4= 3
- variable5= 444
- variable6= 5555555555
- variable7= 66
- variable8=
- variable9= 7

Is there a standard way to accomplish this?
I have tried my own method, but maybe this was to difficult.
I'm not sure that the length of each sentence is the same, so if there is a method to easily split these sentences, I'm willing to learn..
Any help is welcome.

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

Re: Best tactic: how to split data sentences?

Postby medelec35 » Tue Oct 13, 2015 4:35 pm

Hi MJU,
I'm assuming you require help with flowcode V6?
If so take a look at the flowchart.
I did not have a lot of time but thought of one way.
There maybe a better way?

Martin
Attachments
Split Variables1.fcfx
(10.59 KiB) Downloaded 209 times
These users thanked the author medelec35 for the post (total 2):
MJU (Tue Oct 13, 2015 5:15 pm) • tiny (Tue Oct 13, 2015 6:04 pm)
Rating: 10.53%
 
Martin

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

MJU
Posts: 430
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 105 times
Been thanked: 94 times
Contact:

Re: Best tactic: how to split data sentences?

Postby MJU » Tue Oct 13, 2015 5:15 pm

medelec35 wrote:Hi MJU,
I'm assuming you require help with flowcode V6?
If so take a look at the flowchart.
I did not have a lot of time but thought of one way.
There maybe a better way?

Martin


Hello Martin, my hero!

Thank you for your help!
Would you believe this is almost the same way I did this?
I used a few more variables to get there, but your solution looks very good!

I always think that professional programmers know 'tactics' to get solutions much better then people like me.
I want to learn!

Thanks!!
These users thanked the author MJU for the post:
medelec35 (Tue Oct 13, 2015 5:37 pm)
Rating: 5.26%
 

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

Re: Best tactic: how to split data sentences?

Postby Benj » Tue Oct 13, 2015 5:20 pm

Hello,

So you know the GPS component will also do this for you automatically behind the scenes and do the conversions for you from hours and minutes to longitude or latitude.
These users thanked the author Benj for the post:
MJU (Tue Oct 13, 2015 5:27 pm)
Rating: 5.26%
 

MJU
Posts: 430
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 105 times
Been thanked: 94 times
Contact:

Re: Best tactic: how to split data sentences?

Postby MJU » Tue Oct 13, 2015 5:26 pm

Benj wrote:Hello,

So you know the GPS component will also do this for you automatically behind the scenes and do the conversions for you from hours and minutes to longitude or latitude.


Thank you BenJ, but the GPS component is assigned to the standard UART pins.
I can not tell the component to use other pins for the GPS but the standard pins.
With other components we can choose "software", but with this one this doesn't work.

If like now I use an Arduino Uno with the normal UART in use to communicate with my PC and the GPS module connected to D3/4 I need to solve this.
No worries, in this case I learn a lot about the NMEA sentences.

But if you could, you may always look into the GPS component and why I can't choose other pins..

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

Re: Best tactic: how to split data sentences?

Postby medelec35 » Tue Oct 13, 2015 5:37 pm

Hi MJU,
No problem, Just glad I could help.
Sounds like you was very near to your own solution.
I have moved topic to V6 section since I posted a V6 flowchart.

Martin
Martin

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

MJU
Posts: 430
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 105 times
Been thanked: 94 times
Contact:

Re: Best tactic: how to split data sentences?

Postby MJU » Tue Oct 13, 2015 5:41 pm

medelec35 wrote:Hi MJU,
I'm assuming you require help with flowcode V6?
If so take a look at the flowchart.
I did not have a lot of time but thought of one way.
There maybe a better way?

Martin


I looked at it in greater detail and for me this is of great beauty.
My solution was opposite from your solution and your way is much better.

I started to count the "MainStringVariable" from 0 until I found a ",".
So this way I had a start and an end point.
Between these two there was the string I was looking for.
So I "mid$"-ed this into a variable. (which I needed to count).
So by switching the endpoint and use it as a startpoint for the next part it worked.
But this was much more complicated then your method.

You keep adding figures onto a string until you find the ","..
Such a beautiful solution :D
These users thanked the author MJU for the post:
medelec35 (Tue Oct 13, 2015 5:44 pm)
Rating: 5.26%