    ' ----------------- YGPARG - consulta tarjeta por grupo -----------------
    ' $INCLUDE: 'EDITAL.BAS'
      DIM SHARED V1%(2000),V2%(2000),V3%(2000)
      ON ERROR GOTO ErrorHandler

    ' $INCLUDE: 'OPNTEM.BAS'
    ' $INCLUDE: 'OPNXME.BAS'
      GET#5,1
      UM=CVS(UM5$)                                         ' ultimo mesero

      ' $INCLUDE: 'P55ARG.BAS'
      GET#55,1
      PR=CVI(PR55$)
      PC=CVI(PC55$)

5500  APUNTADOR% = VARPTR(V1%(1)):CALL SAVESCRN(1, APUNTADOR%)
      COLOR 15, 7:LOCATE 24,2:PRINT "Creando Indice, Favor de Esperar...  "+SPACE$(41);:LOCATE 23,2:PRINT "":COLOR 7,0:GOSUB 5532
      COLOR 15, 7:LOCATE 24,2:PRINT "Ordenando Indice, Favor de Esperar..."+SPACE$(41);:LOCATE 23,2:PRINT "":COLOR 7,0:GOSUB 5536
      COLOR 15, 7:LOCATE 24,1:PRINT SPACE$(80);:LOCATE 23,2:PRINT "" ' limpia mensaje
5504  COLOR 15,07
      PR=06:PC=34:NR=15:NC=43:GOSUB 9980
      PR=08:PC=35:NR=12:NC=41:GOSUB 9981
      COLOR  0, 7:LOCATE 7,36:PRINT "Nume      Nombre completo      Apodo   Gp"
                                 '   xxxx xxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxx xx
      COLOR 15, 7:LOCATE 24,02:PRINT SPACE$(78);
      COLOR 15, 7:LOCATE 24,02:PRINT " ";CHR$(24);" ";CHR$(25);" PgDn PgUp=desplazarse    Enter=insertar    END C=cancelar";
      COLOR 16,15:LOCATE 24,03:PRINT CHR$(24);
                  LOCATE 24,05:PRINT CHR$(25);
                  LOCATE 24,07:PRINT "PgDn";
                  LOCATE 24,12:PRINT "PgUp";
                  LOCATE 24,32:PRINT "Enter";
                  LOCATE 24,50:PRINT "END";
                  LOCATE 24,54:PRINT "C";
      LOCATE 23,2:PRINT "":COLOR 7,0

      IF RECCNT=0 THEN IB=0:GOTO 5509
      IB=1:LIMI=1:LIMS=LIMI+11
      IF LIMS>RECCNT THEN LIMS=RECCNT
         IF RECCNT>12 THEN PW=20 ELSE PW=LIMS+8
      GOSUB 5528
5506  BAND=0
      DO
          X$=INKEY$
          SELECT CASE X$
                 CASE IS=CHR$(13)                     ' es enter
                      BAND=1
                      NUM$=NUM22$
                      GOTO 5524
                 CASE IS=CHR$(0)+CHR$(72)             ' arriba
                      IF PW=9 THEN IF I=1 THEN ELSE LIMI=LIMI-1:LIMS=LIMS-1 ELSE PW=PW-1
                      GOSUB 5528
                 CASE IS=CHR$(0)+CHR$(80)             ' abajo
                      IF I=RECCNT THEN 5507
                      IF PW=20 THEN IF I=RECCNT THEN ELSE LIMI=LIMI+1:LIMS=LIMS+1 ELSE PW=PW+1
5507                  GOSUB 5528
                 CASE IS=CHR$(0)+CHR$(73)             ' page up
                      LIMI=LIMI-12:IF LIMI<=0     THEN LIMI=1
                      LIMS=LIMI+11:IF LIMS>RECCNT THEN LIMS=RECCNT
                      PW=9
                      GOSUB 5528
                 CASE IS=CHR$(0)+CHR$(81)             ' page down
                      LIMI=LIMI+12:IF LIMI>RECCNT THEN LIMI=RECCNT-11:IF LIMI<=0 THEN LIMI=1
                      LIMS=LIMI+11:IF LIMS>RECCNT THEN LIMS=RECCNT:LIMI=LIMS-11:IF LIMI<=0 THEN LIMI=1
                      PW=LIMS-LIMI+9
                      GOSUB 5528
                 CASE IS=CHR$(0)+CHR$(79)             ' es end
                      GOTO 5524
                 CASE IS="C"                          ' es C
                      GOTO 5524
                 CASE IS="c"                          ' es c
                      GOTO 5524
                 CASE ELSE
          END SELECT
      LOOP UNTIL X$=CHR$(13) OR X$=CHR$(0)+CHR$(72) OR X$=CHR$(0)+CHR$(80) OR X$="C"
      GOTO 5506

5509  COLOR 16,15:LOCATE 24,2:PRINT SPACE$(78);
      IF IB=0 THEN COLOR 16,15:LOCATE 24,2:PRINT " No encontr¢ el empleado...";:LOCATE 23,2:PRINT "":BEEP:W$=INPUT$(1)
      COLOR 16,15:LOCATE 24,2:PRINT SPACE$(78);:LOCATE 23,2:PRINT ""
      BAND=0

5524  APUNTADOR% = VARPTR(V1%(1)):CALL RESTSCRN(1, APUNTADOR%)
      LSET NUM55$ =NUM$
      LSET BAND55$=MKI$(BAND)
      PUT#55,1
      CLOSE:END

5528  COLOR 7,0
      CR=8:COLOR 15,07                                ' reimprime cuadro
      FOR I=LIMI TO LIMS
          GET#22,I
          CR=CR+1
          LOCATE CR,36:PRINT NUM22$;" ";NOL22$;" ";NOC22$;" ";GPO22$
      NEXT I
      I=LIMI+PW-9
      GET#22,I
      COLOR 15,1:LOCATE PW,36:PRINT NUM22$;" ";NOL22$;" ";NOC22$;" ";GPO22$
      COLOR 7,0
      RETURN

5532                                                       ' CREA INDICE
        GOSUB 5540                                         ' abre archivo indice
        CLOSE#22                                           ' cierra arch indice
        KILL IND$                                          ' borra arch indice
        GOSUB 5540                                         ' abre arch indice
        IJ=0
        FOR I=1 TO UM                                      ' busca mesero
            GET#2,I                                        ' accesa registro
            COLOR 15,7:LOCATE 24,70:PRINT USING "###.#%";(I/UM)*100;:LOCATE 23,2:PRINT ""
            IF ASC(F2$)=0 THEN
               LSET NOL22$=NL2$                            ' nombre
               LSET NOC22$=SN2$                            ' apodo
               GPO =CVI(GP2$)
               GPO$=MID$(STR$(GPO),2):IF LEN(GPO$)=1 THEN GPO$="0"+GPO$
               LSET GPO22$=GPO$                            ' grupo
               LSET NUM22$=NU2$                            ' numero
               LSET CS22$=MKI$(1)                          ' indicador de sort
               IJ=IJ+1                                     ' incrementa indice
               PUT#22,IJ                                   ' graba indice
            ENDIF
        NEXT I
        RETURN
5536                                                ' ORDENAR (SORT)
     PLC$="C:O22IND.ARG"                            ' indice
     '                                    reg        nombre         indbaj
       CMND$="2\1\0\0\"+PLC$+"\"+PLC$+"\0\40\N\N\0\37\2\A\A\1\4\A\A\0\Y\D\39\2\I\E\0\0"
       CLOSE#22                                     ' cierra arch indice
     ' CALL SETCON(SLVN$)
     SLVN$="1"
     CALL SORTMC(CMND$,SORTERR%,RECCNT%)
     RECCNT=RECCNT%
     IF RECCNT<0 THEN RECCNT=RECCNT+65536
     IF SORTERR%=0 THEN GOSUB 5540:RETURN
     PRINT:PRINT "*** ERROR AL ORDENAR ARCHIVO INDICE ...VERFIFIQUE QUE HAYA ESPACIO SUFICIENTE";SORTERR%
     CLOSE:END

5540 IND$="C:O22IND.ARG"
     ' $INCLUDE: 'O22ARG.BAS'
     RETURN

6999 ' $INCLUDE: 'R50GRL.BAS'

ErrorHandler:
      IF ERR=70 THEN LOCATE 24,01:COLOR 16,15:PRINT "pd...";:LOCATE 23,2:PRINT "":RESUME
      IF ERR=24 OR ERR=25 OR ERR=27 THEN GOSUB 7510:RESUME
      COLOR 16,15:LOCATE 24,01:PRINT "Error en los datos ";ERR;" Linea ";ERL;". Llame a SIERRA.";:LOCATE 23,2:PRINT "":W$=INPUT$(1):CLOSE:END
