🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.pascal.misc
Article #80

Re: Output formatting Question

#80
From: CBFalconer
Date: Fri, 14 Dec 2001 19:07
34 lines
2421 bytes
Jeff Donovan wrote:
> 
> I am trying to update some code left by a previous programmer, and
> not knowing Pascal very well I am stuck. Can someone please tell
> me how to add leading zeros to a when outputting an integer. I am
> trying to create a hh:mm:ss time string form integer hours, minutes,
> and seconds variables.

  PROCEDURE write2digs(VAR f : text; n : integer)

     BEGIN
     n := abs(n);  /* just in case */
     IF (n < 10) THEN write(f, '0', n : 1)
     ELSE             write(f, n : 2);
     END;

  PROCEDURE writedate(VAR f : text; dd, mm, yy, field: integer);
  (* in ISO form yyyy-mm-dd with leading zeroes *)

    BEGIN
    IF field < 10 THEN field := 10;
    write(f, yy : field - 6, '-');
    write2digs(f, mm);
    write(f, '-');
    write2digs(f, dd);
    END;

Creation of a writetime should be obvious.

-- 
Chuck F (cbfalconer@yahoo.com) (cbfalconer@XXXXworldnet.att.net)
   Available for consulting/temporary embedded and systems.
   (Remove "XXXX" from reply address. yahoo works unmodified)
   mailto:uce@ftc.gov  (for spambots to harvest)
Technical Details
Message-ID: <3C1A4B5C.40DD76DE@yahoo.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!wn1feed!worldnet.att.net!135.173.83.71!wnfilter1!worldnet-localpost!bgtnsc06-news.ops.worldnet.att.net.POSTED!not-for-mail
References: <3C1A3235.5B88630E@marine.usf.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111659,4d112d056daac5d7
X-Google-Attributes: gid111659,public
X-Google-Thread: 10261c,4d112d056daac5d7
X-Google-Attributes: gid10261c,public
X-Google-Thread: 108ebd,4d112d056daac5d7
X-Google-Attributes: gid108ebd,public
X-Google-ArrivalTime: 2001-12-14 11:07:40 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!wn1feed!worldnet.att.net!135.173.83.71!wnfilter1!worldnet-localpost!bgtnsc06-news.ops.worldnet.att.net.POSTED!not-for-mail
Message-ID: <3C1A4B5C.40DD76DE@yahoo.com>
From: CBFalconer <cbfalconer@yahoo.com>
Reply-To: cbfalconer@worldnet.att.net
Organization: Ched Research
X-Mailer: Mozilla 4.75 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.lang.pascal.misc,borland.public.turbopascal,comp.lang.pascal.borland
Subject: Re: Output formatting Question
References: <3C1A3235.5B88630E@marine.usf.edu>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 35
Date: Fri, 14 Dec 2001 19:07:39 GMT
NNTP-Posting-Host: 12.90.170.202
X-Complaints-To: abuse@worldnet.att.net
X-Trace: bgtnsc06-news.ops.worldnet.att.net 1008356859 12.90.170.202 (Fri, 14 Dec 2001 19:07:39 GMT)
NNTP-Posting-Date: Fri, 14 Dec 2001 19:07:39 GMT