Up ! 5GL

Ce programme présente l'échange de données au format Up ! 5GL.

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

Mode compilé

Commande de compilation

upscmp Source=format5gl.upl

Commande d'exécution

format5gl

Mode interprété

upssng Source=format5gl.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.upd", EcritureTexte);
E=EchangeUps5GL(IFlux(F), Nul, Faux);
E.ImporterUnModule(Global, Vrai);
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.upd", LectureTexte);
E=EchangeUps5GL(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.upd", LectureTexte);
E=EchangeUps5GL(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.upd", LectureTexte);
E=EchangeUps5GL(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.upd", LectureTexte);
E=EchangeUps5GL(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.upd", LectureTexte);
E=EchangeUps5GL(IFlux(F));
E.FiltrerSelon(CritereEmploye);
LE=Nul;
PasFini=Vrai;
TantQue PasFini Faire Fin TantQue
E=Nul;
F.Fermer();
ListerEmployes();
Ecran.Ecrire("\n");
Fin Principal

Fichier de données

Echange "Exemple" Version 4.0.0 NePasOptimiserEchange;

ImporterModule
Echange
Debut
Employe("scott0", 7724, 1000.0, Date(12, 1, 1980, 0, 0, 0, 0));
Employe("allen0", 7832, 2000.0, Date(13, 2, 1981, 0, 0, 0, 0));
Employe("smith0", 7948, 1400.0, Date(14, 3, 1982, 0, 0, 0, 0));
Employe("king0", 7964, 2000.0, Date(15, 4, 1983, 0, 0, 0, 0));
Employe("scott1", 7725, 1001.0, Date(12, 1, 1980, 0, 0, 0, 0));
Employe("allen1", 7833, 2001.0, Date(13, 2, 1981, 0, 0, 0, 0));
Employe("smith1", 7949, 1401.0, Date(14, 3, 1982, 0, 0, 0, 0));
Employe("king1", 7965, 2001.0, Date(15, 4, 1983, 0, 0, 0, 0));
Employe("scott2", 7726, 1002.0, Date(12, 1, 1980, 0, 0, 0, 0));
Employe("allen2", 7834, 2002.0, Date(13, 2, 1981, 0, 0, 0, 0));
Employe("smith2", 7950, 1402.0, Date(14, 3, 1982, 0, 0, 0, 0));
Employe("king2", 7966, 2002.0, Date(15, 4, 1983, 0, 0, 0, 0));
Employe("scott3", 7727, 1003.0, Date(12, 1, 1980, 0, 0, 0, 0));
Employe("allen3", 7835, 2003.0, Date(13, 2, 1981, 0, 0, 0, 0));
Employe("smith3", 7951, 1403.0, Date(14, 3, 1982, 0, 0, 0, 0));
Employe("king3", 7967, 2003.0, Date(15, 4, 1983, 0, 0, 0, 0));
Employe("scott4", 7728, 1004.0, Date(12, 1, 1980, 0, 0, 0, 0));
Employe("allen4", 7836, 2004.0, Date(13, 2, 1981, 0, 0, 0, 0));
Employe("smith4", 7952, 1404.0, Date(14, 3, 1982, 0, 0, 0, 0));
Employe("king4", 7968, 2004.0, Date(15, 4, 1983, 0, 0, 0, 0));
Employe("scott5", 7729, 1005.0, Date(12, 1, 1980, 0, 0, 0, 0));
Employe("allen5", 7837, 2005.0, Date(13, 2, 1981, 0, 0, 0, 0));
Employe("smith5", 7953, 1405.0, Date(14, 3, 1982, 0, 0, 0, 0));
Employe("king5", 7969, 2005.0, Date(15, 4, 1983, 0, 0, 0, 0));
Employe("scott6", 7730, 1006.0, Date(12, 1, 1980, 0, 0, 0, 0));
Employe("allen6", 7838, 2006.0, Date(13, 2, 1981, 0, 0, 0, 0));
Employe("smith6", 7954, 1406.0, Date(14, 3, 1982, 0, 0, 0, 0));
Employe("king6", 7970, 2006.0, Date(15, 4, 1983, 0, 0, 0, 0));
Employe("scott7", 7731, 1007.0, Date(12, 1, 1980, 0, 0, 0, 0));
Employe("allen7", 7839, 2007.0, Date(13, 2, 1981, 0, 0, 0, 0));
Employe("smith7", 7955, 1407.0, Date(14, 3, 1982, 0, 0, 0, 0));
Employe("king7", 7971, 2007.0, Date(15, 4, 1983, 0, 0, 0, 0));
Employe("scott8", 7732, 1008.0, Date(12, 1, 1980, 0, 0, 0, 0));
Employe("allen8", 7840, 2008.0, Date(13, 2, 1981, 0, 0, 0, 0));
Employe("smith8", 7956, 1408.0, Date(14, 3, 1982, 0, 0, 0, 0));
Employe("king8", 7972, 2008.0, Date(15, 4, 1983, 0, 0, 0, 0));
Employe("scott9", 7733, 1009.0, Date(12, 1, 1980, 0, 0, 0, 0));
Employe("allen9", 7841, 2009.0, Date(13, 2, 1981, 0, 0, 0, 0));
Employe("smith9", 7957, 1409.0, Date(14, 3, 1982, 0, 0, 0, 0));
Employe("king9", 7973, 2009.0, Date(15, 4, 1983, 0, 0, 0, 0));
Employe("scott10", 7734, 1010.0, Date(12, 1, 1980, 0, 0, 0, 0));
Employe("allen10", 7842, 2010.0, Date(13, 2, 1981, 0, 0, 0, 0));
Employe("smith10", 7958, 1410.0, Date(14, 3, 1982, 0, 0, 0, 0));
Employe("king10", 7974, 2010.0, Date(15, 4, 1983, 0, 0, 0, 0));
Fin Echange

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