comp.lang.ada
 help / color / mirror / Atom feed
* Re: Here my package
       [not found] <0rGy6.262$A24.137061@carnaval.risq.qc.ca>
@ 2001-04-04 14:46 ` Ted Dennison
  2001-04-04 14:56   ` Mich
  0 siblings, 1 reply; 10+ messages in thread
From: Ted Dennison @ 2001-04-04 14:46 UTC (permalink / raw)


In article <0rGy6.262$A24.137061@carnaval.risq.qc.ca>, Mich says...
>
>i want to know how to create a procedure named Date_Valide with the three
>functions in my package.

Could you at try reposting it as plain text, rather than an attachement? My
newsreader doesn't decode binary attachements.

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
          home email - mailto:dennison@telepath.com



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Here my package
  2001-04-04 14:46 ` Here my package Ted Dennison
@ 2001-04-04 14:56   ` Mich
  2001-04-04 15:29     ` Marin David Condic
                       ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Mich @ 2001-04-04 14:56 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3387 bytes --]

ok here my package and i need to create a procedure named Date_Valide
but i don't know how.   my package goes like that:

PACKAGE lesdates IS
              TYPE Date IS RECORD
                 Jour : Natural;
                 Mois : Natural;
                 Ann�e : Natural;
               END RECORD;
FUNCTION Bissextile(Ann�e : IN Natural) RETURN Boolean ;
FUNCTION Jour_Max(Mois, Annee: IN Natural) RETURN Natural ;
FUNCTION Jour_De(La_Date : IN Date)RETURN Natural ;
FUNCTION Prem_Jour(An : IN Natural) RETURN Natural ;
END lesdates;

ans my package body here:

PACKAGE BODY lesdates IS
--PROCEDURE Date_Valide IS
FUNCTION Bissextile(Ann�e : IN Natural) RETURN Boolean IS
  BEGIN -- Bissextile
    IF (Ann�e REM 100) = 0 THEN
    -- un si�cle est bissextile s'il est divisible par 4
       RETURN (Ann�e REM 400) = 0;
    ELSE
    -- une ann�e ordinaire est bissextile si elle est divisible par 4
       RETURN (Ann�e REM 4) = 0;
    END IF;
  END Bissextile;

  FUNCTION Jour_Max(Mois, Annee: IN Natural) RETURN Natural IS
  -- retourne le nombre de jours maximum dans un mois
  -- Gabrini p. 131
  BEGIN -- Jour_Max
    CASE Mois IS
      WHEN 1 | 3 | 5 | 7 | 8 | 10 | 12 => RETURN 31;
      WHEN 4 | 6 | 9 | 11 => RETURN 30;
      WHEN 2 => IF Bissextile (Annee) THEN
                   RETURN 29;
                ELSE
                   RETURN 28; -- merci Auguste Cesar
                END IF;
      WHEN OTHERS => RETURN 0;
    END CASE;
  END Jour_Max;

FUNCTION Prem_Jour(An : IN Natural) RETURN Natural IS
    -- Retourne le premier jour de l'ann�e (dim = 0, ... , sam = 6)
    -- Valide en France � partir de 1583, en Angleterre � partir de 1752,
    --        en Russie � partir de 1918, en Gr�ce � partir de 1923
    -- Ant�c�dent : An est une ann�e valide
    -- Cons�quent : Prem_Jour est le premier jour de l'ann�e

      Somme : Natural;
    BEGIN -- Prem_Jour
      Somme := An + ((An - 1) / 4) - ((An - 1) / 100) + ((An - 1) / 400);
      RETURN Somme REM 7;
    END Prem_Jour;

  FUNCTION Jour_De(La_Date : IN Date)RETURN Natural IS
  -- Retourne le jour de semaine de la date (Jour, Mois, An)
  -- Ant�c�dent : la date est une date valide du calendrier gr�gorien
  -- Cons�quent : Jour_De est le jour de la semaine de la date
  --              dim = 0, ... , sam = 6
    Jour_Preced : ARRAY (1..12) OF Natural :=
                   (0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334);
    Somme : Natural;

  BEGIN -- Jour_De

    Somme := Prem_Jour(La_Date.Ann�e) + Jour_Preced(La_Date.Mois)
             + (La_date.Jour - 1);
    -- correction pour les ann�es bissextiles
    IF Bissextile(La_Date.Ann�e) AND (La_Date.Mois > 2) THEN
       Somme := Somme +1;
    END IF;
    RETURN Somme  REM 7;
  END Jour_De;
--END Date_Valide;
END lesdates;

"Ted Dennison" <dennison@telepath.com> a �crit dans le message news:
JsGy6.1512$jz.128569@www.newsranger.com...
> In article <0rGy6.262$A24.137061@carnaval.risq.qc.ca>, Mich says...
> >
> >i want to know how to create a procedure named Date_Valide with the three
> >functions in my package.
>
> Could you at try reposting it as plain text, rather than an attachement?
My
> newsreader doesn't decode binary attachements.
>
> ---
> T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
>           home email - mailto:dennison@telepath.com





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Here my package
  2001-04-04 14:56   ` Mich
@ 2001-04-04 15:29     ` Marin David Condic
  2001-04-04 15:57       ` Mich
  2001-04-04 16:40     ` Jeffrey Carter
  2001-04-05  4:20     ` DuckE
  2 siblings, 1 reply; 10+ messages in thread
From: Marin David Condic @ 2001-04-04 15:29 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 4341 bytes --]

Now you're getting somewhere. What is it you don't know how to do?

To use the package in your procedure, you simply need to bring it in with a
context clause. Try this:

with LesDates ;
use LesDates ;
procedure Date_Valide is
begin
    -- Your code here. You can call all your package
    --  functions by name here as if they were declared
    --  locally.
end Date_Valide ;

If you need something else, you'll have to explain what it is you need in
more detail.

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com
Web:      http://www.mcondic.com/

"Mich" <katho@tr.cgocable.ca> wrote in message
news:hCGy6.263$A24.139307@carnaval.risq.qc.ca...
> ok here my package and i need to create a procedure named Date_Valide
> but i don't know how.   my package goes like that:
>
> PACKAGE lesdates IS
>               TYPE Date IS RECORD
>                  Jour : Natural;
>                  Mois : Natural;
>                  Ann�e : Natural;
>                END RECORD;
> FUNCTION Bissextile(Ann�e : IN Natural) RETURN Boolean ;
> FUNCTION Jour_Max(Mois, Annee: IN Natural) RETURN Natural ;
> FUNCTION Jour_De(La_Date : IN Date)RETURN Natural ;
> FUNCTION Prem_Jour(An : IN Natural) RETURN Natural ;
> END lesdates;
>
> ans my package body here:
>
> PACKAGE BODY lesdates IS
> --PROCEDURE Date_Valide IS
> FUNCTION Bissextile(Ann�e : IN Natural) RETURN Boolean IS
>   BEGIN -- Bissextile
>     IF (Ann�e REM 100) = 0 THEN
>     -- un si�cle est bissextile s'il est divisible par 4
>        RETURN (Ann�e REM 400) = 0;
>     ELSE
>     -- une ann�e ordinaire est bissextile si elle est divisible par 4
>        RETURN (Ann�e REM 4) = 0;
>     END IF;
>   END Bissextile;
>
>   FUNCTION Jour_Max(Mois, Annee: IN Natural) RETURN Natural IS
>   -- retourne le nombre de jours maximum dans un mois
>   -- Gabrini p. 131
>   BEGIN -- Jour_Max
>     CASE Mois IS
>       WHEN 1 | 3 | 5 | 7 | 8 | 10 | 12 => RETURN 31;
>       WHEN 4 | 6 | 9 | 11 => RETURN 30;
>       WHEN 2 => IF Bissextile (Annee) THEN
>                    RETURN 29;
>                 ELSE
>                    RETURN 28; -- merci Auguste Cesar
>                 END IF;
>       WHEN OTHERS => RETURN 0;
>     END CASE;
>   END Jour_Max;
>
> FUNCTION Prem_Jour(An : IN Natural) RETURN Natural IS
>     -- Retourne le premier jour de l'ann�e (dim = 0, ... , sam = 6)
>     -- Valide en France � partir de 1583, en Angleterre � partir de 1752,
>     --        en Russie � partir de 1918, en Gr�ce � partir de 1923
>     -- Ant�c�dent : An est une ann�e valide
>     -- Cons�quent : Prem_Jour est le premier jour de l'ann�e
>
>       Somme : Natural;
>     BEGIN -- Prem_Jour
>       Somme := An + ((An - 1) / 4) - ((An - 1) / 100) + ((An - 1) / 400);
>       RETURN Somme REM 7;
>     END Prem_Jour;
>
>   FUNCTION Jour_De(La_Date : IN Date)RETURN Natural IS
>   -- Retourne le jour de semaine de la date (Jour, Mois, An)
>   -- Ant�c�dent : la date est une date valide du calendrier gr�gorien
>   -- Cons�quent : Jour_De est le jour de la semaine de la date
>   --              dim = 0, ... , sam = 6
>     Jour_Preced : ARRAY (1..12) OF Natural :=
>                    (0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304,
334);
>     Somme : Natural;
>
>   BEGIN -- Jour_De
>
>     Somme := Prem_Jour(La_Date.Ann�e) + Jour_Preced(La_Date.Mois)
>              + (La_date.Jour - 1);
>     -- correction pour les ann�es bissextiles
>     IF Bissextile(La_Date.Ann�e) AND (La_Date.Mois > 2) THEN
>        Somme := Somme +1;
>     END IF;
>     RETURN Somme  REM 7;
>   END Jour_De;
> --END Date_Valide;
> END lesdates;
>
> "Ted Dennison" <dennison@telepath.com> a �crit dans le message news:
> JsGy6.1512$jz.128569@www.newsranger.com...
> > In article <0rGy6.262$A24.137061@carnaval.risq.qc.ca>, Mich says...
> > >
> > >i want to know how to create a procedure named Date_Valide with the
three
> > >functions in my package.
> >
> > Could you at try reposting it as plain text, rather than an attachement?
> My
> > newsreader doesn't decode binary attachements.
> >
> > ---
> > T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
> >           home email - mailto:dennison@telepath.com
>
>





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Here my package
  2001-04-04 15:29     ` Marin David Condic
@ 2001-04-04 15:57       ` Mich
  2001-04-04 16:15         ` Marin David Condic
  0 siblings, 1 reply; 10+ messages in thread
From: Mich @ 2001-04-04 15:57 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 4820 bytes --]

the procedure need to be in the package 'cause in my principal program i
will call the Date_Valide



"Marin David Condic" <marin.condic.auntie.spam@pacemicro.com> a �crit dans
le message news: 9afek0$cnp$1@nh.pace.co.uk...
> Now you're getting somewhere. What is it you don't know how to do?
>
> To use the package in your procedure, you simply need to bring it in with
a
> context clause. Try this:
>
> with LesDates ;
> use LesDates ;
> procedure Date_Valide is
> begin
>     -- Your code here. You can call all your package
>     --  functions by name here as if they were declared
>     --  locally.
> end Date_Valide ;
>
> If you need something else, you'll have to explain what it is you need in
> more detail.
>
> MDC
> --
> Marin David Condic
> Senior Software Engineer
> Pace Micro Technology Americas    www.pacemicro.com
> Enabling the digital revolution
> e-Mail:    marin.condic@pacemicro.com
> Web:      http://www.mcondic.com/
>
> "Mich" <katho@tr.cgocable.ca> wrote in message
> news:hCGy6.263$A24.139307@carnaval.risq.qc.ca...
> > ok here my package and i need to create a procedure named Date_Valide
> > but i don't know how.   my package goes like that:
> >
> > PACKAGE lesdates IS
> >               TYPE Date IS RECORD
> >                  Jour : Natural;
> >                  Mois : Natural;
> >                  Ann�e : Natural;
> >                END RECORD;
> > FUNCTION Bissextile(Ann�e : IN Natural) RETURN Boolean ;
> > FUNCTION Jour_Max(Mois, Annee: IN Natural) RETURN Natural ;
> > FUNCTION Jour_De(La_Date : IN Date)RETURN Natural ;
> > FUNCTION Prem_Jour(An : IN Natural) RETURN Natural ;
> > END lesdates;
> >
> > ans my package body here:
> >
> > PACKAGE BODY lesdates IS
> > --PROCEDURE Date_Valide IS
> > FUNCTION Bissextile(Ann�e : IN Natural) RETURN Boolean IS
> >   BEGIN -- Bissextile
> >     IF (Ann�e REM 100) = 0 THEN
> >     -- un si�cle est bissextile s'il est divisible par 4
> >        RETURN (Ann�e REM 400) = 0;
> >     ELSE
> >     -- une ann�e ordinaire est bissextile si elle est divisible par 4
> >        RETURN (Ann�e REM 4) = 0;
> >     END IF;
> >   END Bissextile;
> >
> >   FUNCTION Jour_Max(Mois, Annee: IN Natural) RETURN Natural IS
> >   -- retourne le nombre de jours maximum dans un mois
> >   -- Gabrini p. 131
> >   BEGIN -- Jour_Max
> >     CASE Mois IS
> >       WHEN 1 | 3 | 5 | 7 | 8 | 10 | 12 => RETURN 31;
> >       WHEN 4 | 6 | 9 | 11 => RETURN 30;
> >       WHEN 2 => IF Bissextile (Annee) THEN
> >                    RETURN 29;
> >                 ELSE
> >                    RETURN 28; -- merci Auguste Cesar
> >                 END IF;
> >       WHEN OTHERS => RETURN 0;
> >     END CASE;
> >   END Jour_Max;
> >
> > FUNCTION Prem_Jour(An : IN Natural) RETURN Natural IS
> >     -- Retourne le premier jour de l'ann�e (dim = 0, ... , sam = 6)
> >     -- Valide en France � partir de 1583, en Angleterre � partir de
1752,
> >     --        en Russie � partir de 1918, en Gr�ce � partir de 1923
> >     -- Ant�c�dent : An est une ann�e valide
> >     -- Cons�quent : Prem_Jour est le premier jour de l'ann�e
> >
> >       Somme : Natural;
> >     BEGIN -- Prem_Jour
> >       Somme := An + ((An - 1) / 4) - ((An - 1) / 100) + ((An - 1) /
400);
> >       RETURN Somme REM 7;
> >     END Prem_Jour;
> >
> >   FUNCTION Jour_De(La_Date : IN Date)RETURN Natural IS
> >   -- Retourne le jour de semaine de la date (Jour, Mois, An)
> >   -- Ant�c�dent : la date est une date valide du calendrier gr�gorien
> >   -- Cons�quent : Jour_De est le jour de la semaine de la date
> >   --              dim = 0, ... , sam = 6
> >     Jour_Preced : ARRAY (1..12) OF Natural :=
> >                    (0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304,
> 334);
> >     Somme : Natural;
> >
> >   BEGIN -- Jour_De
> >
> >     Somme := Prem_Jour(La_Date.Ann�e) + Jour_Preced(La_Date.Mois)
> >              + (La_date.Jour - 1);
> >     -- correction pour les ann�es bissextiles
> >     IF Bissextile(La_Date.Ann�e) AND (La_Date.Mois > 2) THEN
> >        Somme := Somme +1;
> >     END IF;
> >     RETURN Somme  REM 7;
> >   END Jour_De;
> > --END Date_Valide;
> > END lesdates;
> >
> > "Ted Dennison" <dennison@telepath.com> a �crit dans le message news:
> > JsGy6.1512$jz.128569@www.newsranger.com...
> > > In article <0rGy6.262$A24.137061@carnaval.risq.qc.ca>, Mich says...
> > > >
> > > >i want to know how to create a procedure named Date_Valide with the
> three
> > > >functions in my package.
> > >
> > > Could you at try reposting it as plain text, rather than an
attachement?
> > My
> > > newsreader doesn't decode binary attachements.
> > >
> > > ---
> > > T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
> > >           home email - mailto:dennison@telepath.com
> >
> >
>
>





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Here my package
  2001-04-04 15:57       ` Mich
@ 2001-04-04 16:15         ` Marin David Condic
  0 siblings, 0 replies; 10+ messages in thread
From: Marin David Condic @ 2001-04-04 16:15 UTC (permalink / raw)


As long as Date_Valide is a library level procedure, it can be brought into
your main program with a context clause just like I did with LesDates.

If you want to *add* Date_Valide to the package LesDates - then you've got
two ways to go. One is just to add it in like all the other functions - just
cut and paste and change the names as appropriate. The other is to extend
LesDates with a child package to include all of the procedures you like:

package LesDates.My_Stuff is
...
end LesDates.My_Stuff ;

Which you use is up to you and what it is your assignment is supposed to be
illustrating.

This sort of thing ought to be in your textbook with plenty of examples.
Look through your text to see how to declare a procedure within a package or
a child package.

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com
Web:      http://www.mcondic.com/


"Mich" <katho@tr.cgocable.ca> wrote in message
news:UvHy6.320$A24.146429@carnaval.risq.qc.ca...
> the procedure need to be in the package 'cause in my principal program i
> will call the Date_Valide
>






^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Here my package
  2001-04-04 14:56   ` Mich
  2001-04-04 15:29     ` Marin David Condic
@ 2001-04-04 16:40     ` Jeffrey Carter
  2001-04-04 17:06       ` Mich
  2001-04-05  4:20     ` DuckE
  2 siblings, 1 reply; 10+ messages in thread
From: Jeffrey Carter @ 2001-04-04 16:40 UTC (permalink / raw)


Mich wrote:
> 
> ok here my package and i need to create a procedure named Date_Valide
> but i don't know how.   my package goes like that:

Actually, it looks as if you know how to create a function. Procedures
are similar, but don't return a value:

procedure Date_Valide is
   -- null;
begin -- Date_Valide
   null;
end Date_Valide;

If I knew the requirements for procedure Date_Valide I could perhaps be
more helpful.

> PACKAGE lesdates IS
>               TYPE Date IS RECORD
>                  Jour : Natural;
>                  Mois : Natural;
>                  Ann�e : Natural;
>                END RECORD;

So, what does zero mean as a year? A number not in 1 .. 12 for a month?
A number not in 1 .. 31 for a day? You should take a look at
Ada.Calendar, and perhaps use some of the subtypes defined there:

type Date is record
   Ann�e : Positive;
   Mois  : Ada.Calendar.Month_Number;
   Jour  : Ada.Calendar.Day_Number;
end record;

This would make validating dates much easier.

Jeffrey Carter



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Here my package
  2001-04-04 16:40     ` Jeffrey Carter
@ 2001-04-04 17:06       ` Mich
  2001-04-04 18:41         ` Stephen Leake
  2001-04-04 22:06         ` Jeffrey Carter
  0 siblings, 2 replies; 10+ messages in thread
From: Mich @ 2001-04-04 17:06 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1413 bytes --]

The requirement is with the function that i already got is to put everything
in my procedure but i don't know how : that my real problem...i work on that
for about 3 days and i don't know how to... if you could help tahnx

"Jeffrey Carter" <jeffrey.carter@boeing.com> a �crit dans le message news:
3ACB4E79.6A461BC3@boeing.com...
> Mich wrote:
> >
> > ok here my package and i need to create a procedure named Date_Valide
> > but i don't know how.   my package goes like that:
>
> Actually, it looks as if you know how to create a function. Procedures
> are similar, but don't return a value:
>
> procedure Date_Valide is
>    -- null;
> begin -- Date_Valide
>    null;
> end Date_Valide;
>
> If I knew the requirements for procedure Date_Valide I could perhaps be
> more helpful.
>
> > PACKAGE lesdates IS
> >               TYPE Date IS RECORD
> >                  Jour : Natural;
> >                  Mois : Natural;
> >                  Ann�e : Natural;
> >                END RECORD;
>
> So, what does zero mean as a year? A number not in 1 .. 12 for a month?
> A number not in 1 .. 31 for a day? You should take a look at
> Ada.Calendar, and perhaps use some of the subtypes defined there:
>
> type Date is record
>    Ann�e : Positive;
>    Mois  : Ada.Calendar.Month_Number;
>    Jour  : Ada.Calendar.Day_Number;
> end record;
>
> This would make validating dates much easier.
>
> Jeffrey Carter





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Here my package
  2001-04-04 17:06       ` Mich
@ 2001-04-04 18:41         ` Stephen Leake
  2001-04-04 22:06         ` Jeffrey Carter
  1 sibling, 0 replies; 10+ messages in thread
From: Stephen Leake @ 2001-04-04 18:41 UTC (permalink / raw)


"Mich" <katho@tr.cgocable.ca> writes:

> The requirement is with the function that i already got is to put everything
> in my procedure but i don't know how : that my real problem...i work on that
> for about 3 days and i don't know how to... if you could help tahnx

I'm not sure I'm following you, but I think you are saying you need a
main procedure Date_Valide that contains the package lesdates. No
problem:

procedure Date_Valide is

    package lesdates is
        type date is record
        ...
    end lesdates;

begin -- Date_Valide

    stuff that uses functions in lesdates

end Date_Valide;

In Ada, you can nest package declarations in the declaration part of a
procedure.

You can also just declare everything in package lesdates directly in
the declaration part of the procedure Date_Valide; you don't need a
package.

-- 
-- Stephe



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Here my package
  2001-04-04 17:06       ` Mich
  2001-04-04 18:41         ` Stephen Leake
@ 2001-04-04 22:06         ` Jeffrey Carter
  1 sibling, 0 replies; 10+ messages in thread
From: Jeffrey Carter @ 2001-04-04 22:06 UTC (permalink / raw)


Mich wrote:
> 
> The requirement is with the function that i already got is to put everything
> in my procedure but i don't know how : that my real problem...i work on that
> for about 3 days and i don't know how to... if you could help tahnx

I'm sorry, but this doesn't tell me anything. I don't know if it's a
language problem or because you don't know what the requirements are,
either. Maybe some of both.

Jeffrey Carter



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Here my package
  2001-04-04 14:56   ` Mich
  2001-04-04 15:29     ` Marin David Condic
  2001-04-04 16:40     ` Jeffrey Carter
@ 2001-04-05  4:20     ` DuckE
  2 siblings, 0 replies; 10+ messages in thread
From: DuckE @ 2001-04-05  4:20 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 4196 bytes --]

To be able to assist you, we really need to know what you would like to pass
into the procedure, what you expect the procedure to do, and what you expect
as output from the procedure.

Perhaps you wish to determine whether the record is valid?

If that's the case, you'll need to make the changes described below:

"Mich" <katho@tr.cgocable.ca> wrote in message
news:hCGy6.263$A24.139307@carnaval.risq.qc.ca...
> ok here my package and i need to create a procedure named Date_Valide
> but i don't know how.   my package goes like that:
>
> PACKAGE lesdates IS
>               TYPE Date IS RECORD
>                  Jour : Natural;
>                  Mois : Natural;
>                  Ann�e : Natural;
>                END RECORD;
> FUNCTION Bissextile(Ann�e : IN Natural) RETURN Boolean ;
> FUNCTION Jour_Max(Mois, Annee: IN Natural) RETURN Natural ;
> FUNCTION Jour_De(La_Date : IN Date)RETURN Natural ;
> FUNCTION Prem_Jour(An : IN Natural) RETURN Natural ;
PROCEDURE Date_Valide( La_Date : IN Date;  Is_Valid : OUT Boolean );
> END lesdates;
>
> ans my package body here:
>
> PACKAGE BODY lesdates IS
PROCEDURE Date_Valide( La_Date : IN Date;  Is_Valid : OUT Boolean ) IS
BEGIN
  -- Add code here that uses L_Date as input and assigns the result to
Is_Valid
END Date_Valide;
> FUNCTION Bissextile(Ann�e : IN Natural) RETURN Boolean IS
>   BEGIN -- Bissextile
>     IF (Ann�e REM 100) = 0 THEN
>     -- un si�cle est bissextile s'il est divisible par 4
>        RETURN (Ann�e REM 400) = 0;
>     ELSE
>     -- une ann�e ordinaire est bissextile si elle est divisible par 4
>        RETURN (Ann�e REM 4) = 0;
>     END IF;
>   END Bissextile;
>
>   FUNCTION Jour_Max(Mois, Annee: IN Natural) RETURN Natural IS
>   -- retourne le nombre de jours maximum dans un mois
>   -- Gabrini p. 131
>   BEGIN -- Jour_Max
>     CASE Mois IS
>       WHEN 1 | 3 | 5 | 7 | 8 | 10 | 12 => RETURN 31;
>       WHEN 4 | 6 | 9 | 11 => RETURN 30;
>       WHEN 2 => IF Bissextile (Annee) THEN
>                    RETURN 29;
>                 ELSE
>                    RETURN 28; -- merci Auguste Cesar
>                 END IF;
>       WHEN OTHERS => RETURN 0;
>     END CASE;
>   END Jour_Max;
>
> FUNCTION Prem_Jour(An : IN Natural) RETURN Natural IS
>     -- Retourne le premier jour de l'ann�e (dim = 0, ... , sam = 6)
>     -- Valide en France � partir de 1583, en Angleterre � partir de 1752,
>     --        en Russie � partir de 1918, en Gr�ce � partir de 1923
>     -- Ant�c�dent : An est une ann�e valide
>     -- Cons�quent : Prem_Jour est le premier jour de l'ann�e
>
>       Somme : Natural;
>     BEGIN -- Prem_Jour
>       Somme := An + ((An - 1) / 4) - ((An - 1) / 100) + ((An - 1) / 400);
>       RETURN Somme REM 7;
>     END Prem_Jour;
>
>   FUNCTION Jour_De(La_Date : IN Date)RETURN Natural IS
>   -- Retourne le jour de semaine de la date (Jour, Mois, An)
>   -- Ant�c�dent : la date est une date valide du calendrier gr�gorien
>   -- Cons�quent : Jour_De est le jour de la semaine de la date
>   --              dim = 0, ... , sam = 6
>     Jour_Preced : ARRAY (1..12) OF Natural :=
>                    (0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304,
334);
>     Somme : Natural;
>
>   BEGIN -- Jour_De
>
>     Somme := Prem_Jour(La_Date.Ann�e) + Jour_Preced(La_Date.Mois)
>              + (La_date.Jour - 1);
>     -- correction pour les ann�es bissextiles
>     IF Bissextile(La_Date.Ann�e) AND (La_Date.Mois > 2) THEN
>        Somme := Somme +1;
>     END IF;
>     RETURN Somme  REM 7;
>   END Jour_De;
> --END Date_Valide;
> END lesdates;
>
> "Ted Dennison" <dennison@telepath.com> a �crit dans le message news:
> JsGy6.1512$jz.128569@www.newsranger.com...
> > In article <0rGy6.262$A24.137061@carnaval.risq.qc.ca>, Mich says...
> > >
> > >i want to know how to create a procedure named Date_Valide with the
three
> > >functions in my package.
> >
> > Could you at try reposting it as plain text, rather than an attachement?
> My
> > newsreader doesn't decode binary attachements.
> >
> > ---
> > T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
> >           home email - mailto:dennison@telepath.com
>
>





^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2001-04-05  4:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <0rGy6.262$A24.137061@carnaval.risq.qc.ca>
2001-04-04 14:46 ` Here my package Ted Dennison
2001-04-04 14:56   ` Mich
2001-04-04 15:29     ` Marin David Condic
2001-04-04 15:57       ` Mich
2001-04-04 16:15         ` Marin David Condic
2001-04-04 16:40     ` Jeffrey Carter
2001-04-04 17:06       ` Mich
2001-04-04 18:41         ` Stephen Leake
2001-04-04 22:06         ` Jeffrey Carter
2001-04-05  4:20     ` DuckE

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox