GSM and GPS Help Needed plzz

Good day, I have a GSM module and a GPS module… I found and tested the code for each one successfully… now i need to put them both together… what i need is 1) take an initial reading from GPS and save it 2) keep reading from GPS untill getting new latitude > old latitude +10 OR new logitude > old longitude +10… 3) if this happens I need to send an SMS using GSM…
Here is the code for GPS:

#include <string.h>
 #include <ctype.h>
 int ledPin = 13;                  // LED test pin
 int rxPin = 0;                    // RX PIN 
 int txPin = 1;                    // TX TX
 int byteGPS=-1;
 char linea[300] = "";
 char comandoGPR[7] = "$GPRMC";
 int cont=0;
 int bien=0;
 int conta=0;
 int indices[13];
 void setup() {
   pinMode(ledPin, OUTPUT);       // Initialize LED pin
   pinMode(rxPin, INPUT);
   pinMode(txPin, OUTPUT);
   for (int i=0;i<300;i++){       // Initialize a buffer for received data
     linea[i]=' ';
 void loop() {
   digitalWrite(ledPin, HIGH);;         // Read a byte of the serial port
   if (byteGPS == -1) {           // See if the port is empty yet
   } else {
     linea[conta]=byteGPS;        // If there is serial port data, it is put in the buffer
     //Serial.print(byteGPS, BYTE); 
     if (byteGPS==13){            // If the received byte is = to 13, end of transmission
       digitalWrite(ledPin, LOW); 
       for (int i=1;i<7;i++){     // Verifies if the received command starts with $GPR
         if (linea[i]==comandoGPR[i-1]){
       if(bien==6){               // If yes, continue and process the data
         for (int i=0;i<300;i++){
           if (linea[i]==','){    // check for the position of the  "," separator
           if (linea[i]=='*'){    // ... and the "*"
         Serial.println("");      // ... and write to the serial port
         for (int i=2;i<5;i+=2){
             case 2 :Serial.print("Latitude: ");break;
             case 4 :Serial.print("Longitude: ");break;
           for (int j=indices[i];j<(indices[i+1]-1);j++){
       conta=0;                    // Reset the buffer
       for (int i=0;i<300;i++){    //  
         linea[i]=' ';             

Here Is the code for GSM

#include <NewSoftSerial.h>
NewSoftSerial cell(2,3);  // We need to create a serial port on D2/D3 to talk to the GSM module
char mobile[xxxxxxxxxx] = "xxxxxxxx";  // Replace xxxxxxxx with the recipient's mobile number
void setup()
{  //Initialize serial ports for communication.
delay(35000); // give the GSM module time to initialise, locate network etc.
// this delay time varies. Use example 26.1 sketch to measure the amount
// of time from board reset to SIND: 4, then add five seconds just in case
void loop()
cell.println("AT+CMGF=1"); // set SMS mode to text
cell.print("AT+CMGS=");  // now send message...
cell.print(34,BYTE); // ASCII equivalent of "
cell.println(34,BYTE);  // ASCII equivalent of "
delay(500); // give the module some thinking time
cell.print("Arduino");   // our message to send
cell.println(26,BYTE);  // ASCII equivalent of Ctrl-Z
delay(15000); // the SMS module needs time to return to OK status
do //to send 1 msg only
while (1>0);

Please read this,97455.0.html, part 6 in particular. Then go back and modify your post using [code]...[/code] tags. That way we won't get italics, and we can see your sketch properly.