Hi
I have 3 locations in EEprom to which I want to assign an phone number each. I want to achieve this by sending an text messege from an already programmed phone number in the PIC. Its not working for me at the moment when I try to add the number to location 1 & sometimes 2. It works pretty well when I use location 3. Here is my program

DEFINE OSC 4
ADCON1=7
CMCON=7
INTCON=0
OPTION_REG.7=0
TRISA=0 : PORTA=0
TRISB=0 : PORTB=0
TRISC=%10000000 : PORTC=0
TRISD=0 : PORTD=0
TRISE=0 : PORTE=0
CCP1CON=0
a var byte
b var byte
c var byte
d var byte
e var byte
f var byte
g var byte
num var byte[13]
ph1 var byte[13]
ph2 var byte[13]
ph3 var byte[13]
my1 var byte[13]
my2 var byte[13]
sms var byte[17]
@ ERRORLEVEL -306
yellowled var portb.4
redled var portb.5
greenled var portb.6

Include "modedefs.bas"
EEPROM 200,["+","4","4","7","8","3","2","3","2","3","1","4","6 ","+","4","4","7","9","3","1","2","2","5","2","3", "7"]

gosub load

gosub del

main:
high portb.6 : pause 30 : low portb.6

DEBUG "AT^SMGR=1",13
DEBUGIN 5000,main,[WAIT("UNREAD"),SKIP 3,STR num\13\13,SKIP 27,STR sms\17\13]

gosub chk : pause 500
DEBUG "AT+CMGD=1",13
for a=0 to 15
num[a]="0" : sms[a]="0"
next a
goto main

chk:
a=0 : b=0 : d=0 : e=0 : f=0
for g=0 to 12
if num[g]=ph1[g] then a=a+1
if num[g]=ph2[g] then b=b+1
if num[g]=ph3[g] then d=d+1
if num[g]=my1[g] then e=e+1
if num[g]=my2[g] then f=f+1
next g
if (a=13) OR (b=13) OR (d=13)then gosub chkms
if (e=13) OR (f=13)then gosub adn
return


adn:
for g=0 to 50
toggle yellowled
pause 50
next g
if sms[0]="+" then

SELECT CASE sms[13]
CASE "1"
for a=0 to 12
write a,num[a]
next a

CASE "2"
for a=0 to 12
write a+13,num[a]
next a

CASE "3"
for a=0 to 12
write a+26,num[a]
next a
END SELECT
gosub load

return

chkms:
for g=0 to 30
toggle greenled
pause 30
next g
return




load:
for a=0 to 12
read a,ph1[a] : read a+13,ph2[a] : read a+26,ph3[a]
next a

return

del:
DEBUG "AT+CMGD=1",13
DEBUGIN 5000,del,[WAIT("OK")]
gosub set
return

set:
pause 1000
DEBUG "AT+CMGF=1",13
DEBUGIN 5000,set,[WAIT("OK")]
return

' sms[13] decides which location the number will be stored.
Please help