Format binaire

Ce programme présente l'échange de données au format binaire.

Le fichier source est ${UPS_HOME}/upsedi/demo/${UPS_LANGUAGE}/formatbinaire.upl.

Mode compilé

Commande de compilation

upscmp Source=formatbinaire.upl

Commande d'exécution

formatbinaire

Mode interprété

upssng Source=formatbinaire.upl

Fichier source

Source Composant "Exemple d'emploi de l'import/export" Version 4.0.0;

ImporterModule
/************/
Type Employe Defaut
/*****************/
Fin Type

Variable
/******/
Procedure CreerListeDEmployes()
/*****************************/
Variable
/******/
Debut
Pour I=0 JusquA 10 Faire Fin Pour
Fin Procedure

Procedure ListerEmployes()
/************************/
Variable
/******/
Debut
Pour E=LE.ParcoursAuDebut() JusquA LE.DernierElement() Faire Fin Pour
Fin Procedure

Fonction CritereEmploye(O : Nul Ou Objet) Retourner Booleen
/*********************************************************/
Variable
/******/
Debut
Si O==Nul Alors Fin Si
E=Employe(O);
Retourner E.Nom Comme "scott*";
Fin Fonction

Principal
/*******/
Variable
/******/
Debut
Ecran.Ecrire("Base de données");
Ecran.Ecrire("===============");
CreerListeDEmployes();
ListerEmployes();
Ecran.Ecrire("\n");

F=Fichier("/tmp/essai.dmp", EcritureBinaire);
E=EchangeBinaire(IFlux(F));
Pour E2=LE.ParcoursAuDebut() JusquA LE.DernierElement() Pas LE.Suivant() Faire Fin Pour
E=Nul;
F.Fermer();

Ecran.Ecrire("Importation complète");
Ecran.Ecrire("====================");
F=Fichier("/tmp/essai.dmp", LectureBinaire);
E=EchangeBinaire(IFlux(F));
LE=Nul;
PasFini=Vrai;
TantQue PasFini Faire Fin TantQue E=Nul;
F.Fermer();
ListerEmployes();
Ecran.Ecrire("\n");

Ecran.Ecrire("A partir du 20èm rang");
Ecran.Ecrire("=====================");
F=Fichier("/tmp/essai.dmp", LectureBinaire);
E=EchangeBinaire(IFlux(F));
E.FiltrerAPartirDe(20);
LE=Nul;
PasFini=Vrai;
TantQue PasFini Faire Fin TantQue
E=Nul;
F.Fermer();
ListerEmployes();
Ecran.Ecrire("\n");

Ecran.Ecrire("20 premiers rangs");
Ecran.Ecrire("=================");
F=Fichier("/tmp/essai.dmp", LectureBinaire);
E=EchangeBinaire(IFlux(F));
E.FiltrerJusquA(20);
LE=Nul;
PasFini=Vrai;
TantQue PasFini Faire Fin TantQue E=Nul;
F.Fermer();
ListerEmployes();
Ecran.Ecrire("\n");

Ecran.Ecrire("Entre 10 et 30èm rang");
Ecran.Ecrire("=====================");
F=Fichier("/tmp/essai.dmp", LectureBinaire);
E=EchangeBinaire(IFlux(F));
E.FiltrerEntre(10,30);
LE=Nul;
PasFini=Vrai;
TantQue PasFini Faire Fin TantQue
E=Nul;
F.Fermer();
ListerEmployes();
Ecran.Ecrire("\n");

Ecran.Ecrire("scott uniquement");
Ecran.Ecrire("================");
F=Fichier("/tmp/essai.dmp", LectureBinaire);
E=EchangeBinaire(IFlux(F));
E.FiltrerSelon(CritereEmploye);
LE=Nul;
PasFini=Vrai;
TantQue PasFini Faire Fin TantQue
E=Nul;
F.Fermer();
ListerEmployes();
Ecran.Ecrire("\n");
Fin Principal

Résultat de l'exécution

Base de données =============== scott0 7,724 1,000.0000 12/01/1980 00:00:00 allen0 7,832 2,000.0000 13/02/1981 00:00:00 smith0 7,948 1,400.0000 14/03/1982 00:00:00 king0 7,964 2,000.0000 15/04/1983 00:00:00 scott1 7,725 1,001.0000 12/01/1980 00:00:00 allen1 7,833 2,001.0000 13/02/1981 00:00:00 smith1 7,949 1,401.0000 14/03/1982 00:00:00 king1 7,965 2,001.0000 15/04/1983 00:00:00 scott2 7,726 1,002.0000 12/01/1980 00:00:00 allen2 7,834 2,002.0000 13/02/1981 00:00:00 smith2 7,950 1,402.0000 14/03/1982 00:00:00 king2 7,966 2,002.0000 15/04/1983 00:00:00 scott3 7,727 1,003.0000 12/01/1980 00:00:00 allen3 7,835 2,003.0000 13/02/1981 00:00:00 smith3 7,951 1,403.0000 14/03/1982 00:00:00 king3 7,967 2,003.0000 15/04/1983 00:00:00 scott4 7,728 1,004.0000 12/01/1980 00:00:00 allen4 7,836 2,004.0000 13/02/1981 00:00:00 smith4 7,952 1,404.0000 14/03/1982 00:00:00 king4 7,968 2,004.0000 15/04/1983 00:00:00 scott5 7,729 1,005.0000 12/01/1980 00:00:00 allen5 7,837 2,005.0000 13/02/1981 00:00:00 smith5 7,953 1,405.0000 14/03/1982 00:00:00 king5 7,969 2,005.0000 15/04/1983 00:00:00 scott6 7,730 1,006.0000 12/01/1980 00:00:00 allen6 7,838 2,006.0000 13/02/1981 00:00:00 smith6 7,954 1,406.0000 14/03/1982 00:00:00 king6 7,970 2,006.0000 15/04/1983 00:00:00 scott7 7,731 1,007.0000 12/01/1980 00:00:00 allen7 7,839 2,007.0000 13/02/1981 00:00:00 smith7 7,955 1,407.0000 14/03/1982 00:00:00 king7 7,971 2,007.0000 15/04/1983 00:00:00 scott8 7,732 1,008.0000 12/01/1980 00:00:00 allen8 7,840 2,008.0000 13/02/1981 00:00:00 smith8 7,956 1,408.0000 14/03/1982 00:00:00 king8 7,972 2,008.0000 15/04/1983 00:00:00 scott9 7,733 1,009.0000 12/01/1980 00:00:00 allen9 7,841 2,009.0000 13/02/1981 00:00:00 smith9 7,957 1,409.0000 14/03/1982 00:00:00 king9 7,973 2,009.0000 15/04/1983 00:00:00 scott10 7,734 1,010.0000 12/01/1980 00:00:00 allen10 7,842 2,010.0000 13/02/1981 00:00:00 smith10 7,958 1,410.0000 14/03/1982 00:00:00 king10 7,974 2,010.0000 15/04/1983 00:00:00 Importation complète ==================== scott0 7,724 1,000.0000 12/01/1980 00:00:00 allen0 7,832 2,000.0000 13/02/1981 00:00:00 smith0 7,948 1,400.0000 14/03/1982 00:00:00 king0 7,964 2,000.0000 15/04/1983 00:00:00 scott1 7,725 1,001.0000 12/01/1980 00:00:00 allen1 7,833 2,001.0000 13/02/1981 00:00:00 smith1 7,949 1,401.0000 14/03/1982 00:00:00 king1 7,965 2,001.0000 15/04/1983 00:00:00 scott2 7,726 1,002.0000 12/01/1980 00:00:00 allen2 7,834 2,002.0000 13/02/1981 00:00:00 smith2 7,950 1,402.0000 14/03/1982 00:00:00 king2 7,966 2,002.0000 15/04/1983 00:00:00 scott3 7,727 1,003.0000 12/01/1980 00:00:00 allen3 7,835 2,003.0000 13/02/1981 00:00:00 smith3 7,951 1,403.0000 14/03/1982 00:00:00 king3 7,967 2,003.0000 15/04/1983 00:00:00 scott4 7,728 1,004.0000 12/01/1980 00:00:00 allen4 7,836 2,004.0000 13/02/1981 00:00:00 smith4 7,952 1,404.0000 14/03/1982 00:00:00 king4 7,968 2,004.0000 15/04/1983 00:00:00 scott5 7,729 1,005.0000 12/01/1980 00:00:00 allen5 7,837 2,005.0000 13/02/1981 00:00:00 smith5 7,953 1,405.0000 14/03/1982 00:00:00 king5 7,969 2,005.0000 15/04/1983 00:00:00 scott6 7,730 1,006.0000 12/01/1980 00:00:00 allen6 7,838 2,006.0000 13/02/1981 00:00:00 smith6 7,954 1,406.0000 14/03/1982 00:00:00 king6 7,970 2,006.0000 15/04/1983 00:00:00 scott7 7,731 1,007.0000 12/01/1980 00:00:00 allen7 7,839 2,007.0000 13/02/1981 00:00:00 smith7 7,955 1,407.0000 14/03/1982 00:00:00 king7 7,971 2,007.0000 15/04/1983 00:00:00 scott8 7,732 1,008.0000 12/01/1980 00:00:00 allen8 7,840 2,008.0000 13/02/1981 00:00:00 smith8 7,956 1,408.0000 14/03/1982 00:00:00 king8 7,972 2,008.0000 15/04/1983 00:00:00 scott9 7,733 1,009.0000 12/01/1980 00:00:00 allen9 7,841 2,009.0000 13/02/1981 00:00:00 smith9 7,957 1,409.0000 14/03/1982 00:00:00 king9 7,973 2,009.0000 15/04/1983 00:00:00 scott10 7,734 1,010.0000 12/01/1980 00:00:00 allen10 7,842 2,010.0000 13/02/1981 00:00:00 smith10 7,958 1,410.0000 14/03/1982 00:00:00 king10 7,974 2,010.0000 15/04/1983 00:00:00 A partir du 20èm rang ===================== king4 7,968 2,004.0000 15/04/1983 00:00:00 scott5 7,729 1,005.0000 12/01/1980 00:00:00 allen5 7,837 2,005.0000 13/02/1981 00:00:00 smith5 7,953 1,405.0000 14/03/1982 00:00:00 king5 7,969 2,005.0000 15/04/1983 00:00:00 scott6 7,730 1,006.0000 12/01/1980 00:00:00 allen6 7,838 2,006.0000 13/02/1981 00:00:00 smith6 7,954 1,406.0000 14/03/1982 00:00:00 king6 7,970 2,006.0000 15/04/1983 00:00:00 scott7 7,731 1,007.0000 12/01/1980 00:00:00 allen7 7,839 2,007.0000 13/02/1981 00:00:00 smith7 7,955 1,407.0000 14/03/1982 00:00:00 king7 7,971 2,007.0000 15/04/1983 00:00:00 scott8 7,732 1,008.0000 12/01/1980 00:00:00 allen8 7,840 2,008.0000 13/02/1981 00:00:00 smith8 7,956 1,408.0000 14/03/1982 00:00:00 king8 7,972 2,008.0000 15/04/1983 00:00:00 scott9 7,733 1,009.0000 12/01/1980 00:00:00 allen9 7,841 2,009.0000 13/02/1981 00:00:00 smith9 7,957 1,409.0000 14/03/1982 00:00:00 king9 7,973 2,009.0000 15/04/1983 00:00:00 scott10 7,734 1,010.0000 12/01/1980 00:00:00 allen10 7,842 2,010.0000 13/02/1981 00:00:00 smith10 7,958 1,410.0000 14/03/1982 00:00:00 king10 7,974 2,010.0000 15/04/1983 00:00:00 20 premiers rangs ================= scott0 7,724 1,000.0000 12/01/1980 00:00:00 allen0 7,832 2,000.0000 13/02/1981 00:00:00 smith0 7,948 1,400.0000 14/03/1982 00:00:00 king0 7,964 2,000.0000 15/04/1983 00:00:00 scott1 7,725 1,001.0000 12/01/1980 00:00:00 allen1 7,833 2,001.0000 13/02/1981 00:00:00 smith1 7,949 1,401.0000 14/03/1982 00:00:00 king1 7,965 2,001.0000 15/04/1983 00:00:00 scott2 7,726 1,002.0000 12/01/1980 00:00:00 allen2 7,834 2,002.0000 13/02/1981 00:00:00 smith2 7,950 1,402.0000 14/03/1982 00:00:00 king2 7,966 2,002.0000 15/04/1983 00:00:00 scott3 7,727 1,003.0000 12/01/1980 00:00:00 allen3 7,835 2,003.0000 13/02/1981 00:00:00 smith3 7,951 1,403.0000 14/03/1982 00:00:00 king3 7,967 2,003.0000 15/04/1983 00:00:00 scott4 7,728 1,004.0000 12/01/1980 00:00:00 allen4 7,836 2,004.0000 13/02/1981 00:00:00 smith4 7,952 1,404.0000 14/03/1982 00:00:00 king4 7,968 2,004.0000 15/04/1983 00:00:00 Entre 10 et 30èm rang ===================== allen2 7,834 2,002.0000 13/02/1981 00:00:00 smith2 7,950 1,402.0000 14/03/1982 00:00:00 king2 7,966 2,002.0000 15/04/1983 00:00:00 scott3 7,727 1,003.0000 12/01/1980 00:00:00 allen3 7,835 2,003.0000 13/02/1981 00:00:00 smith3 7,951 1,403.0000 14/03/1982 00:00:00 king3 7,967 2,003.0000 15/04/1983 00:00:00 scott4 7,728 1,004.0000 12/01/1980 00:00:00 allen4 7,836 2,004.0000 13/02/1981 00:00:00 smith4 7,952 1,404.0000 14/03/1982 00:00:00 king4 7,968 2,004.0000 15/04/1983 00:00:00 scott5 7,729 1,005.0000 12/01/1980 00:00:00 allen5 7,837 2,005.0000 13/02/1981 00:00:00 smith5 7,953 1,405.0000 14/03/1982 00:00:00 king5 7,969 2,005.0000 15/04/1983 00:00:00 scott6 7,730 1,006.0000 12/01/1980 00:00:00 allen6 7,838 2,006.0000 13/02/1981 00:00:00 smith6 7,954 1,406.0000 14/03/1982 00:00:00 king6 7,970 2,006.0000 15/04/1983 00:00:00 scott7 7,731 1,007.0000 12/01/1980 00:00:00 allen7 7,839 2,007.0000 13/02/1981 00:00:00 scott uniquement ================ scott0 7,724 1,000.0000 12/01/1980 00:00:00 scott1 7,725 1,001.0000 12/01/1980 00:00:00 scott2 7,726 1,002.0000 12/01/1980 00:00:00 scott3 7,727 1,003.0000 12/01/1980 00:00:00 scott4 7,728 1,004.0000 12/01/1980 00:00:00 scott5 7,729 1,005.0000 12/01/1980 00:00:00 scott6 7,730 1,006.0000 12/01/1980 00:00:00 scott7 7,731 1,007.0000 12/01/1980 00:00:00 scott8 7,732 1,008.0000 12/01/1980 00:00:00 scott9 7,733 1,009.0000 12/01/1980 00:00:00 scott10 7,734 1,010.0000 12/01/1980 00:00:00