# Agenda telefônica, by Cristian Robert Gallas.
# 06/11/1994, Desenvolvido na versão 2.5.1, não roda em COLORS=2

a="";b="";c="";i=""
_INICIO
cls
  under on
  cup;centre "AGENDA TELEFONICA"
  under off
  pos 34 4;echo "1 - Inclui"
  pos 34 6;echo "2 - Exclui"
  pos 34 8;echo "3 - Consulta"
  pos 34 10;echo "4 - Ordena"
  pos 34 12;echo "5 - Imprime"
  pos 30 16;insert "Qual opção: ",,6,p1,i0,,p0,i2
  attrib i
if i==""
   echo
   exit
fi
if i=1
   goto INCLUI
fi
if i=2
   goto EXCLUI
fi
if i=3
   goto CONSULTA
fi
if i=4
   goto ORDENA
fi
if i=5
   goto IMPRIMI
else
   goto INICIO
fi
_INCLUI
 cls
 under on
 pos 0 2;centre "MODULO DE INCLUSÃO"
 under off
 pos 16 5;insert "Qual nome ...... : ",,29,p1,i0,,p0,i2
 attrib i

 if i==""
    goto INICIO
 fi
 pos 16 7;insert "Qual telefone .. : ",,29,p1,i0,,p0,i2
 attrib a

 if a==""
    goto INICIO
 fi
pos 0 10
border -c " Aguarde atualização... "
len -o i;attrib c
b=40;b=b-${c};c=${b};b=""
spc ${c};attrib b
c=${path}
echo ${i}${b}${a} >> ${c}tel.lt
goto INCLUI
_CONSULTA
cls;under on
pos 0 2
centre MODULO DE CONSULTA;under off
pos 32 6;echo "1 - Individual"
pos 32 8;echo "2 - Todos"
pos 31 12;insert "Qual opção: ",,6,p1,i0,,p0,i2
attrib i
if i=1
   goto INDIVIDUAL
fi
if i=2
   goto TODOS
else
   goto INICIO
fi
_INDIVIDUAL
pos 20 12;insert "Consultar ... : ",,29,p1,i0,,p0,i2
attrib i
if i==""
   goto INICIO
else
cls
echo "_________ NOME __________           _____ TELEFONE _____"
echo
a=${path}
   grep ${a}tel.lt ${i}
   echo
   echo -a "Pressione [QUALQUER TECLA] ..."
   wait key
   goto INICIO
fi
_TODOS
cls
echo "_________ NOME __________           _____ TELEFONE _____"
echo
a=${path}
pg ${a}tel.lt
echo
echo -a "Pressione [QUALQUER TECLA] ..."
wait key
goto INICIO
_EXCLUI
pos 20 16;insert Excluir ... : ,,29,p1,i0,,p0,i2
attrib i
if i==""
   goto INICIO
else
a=${path}
   grep -a -o ${a}tel.lt ${i}
   attrib i
fi
cup;cline
a=${path}
pos 12 18;lgrep ${a}tel.lt,${i}
pos 12 16
pos 12 16;insert ____ Confirma exclusão [ 1 ] Sim, [ 2 ] Não ____ ,,4,p1,i0,,p0,i2
attrib a
if a=2
   goto INICIO
fi
if a=1
   a=${path}
   cut line ${a}tel.lt,${i}
   pos 12 18
   echo "Exclusão com sucesso                  "
   sleep 100
   goto INICIO
else
   goto INICIO
fi
_IMPRIMI
a=${path}
pos 56 16;paper 1;echo "    "
paper 0
pos 21 16
lp ${a}tel.lt,60,6
goto INICIO
_ORDENA
pos 30 16;cline
border -c  Ordenando... ;
a=${path}
sort ${a}tel.lt > ram:tel.lt0
rm ${a}tel.lt;mv ram:tel.lt0 ${a}tel.lt
goto INICIO
