Best tactic: how to split data sentences?

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

Moderator: Benj

Post Reply
MJU
Posts: 502
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 121 times
Been thanked: 108 times
Contact:

Best tactic: how to split data sentences?

Post by MJU »

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.

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: Best tactic: how to split data sentences?

Post by medelec35 »

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

MJU
Posts: 502
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 121 times
Been thanked: 108 times
Contact:

Re: Best tactic: how to split data sentences?

Post by MJU »

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!!

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: Best tactic: how to split data sentences?

Post by Benj »

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.

MJU
Posts: 502
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 121 times
Been thanked: 108 times
Contact:

Re: Best tactic: how to split data sentences?

Post by MJU »

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..

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: Best tactic: how to split data sentences?

Post by medelec35 »

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

MJU
Posts: 502
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 121 times
Been thanked: 108 times
Contact:

Re: Best tactic: how to split data sentences?

Post by MJU »

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

Post Reply