115 lines
3.7 KiB
Plaintext
115 lines
3.7 KiB
Plaintext
|
IDENTIFICATION DIVISION.
|
|||
|
PROGRAM-ID. insee.
|
|||
|
AUTHOR. OD.
|
|||
|
*---------------------------------------------------------------*
|
|||
|
* PROGRAMME *
|
|||
|
* CONTROLE VALIDITE NUMERO INSEE *
|
|||
|
*---------------------------------------------------------------*
|
|||
|
|
|||
|
ENVIRONMENT DIVISION.
|
|||
|
DATA DIVISION.
|
|||
|
|
|||
|
WORKING-STORAGE SECTION.
|
|||
|
*--------------------------*
|
|||
|
* DEFINITION DES VARIABLES *
|
|||
|
*--------------------------*
|
|||
|
|
|||
|
01 CD-INSEE.
|
|||
|
* Code Homme/Femme, 1 = homme, 2 = femme
|
|||
|
05 CD-SX PICTURE 9 VALUE ZERO.
|
|||
|
* Code ann<6E>e de naissance
|
|||
|
05 CD-NSSNC PICTURE 99 VALUE ZERO.
|
|||
|
* Code mois de naissance
|
|||
|
05 CD-MS-NSSNC PICTURE 99 VALUE ZERO.
|
|||
|
* Code d<>partement
|
|||
|
* Enlever les d<>partements non existants, et 2A pour Corse,
|
|||
|
* ainsi que 2B
|
|||
|
05 CD-DPRTMNT PICTURE XX.
|
|||
|
* Code commune
|
|||
|
05 CD-CMMNE PICTURE 999 VALUE ZERO.
|
|||
|
* Code registre
|
|||
|
05 CD-RGSTR PICTURE 999 VALUE ZERO.
|
|||
|
* Cl<43> de contr<74>le
|
|||
|
05 CL-CTRL PICTURE 99 VALUE ZERO.
|
|||
|
|
|||
|
* ERREURS
|
|||
|
* Bool<6F>en permettant de dire s'il y a erreur ou pas
|
|||
|
* Initialis<69> <20> 0 pour l'instant
|
|||
|
01 ERR-BLN PICTURE 9 VALUE LOW-VALUE.
|
|||
|
* Nom erreur
|
|||
|
01 ERR-NM PICTURE X(20) VALUE SPACE.
|
|||
|
|
|||
|
PROCEDURE DIVISION.
|
|||
|
* Nom du programme, ici PROGRAMME
|
|||
|
PROGRAMME SECTION.
|
|||
|
|
|||
|
* Demande du num<75>ro
|
|||
|
DEBUT.
|
|||
|
DISPLAY "Tapez votre num<75>ro INSEE : " WITH NO ADVANCING.
|
|||
|
ACCEPT CD-INSEE.
|
|||
|
|
|||
|
* Affichage des valeurs entr<74>es
|
|||
|
AFFICHAGE.
|
|||
|
DISPLAY "Sexe : " CD-SX.
|
|||
|
DISPLAY "Ann<6E>e de naissance : " CD-NSSNC.
|
|||
|
DISPLAY "Mois de naissance : " CD-MS-NSSNC.
|
|||
|
DISPLAY "D<>partement de naissance : " CD-DPRTMNT.
|
|||
|
DISPLAY "Commune : " CD-CMMNE.
|
|||
|
DISPLAY "Code registre : " CD-RGSTR.
|
|||
|
DISPLAY "Cl<43> de contr<74>le : " CL-CTRL.
|
|||
|
* STOP RUN.
|
|||
|
|
|||
|
* Contr<74>les de validit<69>
|
|||
|
CONTROLE SECTION.
|
|||
|
|
|||
|
* Contr<74>le du sexe
|
|||
|
SEXE.
|
|||
|
IF NOT (CD-SX EQUAL TO 1 OR CD-SX EQUAL TO 2) THEN
|
|||
|
MOVE HIGH-VALUE TO ERR-BLN
|
|||
|
MOVE "sexe." TO ERR-NM.
|
|||
|
* Contr<74>le sur type code sexe
|
|||
|
SEXETYPE.
|
|||
|
IF CD-SX IS NOT NUMERIC THEN
|
|||
|
MOVE HIGH-VALUE TO ERR-BLN
|
|||
|
MOVE "sexe non num<75>rique." TO ERR-NM.
|
|||
|
|
|||
|
* Contr<74>le sur mois de naissance
|
|||
|
MOISNAISSANCE.
|
|||
|
IF (CD-MS-NSSNC EQUAL TO 0 OR CD-MS-NSSNC GREATER THAN 12)
|
|||
|
THEN
|
|||
|
MOVE HIGH-VALUE TO ERR-BLN
|
|||
|
MOVE "mois de naissance." TO ERR-NM.
|
|||
|
* Contr<74>le sur type code mois de naissance
|
|||
|
MOISNAISSANCETYPE.
|
|||
|
IF CD-MS-NSSNC IS NOT NUMERIC THEN
|
|||
|
MOVE HIGH-VALUE TO ERR-BLN
|
|||
|
MOVE "ann<6E>e de naissance non num<75>rique." TO ERR-NM.
|
|||
|
|
|||
|
* Contr<74>le sur d<>partement
|
|||
|
DEPARTEMENT.
|
|||
|
IF CD-DPRTMNT EQUAL TO "2A" THEN
|
|||
|
MOVE "19" TO CD-DPRTMNT
|
|||
|
IF CD-DPRTMNT EQUAL TO "2B" THEN
|
|||
|
MOVE "18" TO CD-DPRTMNT
|
|||
|
IF (CD-DPRTMNT EQUAL TO "96" OR CD-DPRTMNT EQUAL TO 0)
|
|||
|
THEN
|
|||
|
MOVE HIGH-VALUE TO ERR-BLN
|
|||
|
MOVE "mauvais d<>partement".
|
|||
|
* Contr<74>le sur type code d<>partement
|
|||
|
DEPARTEMENTTYPE.
|
|||
|
IF CD-DPRTMNT IS NOT NUMERIC THEN
|
|||
|
MOVE HIGH-VALUE TO ERR-BLN
|
|||
|
MOVE
|
|||
|
|
|||
|
|
|||
|
* Affichage du r<>sultat
|
|||
|
RESULTAT SECTION.
|
|||
|
|
|||
|
* Affichage de l'erreur
|
|||
|
ERREUR.
|
|||
|
IF ERR-BLN EQUAL TO HIGH-VALUE THEN
|
|||
|
DISPLAY "Erreur sur : " ERR-NM
|
|||
|
ELSE
|
|||
|
DISPLAY "Aucune erreur.".
|
|||
|
STOP RUN.
|