identification division.
program-id. j2.
* (programa test velocidad)
* (por jcantero)
environment division.
configuration section.
source-computer. rmcobol-85.
object-computer. rmcobol-85.
special-names.
decimal-point is comma.
*
input-output section.
file-control.
*
select f-tmp assign to random nombre-f-tmp
organization indexed
access mode is dynamic
record key is clave-t
file status is fs-f-tmp.
select f-tmpx assign to random nombre-f-tmpx
organization indexed
access mode is dynamic
record key is clave-tx
alternate record key is clave-t1x with duplicates
alternate record key is clave-t2x with duplicates
alternate record key is clave-t3x with duplicates
alternate record key is clave-t4x with duplicates
file status is fs-f-tmpx.
data division.
file section.
*
fd f-tmp.
01 reg-f-tmp.
02 clave-t pic 9(15). EURO
02 clave-t1 pic 9(15). EURO
02 clave-t2 pic 9(15). EURO
02 clave-t3 pic x(15). EURO
02 clave-t4 pic x(15). EURO
02 linea-f-tmp.
03 filler pic xx.
03 c-1 pic x(10).
03 filler pic xx.
03 c-2 pic x(40).
03 filler pic xx.
03 c-3 pic x(5).
03 filler pic xx.
02 linea-f-tmpx.
03 pic x(14).
03 c-4 pic x(40).
03 pic x(9).
02 cx pic x(9).
fd f-tmpx.
01 reg-f-tmpx.
02 clave-tx pic 9(15). EURO
02 clave-t1x pic 9(15). EURO
02 clave-t2x pic 9(15). EURO
02 clave-t3x pic x(15). EURO
02 clave-t4x pic x(15). EURO
02 linea-f-tmpxxx.
03 filler pic xx.
03 c-1x pic x(10).
03 filler pic xx.
03 c-2x pic x(40).
03 filler pic xx.
03 c-3x pic x(5).
03 filler pic xx.
02 linea-f-tmpxxxx.
03 pic x(14).
03 c-4x pic x(40).
03 pic x(9).
02 cx pic x(9).
*
working-storage section.
*
01 nada pic x.
01 fs-camino pic xx.
01 fs-f-tmp pic xx.
88 esta-tmp value '00'.
88 n-esta-tmp value '23' '22'.
88 n-existe-tmp value '35'.
88 fin-tmp value '10' '46'.
01 fs-f-tmpx pic xx.
88 esta-tmpx value '00'.
88 n-esta-tmpx value '23' '22'.
88 n-existe-tmpx value '35'.
88 fin-tmpx value '10' '46'.
01 mun00-pueblo pic 99.
*
01 nombre-f-tmp pic x(80) value 'test1.psa '.
01 nombre-f-tmpx pic x(80) value 'test5.psa '.
01 tecla pic 99 value 0.
88 f1 value 01.
88 f2 value 02.
88 f3 value 03.
88 f4 value 04.
88 f5 value 05.
88 f6 value 06.
88 f7 value 07.
88 f8 value 08.
88 f9 value 09.
88 f10 value 10.
88 f11 value 11.
88 f12 value 12.
88 f13 value 13.
88 f14 value 14.
88 f15 value 15.
88 f16 value 16.
88 f17 value 17.
88 escapar value 27 11.
88 arriba value 52.
88 abajo value 53.
88 izquierda value 65, 56.
88 pg-up value 67.
88 pg-dn value 68.
88 intro value 13.
88 derecha value 09 66.
01 mensaje pic x(80) value spaces.
01 x pic x value ' '.
88 es-s value 'S' 's'.
88 es-n value 'N' 'n'.
88 es-sn value 'S' 's' 'N' 'n'.
01 fecha pic 9(6) value 0.
01 fechax pic 9(6) value 0.
01 i pic 9(9) value 0.
01 j pic 9(9) value 0.
01 k pic 9(9) value 0.
01 kk pic 9(9) value 0.
01 a-j pic 9(9) value 0.
01 m pic 9(9) value 0.
01 l pic 9(9) value 0.
01 tope pic 9(9).
01 linea-pan1 PIC 99 USAGE BINARY VALUE 17.
01 hasta-linea1 PIC 99 USAGE BINARY VALUE 22.
01 reg-ventana.
02 vx pic 99 value 1.
02 vy pic 99 value 17.
02 vw pic 99 value 79.
02 vz pic 99 value 22.
02 vi pic 999.
02 vj pic 999.
02 esca pic 9999 comp-1 value 27.
02 filler redefines esca.
03 filler pic x.
03 esc pic x.
02 act-g.
03 esc1 pic x.
03 filler pic xx value '(0'.
02 des-g.
03 esc2 pic x.
03 filler pic xx value '(B'.
02 vlinea pic x(100).
02 rlinea pic x(77) value all 'q'.
01 x1 pic x value ' '.
01 reg-errores.
02 f-e pic xx.
02 n-e pic x(13).
01 lk-cod pic x(9).
01 registros pic 9(15).
01 i-registros pic 9(15).
01 t-inicio pic 9(12).
01 t-final pic 9(12).
01 c-tiempo pic 9(12)v99.
01 c-tiempo1 pic 9(12).
01 c-tiempo2 pic 9(12).
01 ct-tiempo pic 9(12).
01 numero pic 9(12)v99.
01 numero-medio pic 9(12)v99.
01 ct-ent pic 9(12)v99.
01 ct-sal pic 9(12)v99.
01 ct-veces pic 9(12).
01 c-minutos pic z.zzz.zzz,zz.
01 c-seg pic 9(12).
01 c-min pic 9(12).
01 c-hor pic 9(12).
01 e-tiempo pic 99.99.99.99.
01 e-registro pic zzz.zzz.zz9,99.
procedure division.
declaratives.
io-error section.
use after standard error procedure on
f-tmp f-tmpx.
end declaratives.
main section.
iniciow.
display ' Prueba de velocidad ' line 1 position 1
reverse erase.
initialize registros.
inicio.
display ' Numero de registros ' line 2 position 1.
accept registros line 2 position 30 update on exception tecla
continue
end-accept
if not intro and not escapar go inicio.
initialize numero-medio
perform ciclo1 thru fin-ciclo1.
perform ciclo1x thru fin-ciclo1x.
compute e-registro rounded = numero-medio / 4.
display ' Proceso terminado, (tiempo medio '
e-registro
' reg/seg) Pulse tecla...'
accept x.
fin-p.
goback.
tiempo-inicio.
accept t-inicio from time
move t-inicio to e-tiempo.
display ' Hora de inicio '
e-tiempo.
tiempo-final.
accept t-final from time
move t-final to e-tiempo.
display ' final '
e-tiempo.
perform totaliza-tiempo.
move c-tiempo to e-registro.
display ' Tiempo invertido (segundos) '
e-registro
move numero to e-registro.
display ' Registros/segundo '
e-registro.
add numero to numero-medio.
ciclo1.
display ' '.
display '--------- Generando fichero 1 clave ---------'
perform tiempo-inicio
perform abrir-ficheros thru fin-abrir-ficheros.
perform procesar-fichero.
perform tiempo-final.
display ' '.
display '--------- Leyendo fichero 1 clave ---------'
perform tiempo-inicio
perform procesar-fichero1.
perform tiempo-final.
close f-tmp.
fin-ciclo1.
ciclo1x.
display ' '.
display '--------- Generando fichero 5 claves ---------'
perform tiempo-inicio
perform abrir-ficherosx thru fin-abrir-ficherosx.
perform procesar-ficherox.
perform tiempo-final.
display ' '.
display '--------- Leyendo fichero 5 claves ---------'
perform tiempo-inicio
perform procesar-fichero1x.
perform tiempo-final.
close f-tmpx.
fin-ciclo1x.
totaliza-tiempo.
move t-final to c-tiempo1
divide c-tiempo1 by 1000000 giving c-hor remainder
c-tiempo2
divide c-tiempo2 by 10000 giving c-min remainder
c-tiempo1
divide c-tiempo1 by 100 giving c-seg remainder
c-tiempo2
compute ct-sal = c-hor * 3600 + c-min * 60 + c-seg
+ c-tiempo2 / 100
move t-inicio to c-tiempo1
divide c-tiempo1 by 1000000 giving c-hor remainder
c-tiempo2
divide c-tiempo2 by 10000 giving c-min remainder
c-tiempo1
divide c-tiempo1 by 100 giving c-seg remainder
c-tiempo2
compute ct-ent = c-hor * 3600 + c-min * 60 + c-seg
compute c-tiempo = ct-sal - ct-ent
+ c-tiempo2 / 100
compute numero rounded = registros / c-tiempo.
procesar-fichero.
initialize i-registros
perform test after until i-registros > registros
add 1 to i-registros
move i-registros to clave-t
write reg-f-tmp end-write
end-perform.
procesar-fichero1.
initialize clave-t
start f-tmp key is > clave-t
read f-tmp next record end-read
perform test after until fin-tmp
read f-tmp next record end-read
end-perform.
procesar-ficherox.
initialize i-registros
perform test after until i-registros > registros
add 1 to i-registros
move i-registros to clave-tx
compute clave-t1x = clave-tx / 13
compute clave-t2x = clave-tx ** 13
ACCEPT CLAVE-T3x FROM TIME
ACCEPT CLAVE-T4x FROM DATE
write reg-f-tmpx end-write
end-perform.
procesar-fichero1x.
initialize clave-tx
start f-tmpx key is > clave-tx
read f-tmpx next record end-read
perform test after until fin-tmpx
read f-tmpx next record end-read
end-perform.
acept-key.
accept x line 24 position 80 off no beep
on exception tecla continue.
fastidiar.
display ' ' line 24 position 77 beep.
acept-keyx.
accept x line 24 position 80 off tab
on exception tecla continue.
borrar-linea24.
display ' ' line 24 position 1 erase eol.
mensaje.
display mensaje line 24 position 1 erase eol
perform acept-key.
perform borrar-linea24.
mensajex.
display mensaje line 24 position 1 erase eol
perform acept-keyx.
perform borrar-linea24.
********************************************
* subrutinas de acceso a ficheros.
********************************************
abrir-ficheros.
abre-tmp.
* ACCEPT nombre-f-tmp LINE 23 UPDATE.
open output f-tmp.
if not esta-tmp then
go abre-tmp
else
close f-tmp
open i-o f-tmp
end-if.
fin-abrir-ficheros.
abrir-ficherosx.
abre-tmpx.
* ACCEPT nombre-f-tmp LINE 23 UPDATE.
open output f-tmpx.
if not esta-tmpx then
go abre-tmpx
else
close f-tmpx
open i-o f-tmpx
end-if.
fin-abrir-ficherosx.
ver-error.
move ' ' to mensaje
if f-e = '35' then
string 'Fichero ' n-e ' no existe. Pulse tecla...'
delimited by size into mensaje
perform mensaje
****** para hacer pruebas quito el "go"
****** go fin-p
end-if.
if f-e = '38' or = '93' then
string 'Fichero ' n-e ' bloqueado. Pulse tecla...'
delimited by size into mensaje
perform mensaje
go fin-p
end-if.
if f-e = '98' then
string 'Fichero ' n-e ' deteriorado. Pulse tecla...'
delimited by size into mensaje
perform mensaje
go fin-p
end-if.
if f-e not = '00' then
string 'Error ' f-e ' en el fichero ' n-e
' .Pulse tecla...'
delimited by size into mensaje
perform mensaje
go fin-p
end-if.