   ' ============ ::::::::   MCAARG :::::::: ==============================
   '
   ' :::::::  ANALISIS DE VENTAS                   
   '                                                
   ' SISTEMAS SIERRA SA DE CV                    MODIFICA CLAVES DE ACCESO
   ' 15-Oct-2003 1005  creaci¢n inicial del programa
   ' ======================================================================
    
    ' $INCLUDE: 'EDITAL.BAS'
      DIM SHARED V1%(2000),V2%(2000),V3%(2000)
      ON ERROR GOTO ErrorHandler
      WIDTH LPRINT 150                                     ' asigna impresor

      GOSUB 9802                                           ' carga parametros
      CVEACC=59:GOSUB 6897:IF VCVE=1 THEN CLOSE:END
    ' $INCLUDE: 'AUTARG.BAS'

      IF LEN(ANO$)=2 THEN XANO$=ANO$:IF ANO$<"80" THEN ANO$="20"+ANO$ ELSE ANO$="19"+ANO$

110   GOSUB 350                                            ' INICIA PROCESO
      CLOSE                                                ' cierra archivos
      END

350                                                        ' CLAVES
     GOSUB 10016                                           ' cuadro pantalla
     SISTEMA$="ANALISIS DE VENTAS":LG=79                   ' titulo
     MENU$="Modifica claves"
     GOSUB 8300                                            ' encabezado
     COLOR 7,0                                             ' intensidad media

     COLOR 7,0                                             ' intensidad media
     PR= 9:PC=09:NR=04:NC=62:GOSUB 9980
     PR=11:PC=10:NR=01:NC=04:GOSUB 9981
     PR=11:PC=16:NR=01:NC=07:GOSUB 9981
     PR=11:PC=25:NR=01:NC=30:GOSUB 9981
     PR=11:PC=57:NR=01:NC=05:GOSUB 9981
     PR=11:PC=64:NR=01:NC=06:GOSUB 9981
     COLOR  0,7:LOCATE 10,12:PRINT "Num    Men£            Descripci¢n            Clave  Progrm"

     OPEN "PSWACC.ARG" FOR RANDOM ACCESS READ WRITE SHARED AS #41 LEN=49
     FIELD#41,1AS ST41$,7AS MN41$,30AS DE41$,5AS CV41$,6AS PG41$

1010 GOSUB 1012:GOSUB 1014:GOSUB 1016:GOSUB 1018:GOSUB 1020:GOTO 1050
1012 COLOR 15,7:LOCATE 12,11:PRINT SPACE$(04):RETURN
1014 COLOR 15,7:LOCATE 12,17:PRINT SPACE$(07):RETURN
1016 COLOR 15,7:LOCATE 12,26:PRINT SPACE$(30):RETURN
1018 COLOR 15,7:LOCATE 12,58:PRINT SPACE$(05):RETURN
1020 COLOR 15,7:LOCATE 12,65:PRINT SPACE$(06):RETURN

1050 LS=1000
     NUM$=SPACE$(4)
     MNU$=SPACE$(7)
     DES$=SPACE$(3)
     CVE$=SPACE$(5)
     PRG$=SPACE$(6)

1100 MENSAJE$=" N£mero de men£.  F8=consulta.  0=clave de acceso al sistema.":GOSUB 15710
     COLOR 16,15:LOCATE 24,20:PRINT "F8";
                 LOCATE 24,34:PRINT "0";
     LOCATE 23,2:PRINT "":COLOR 7,0
     IF NUM$=SPACE$(4) THEN S$="" ELSE S$=NUM$
     COLOR 15,1:W=12:Z=11:L=4:T=1:keypressed = edit(z,w,l,S$) ' NUMERO
     IF KEYPRESSED=ESCAPE OR KEYPRESSED=UPARROW THEN RETURN
     IF KEYPRESSED=FF8 THEN
        GOSUB 2800
        S$=NUM$
     ENDIF
     NUM$=STRING$(4-LEN(S$),"0")+S$
     COLOR 15,7:LOCATE 12,11:PRINT NUM$
     NUM=VAL(S$)
     IF NUM=0 THEN
        ' $INCLUDE: 'OPNTEM.BAS '
        GET#5,1                                            ' accesa temporal
        CVE$=PW5$
        LOCATE 12,26:PRINT "Clave de acceso al sistema"
        LOCATE 12,58:PRINT CVE$
1110    MENSAJE$=" Clave de acceso.  xxxxx ":GOSUB 15710
        IF CVE$=SPACE$(5) THEN S$="" ELSE S$=CVE$
        COLOR 15,1:W=12:Z=58:L=5:T=3:keypressed = edit(z,w,l,S$) ' CLAVE
        IF KEYPRESSED<>ESCAPE AND KEYPRESSED<>UPARROW THEN
           CVE$=S$+SPACE$(5-LEN(S$))                       ' clave
           COLOR 15,7:LOCATE 12,58:PRINT CVE$              ' imprime
        ENDIF
        LSET PW5$=CVE$
        PUT#5,1
        BEEP
        CLOSE#5
        GOSUB 5000
        PR=15:PC=59:NR=05:NC=12:GOSUB 9981
        COLOR 15,7
           LOCATE PR+1,PC+1:PRINT " IMPORTANTE "
           LOCATE PR+2,PC+1:PRINT "Guarde en un"       
           LOCATE PR+3,PC+1:PRINT "lugar seguro"
           LOCATE PR+4,PC+1:PRINT "la clave:   "
           LOCATE PR+5,PC+1:PRINT "   xxxxx    "
        COLOR 1,7
           LOCATE PR+1,PC+1:PRINT " IMPORTANTE "
        COLOR 4,7
           LOCATE PR+5,PC+4:PRINT CVE$
           W$=INPUT$(1)
        GOSUB 5002
        GOTO 1010
     ENDIF
     IF NUM<1 OR NUM>LS THEN
        GOSUB 7600
        GOTO 1010
     ENDIF
     GET#41,NUM
     IF ASC(ST41$)=255 THEN
        GOSUB 7590
        GOTO 1010                                          ' no existe
     ELSE
        MNU$=MN41$
        DES$=DE41$
        CVE$=CV41$
        PRG$=PG41$
        COLOR 15,7
           LOCATE 12,17:PRINT MNU$
           LOCATE 12,26:PRINT DES$
           LOCATE 12,58:PRINT CVE$
           LOCATE 12,65:PRINT PRG$
     ENDIF

1170 MENSAJE$=" Clave de acceso.  xxxxx ":GOSUB 15710
     IF CVE$=SPACE$(5) THEN S$="" ELSE S$=CVE$
     COLOR 15,1:W=12:Z=58:L=5:T=3:keypressed = edit(z,w,l,S$) ' CLAVE
     IF KEYPRESSED=ESCAPE OR KEYPRESSED=UPARROW THEN
        COLOR 15,7:LOCATE 12,58:PRINT CVE$
        GOTO 1010
     ELSE
        CVE$=S$+SPACE$(5-LEN(S$))                          ' clave
        COLOR 15,7:LOCATE 12,58:PRINT CVE$                 ' imprime
    ENDIF

1175 LSET ST41$=CHR$(0)
     LSET MN41$=MNU$
     LSET DE41$=DES$
     LSET CV41$=CVE$
     LSET PG41$=PRG$
     PUT#41,NUM
     BEEP
     IF NUM=59 THEN
        GOSUB 5000
        PR=15:PC=59:NR=05:NC=12:GOSUB 9981
        COLOR 15,7
           LOCATE PR+1,PC+1:PRINT " IMPORTANTE "
           LOCATE PR+2,PC+1:PRINT "Guarde en un"       
           LOCATE PR+3,PC+1:PRINT "lugar seguro"
           LOCATE PR+4,PC+1:PRINT "la clave:   "
           LOCATE PR+5,PC+1:PRINT "   xxxxx    "
        COLOR 1,7
           LOCATE PR+1,PC+1:PRINT " IMPORTANTE "
        COLOR 4,7
           LOCATE PR+5,PC+4:PRINT CVE$
           W$=INPUT$(1)
        GOSUB 5002
     ENDIF
     GOTO 1010

2800                                                       ' CONSULTA
     ' $INCLUDE: 'I60ARG.BAS'
       LSET NUM60$ =SPACE$(4)
       PUT#60,1
       CLOSE#60
       SHELL "\SIEARG2\CMNARG"                             ' INSERTA MENU
       ' $INCLUDE: 'I60ARG.BAS'
       GET#60,1
       NUM$=NUM60$
       CLOSE#60
       RETURN

5000 AP%=VARPTR(V1%(1)):CALL SAVESCRN(1, AP%):RETURN
5002 AP%=VARPTR(V1%(1)):CALL RESTSCRN(1, AP%):RETURN

6999 ' $INCLUDE: 'R40GRL.BAS'
     ' $INCLUDE: 'LEFARG.BAS'
     ' $INCLUDE: 'KEYARG.BAS'
     ' $INCLUDE: 'VERSFT.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
