Serial NMEA works but now what?

Sorry, I am a programming novice.

I’m using newsoftserial to read an electronic compass that outputs a NMEA statement: $HCHDM, 240.2, M*27
that I can now read on the serial monitor. It took forever to figure out so I am quite pleased.

Now I need a suggestion (a starting place) for extracting the numbers between the commas 240.2 in the statement above so they are available as a single variable.

Any suggestion would be gratefully received!

Here is “my” code:

#include <NewSoftSerial.h>

NewSoftSerial mySerial(2, 3, true); // RX here is receive pin 2; TX pin 3
byte aa;
void setup()
{
Serial.begin(4800); // this is the rate the computer talks to the arduino

// set the data rate for the NewSoftSerial port
mySerial.begin(4800); // default rate is 4800 bps

}

void loop() // run over and over again

{
if (mySerial.available())
{
aa= mySerial.read(); // get the byte of data
Serial.print(aa); // send it to the serial monitor
}
}

Now I need a suggestion (a starting place) for extracting the numbers between the commas 240.2 in the statement above so they are available as a single variable.

Extracting them from what? You need to store the data in a char array first. Then, strtok() can be useful (NOT strtok_r).