Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2005-05

Varriable number of parameters

4 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Pianoman

Hi, how can I create procedure with undefined number of parrameters. Writeln is example of what I am looking for for example procedure add(a,b,c,.... var result)
Pianoman

Earlier message 350 lines
----- Original Message ----- From: To: Sent: Wednesday, May 11, 2005 12:00 PM Subject: fpc-pascal Digest, Vol 9, Issue 11 > Send fpc-pascal mailing list submissions to > > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > or, via email, send a message with subject or body 'help' to > > > You can reach the person managing the list at > > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of fpc-pascal digest..." > > > Today's Topics: > > 1. Re: freepascal website programmed in...? (Rimgaudas Laucius) > 2. Re: building docs from cvs (Bob Barry) > 3. Re: building docs from cvs (Marco van de Voort) > 4. Re: building docs from cvs (Michael Van Canneyt) > 5. Re: building docs from cvs (Florian Klaempfl) > 6. Re: building docs from cvs (Marco van de Voort) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Tue, 10 May 2005 21:58:52 +0300 > From: "Rimgaudas Laucius" > Subject: Re: [fpc-pascal] freepascal website programmed in...? > To: "FPC-Pascal users discussions" > Message-ID: > Content-Type: text/plain; charset="iso-8859-1" > > Hi, > > there is nothing curiuos. I also use FPC to program CGI websites. I has one > advantage: i use Windows in my work and there is almost no need of > additional effort to port FPC programs to Linux server. > > > ----- Original Message ----- > From: "L505" > To: > Sent: Tuesday, May 10, 2005 12:34 AM > Subject: [fpc-pascal] freepascal website programmed in...? > > > > The freepascal.org website and community is programmed in.... CGI/pascal? > > ;-) > > > > curious... > > Lars > > > > > > _______________________________________________ > > fpc-pascal maillist - > > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > > > ------------------------------ > > Message: 2 > Date: Wed, 11 May 2005 09:48:11 +0200 > From: Bob Barry > Subject: Re: [fpc-pascal] building docs from cvs > To: > Cc: FPC-Pascal users discussions > Message-ID: > Content-Type: text/plain; charset="us-ascii" > > Michael - > > On Sun, 8 May 2005 11:25 you wrote: > >> But ps and pdf still don't compile. > > Strange, because I did a 'make alldist' yesterday and uploaded all > > docs for the 2.0 release. All is committed and tagged. > > Compilation of pdf and ps fail for me, but it looks like the fault is in using > out-of-the-box setup of tetex.. It might be a good idea to test the relevant > parameter at start of compilation, and if value is inadequate then exit with > a message suggesting what to do about it. > > Pdf compilation fails with: > LaTeX Warning: Reference `rtl:x86:readportw' on page 1283 undefined on input li > ne 79730. > > ) [1283] (./rtl.aux > ! TeX capacity exceeded, sorry [save size=5000]. > @bel ...dafter \ifx \csname > \else > l.8883 ...213}{Types\relax }{subsection.31.2.2}{}} > > ! ==> Fatal error occurred, the output PDF file is not finished! > Transcript written on rtl.log. > make: *** [rtl.pdf] Error 1 > make: Leaving directory `/home/bobb/freepascal/cvs/fpc/docs' > > Similarly, compilation of ps fails with: > LaTeX Warning: Reference `rtl:x86:readportw' on page 1292 undefined on input li > ne 79730. > > ) [1292] (./rtl.aux > ! TeX capacity exceeded, sorry [save size=5000]. > @bel ...dafter \ifx \csname > \else > l.8883 ...222}{Types\relax }{subsection.31.2.2}{}} > > Output written on rtl.dvi (1293 pages, 7460520 bytes). > Transcript written on rtl.log. > make: *** [rtl.dvi] Error 1 > make: Leaving directory `/home/bobb/freepascal/cvs/fpc/docs' > > Thanks, > > Bob > > > > ------------------------------ > > Message: 3 > Date: Wed, 11 May 2005 09:51:25 +0200 (CEST) > From: (Marco van de Voort) > Subject: Re: [fpc-pascal] building docs from cvs > To: , FPC-Pascal users discussions > > Message-ID: > Content-Type: text/plain; charset=US-ASCII > > > On Sun, 8 May 2005 11:25 you wrote: > > >> But ps and pdf still don't compile. > > > Strange, because I did a 'make alldist' yesterday and uploaded all > > > docs for the 2.0 release. All is committed and tagged. > > > > Compilation of pdf and ps fail for me, but it looks like the fault is in using > > out-of-the-box setup of tetex.. It might be a good idea to test the relevant > > parameter at start of compilation, and if value is inadequate then exit with > > a message suggesting what to do about it. > > If you know how :_) > > Anyway, in texmf.conf you need to up some of the limits. The default values > are too tight. > > > > > ------------------------------ > > Message: 4 > Date: Wed, 11 May 2005 10:13:41 +0200 (Romance Daylight Time) > From: Michael Van Canneyt > Subject: Re: [fpc-pascal] building docs from cvs > To: FPC-Pascal users discussions > Message-ID: > Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed > > > > On Wed, 11 May 2005, Marco van de Voort wrote: > > >> On Sun, 8 May 2005 11:25 you wrote: > >>>> But ps and pdf still don't compile. > >>> Strange, because I did a 'make alldist' yesterday and uploaded all > >>> docs for the 2.0 release. All is committed and tagged. > >> > >> Compilation of pdf and ps fail for me, but it looks like the fault is in using > >> out-of-the-box setup of tetex.. It might be a good idea to test the relevant > >> parameter at start of compilation, and if value is inadequate then exit with > >> a message suggesting what to do about it. > > > > If you know how :_) > > > > Anyway, in texmf.conf you need to up some of the limits. The default values > > are too tight. > > Exactly. > > set > > save_size=10000 > > in texmf.conf > > Normally, you can also do it via an environment variable. > > export save_size=10000 > pdflatex rtl.tex > > I have received a fix for the makefiles, which I received from the Debian devels. > I'll see about applying it tonight. > > Michael. > > > > ------------------------------ > > Message: 5 > Date: Wed, 11 May 2005 10:24:16 +0200 > From: Florian Klaempfl > Subject: Re: [fpc-pascal] building docs from cvs > To: , FPC-Pascal users discussions > > Message-ID: > Content-Type: text/plain; charset=us-ascii > > Bob Barry wrote: > > > Michael - > > > > On Sun, 8 May 2005 11:25 you wrote: > > > >>>But ps and pdf still don't compile. > >> > >>Strange, because I did a 'make alldist' yesterday and uploaded all > >>docs for the 2.0 release. All is committed and tagged. > > > > > > Compilation of pdf and ps fail for me, but it looks like the fault is in using > > out-of-the-box setup of tetex.. It might be a good idea to test the relevant > > parameter at start of compilation, and if value is inadequate then exit with > > a message suggesting what to do about it. > > The problem is that the fpc docs are huge and that the default values of some > TeX distribtions are too small. I don't know if these values can be tested > inside a TeX file. > > > > > Pdf compilation fails with: > > LaTeX Warning: Reference `rtl:x86:readportw' on page 1283 undefined on input li > > ne 79730. > > > > ) [1283] (./rtl.aux > > ! TeX capacity exceeded, sorry [save size=5000]. > > @bel ...dafter \ifx \csname > > \else > > l.8883 ...213}{Types\relax }{subsection.31.2.2}{}} > > > > ! ==> Fatal error occurred, the output PDF file is not finished! > > Transcript written on rtl.log. > > make: *** [rtl.pdf] Error 1 > > make: Leaving directory `/home/bobb/freepascal/cvs/fpc/docs' > > > > Similarly, compilation of ps fails with: > > LaTeX Warning: Reference `rtl:x86:readportw' on page 1292 undefined on input li > > ne 79730. > > > > ) [1292] (./rtl.aux > > ! TeX capacity exceeded, sorry [save size=5000]. > > @bel ...dafter \ifx \csname > > \else > > l.8883 ...222}{Types\relax }{subsection.31.2.2}{}} > > > > Output written on rtl.dvi (1293 pages, 7460520 bytes). > > Transcript written on rtl.log. > > make: *** [rtl.dvi] Error 1 > > make: Leaving directory `/home/bobb/freepascal/cvs/fpc/docs' > > > > Thanks, > > > > Bob > > > > _______________________________________________ > > fpc-pascal maillist - > > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > > > ------------------------------ > > Message: 6 > Date: Wed, 11 May 2005 10:35:24 +0200 (CEST) > From: (Marco van de Voort) > Subject: Re: [fpc-pascal] building docs from cvs > To: FPC-Pascal users discussions > Message-ID: > Content-Type: text/plain; charset=US-ASCII > > > Normally, you can also do it via an environment variable. > > > > export save_size=10000 > > pdflatex rtl.tex > > > > I have received a fix for the makefiles, which I received from the Debian devels. > > I'll see about applying it tonight. > > Added to > > http://www.freepascal.org/wiki/index.php/Release_engineering > > > > ------------------------------ > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > End of fpc-pascal Digest, Vol 9, Issue 11 > ***************************************** > > > > __________ Informacia od NOD32 1.1092 (20050510) __________ > > Tato sprava bola preverena antivirusovym systemom NOD32. > http://www.eset.sk > >
Michael Van Canneyt
to Pianoman
Pianoman wrote
Hi, how can I create procedure with undefined number of parrameters. Writeln is example of what I am looking for for example procedure add(a,b,c,.... var result)

If the function must be written in pascal, all you can do is use the array of const construction:

Function MyFunction(Fmt : STring; Args : Array of const);
Which can be called as
Function MyFunction(A,[B,C,D]);

or

Function MyFunction(A,[D]);

etc.

Michael.

Show quoted text 357 lines
Pianoman ----- Original Message ----- From: To: Sent: Wednesday, May 11, 2005 12:00 PM Subject: fpc-pascal Digest, Vol 9, Issue 11 > Send fpc-pascal mailing list submissions to > > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > or, via email, send a message with subject or body 'help' to > > > You can reach the person managing the list at > > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of fpc-pascal digest..." > > > Today's Topics: > > 1. Re: freepascal website programmed in...? (Rimgaudas Laucius) > 2. Re: building docs from cvs (Bob Barry) > 3. Re: building docs from cvs (Marco van de Voort) > 4. Re: building docs from cvs (Michael Van Canneyt) > 5. Re: building docs from cvs (Florian Klaempfl) > 6. Re: building docs from cvs (Marco van de Voort) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Tue, 10 May 2005 21:58:52 +0300 > From: "Rimgaudas Laucius" > Subject: Re: [fpc-pascal] freepascal website programmed in...? > To: "FPC-Pascal users discussions" > Message-ID: > Content-Type: text/plain; charset="iso-8859-1" > > Hi, > > there is nothing curiuos. I also use FPC to program CGI websites. I has one > advantage: i use Windows in my work and there is almost no need of > additional effort to port FPC programs to Linux server. > > > ----- Original Message ----- > From: "L505" > To: > Sent: Tuesday, May 10, 2005 12:34 AM > Subject: [fpc-pascal] freepascal website programmed in...? > > >> The freepascal.org website and community is programmed in.... CGI/pascal? >> ;-) >> >> curious... >> Lars >> >> >> _______________________________________________ >> fpc-pascal maillist - >> http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > > > ------------------------------ > > Message: 2 > Date: Wed, 11 May 2005 09:48:11 +0200 > From: Bob Barry > Subject: Re: [fpc-pascal] building docs from cvs > To: > Cc: FPC-Pascal users discussions > Message-ID: > Content-Type: text/plain; charset="us-ascii" > > Michael - > > On Sun, 8 May 2005 11:25 you wrote: >>> But ps and pdf still don't compile. >> Strange, because I did a 'make alldist' yesterday and uploaded all >> docs for the 2.0 release. All is committed and tagged. > > Compilation of pdf and ps fail for me, but it looks like the fault is in using > out-of-the-box setup of tetex.. It might be a good idea to test the relevant > parameter at start of compilation, and if value is inadequate then exit with > a message suggesting what to do about it. > > Pdf compilation fails with: > LaTeX Warning: Reference `rtl:x86:readportw' on page 1283 undefined on input li > ne 79730. > > ) [1283] (./rtl.aux > ! TeX capacity exceeded, sorry [save size=5000]. > @bel ...dafter \ifx \csname > \else > l.8883 ...213}{Types\relax }{subsection.31.2.2}{}} > > ! ==> Fatal error occurred, the output PDF file is not finished! > Transcript written on rtl.log. > make: *** [rtl.pdf] Error 1 > make: Leaving directory `/home/bobb/freepascal/cvs/fpc/docs' > > Similarly, compilation of ps fails with: > LaTeX Warning: Reference `rtl:x86:readportw' on page 1292 undefined on input li > ne 79730. > > ) [1292] (./rtl.aux > ! TeX capacity exceeded, sorry [save size=5000]. > @bel ...dafter \ifx \csname > \else > l.8883 ...222}{Types\relax }{subsection.31.2.2}{}} > > Output written on rtl.dvi (1293 pages, 7460520 bytes). > Transcript written on rtl.log. > make: *** [rtl.dvi] Error 1 > make: Leaving directory `/home/bobb/freepascal/cvs/fpc/docs' > > Thanks, > > Bob > > > > ------------------------------ > > Message: 3 > Date: Wed, 11 May 2005 09:51:25 +0200 (CEST) > From: (Marco van de Voort) > Subject: Re: [fpc-pascal] building docs from cvs > To: , FPC-Pascal users discussions > > Message-ID: > Content-Type: text/plain; charset=US-ASCII > >> On Sun, 8 May 2005 11:25 you wrote: >>>> But ps and pdf still don't compile. >>> Strange, because I did a 'make alldist' yesterday and uploaded all >>> docs for the 2.0 release. All is committed and tagged. >> >> Compilation of pdf and ps fail for me, but it looks like the fault is in using >> out-of-the-box setup of tetex.. It might be a good idea to test the relevant >> parameter at start of compilation, and if value is inadequate then exit with >> a message suggesting what to do about it. > > If you know how :_) > > Anyway, in texmf.conf you need to up some of the limits. The default values > are too tight. > > > > > ------------------------------ > > Message: 4 > Date: Wed, 11 May 2005 10:13:41 +0200 (Romance Daylight Time) > From: Michael Van Canneyt > Subject: Re: [fpc-pascal] building docs from cvs > To: FPC-Pascal users discussions > Message-ID: > Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed > > > > On Wed, 11 May 2005, Marco van de Voort wrote: > >>> On Sun, 8 May 2005 11:25 you wrote: >>>>> But ps and pdf still don't compile. >>>> Strange, because I did a 'make alldist' yesterday and uploaded all >>>> docs for the 2.0 release. All is committed and tagged. >>> >>> Compilation of pdf and ps fail for me, but it looks like the fault is in using >>> out-of-the-box setup of tetex.. It might be a good idea to test the relevant >>> parameter at start of compilation, and if value is inadequate then exit with >>> a message suggesting what to do about it. >> >> If you know how :_) >> >> Anyway, in texmf.conf you need to up some of the limits. The default values >> are too tight. > > Exactly. > > set > > save_size=10000 > > in texmf.conf > > Normally, you can also do it via an environment variable. > > export save_size=10000 > pdflatex rtl.tex > > I have received a fix for the makefiles, which I received from the Debian devels. > I'll see about applying it tonight. > > Michael. > > > > ------------------------------ > > Message: 5 > Date: Wed, 11 May 2005 10:24:16 +0200 > From: Florian Klaempfl > Subject: Re: [fpc-pascal] building docs from cvs > To: , FPC-Pascal users discussions > > Message-ID: > Content-Type: text/plain; charset=us-ascii > > Bob Barry wrote: > >> Michael - >> >> On Sun, 8 May 2005 11:25 you wrote: >> >>>> But ps and pdf still don't compile. >>> >>> Strange, because I did a 'make alldist' yesterday and uploaded all >>> docs for the 2.0 release. All is committed and tagged. >> >> >> Compilation of pdf and ps fail for me, but it looks like the fault is in using >> out-of-the-box setup of tetex.. It might be a good idea to test the relevant >> parameter at start of compilation, and if value is inadequate then exit with >> a message suggesting what to do about it. > > The problem is that the fpc docs are huge and that the default values of some > TeX distribtions are too small. I don't know if these values can be tested > inside a TeX file. > >> >> Pdf compilation fails with: >> LaTeX Warning: Reference `rtl:x86:readportw' on page 1283 undefined on input li >> ne 79730. >> >> ) [1283] (./rtl.aux >> ! TeX capacity exceeded, sorry [save size=5000]. >> @bel ...dafter \ifx \csname >> \else >> l.8883 ...213}{Types\relax }{subsection.31.2.2}{}} >> >> ! ==> Fatal error occurred, the output PDF file is not finished! >> Transcript written on rtl.log. >> make: *** [rtl.pdf] Error 1 >> make: Leaving directory `/home/bobb/freepascal/cvs/fpc/docs' >> >> Similarly, compilation of ps fails with: >> LaTeX Warning: Reference `rtl:x86:readportw' on page 1292 undefined on input li >> ne 79730. >> >> ) [1292] (./rtl.aux >> ! TeX capacity exceeded, sorry [save size=5000]. >> @bel ...dafter \ifx \csname >> \else >> l.8883 ...222}{Types\relax }{subsection.31.2.2}{}} >> >> Output written on rtl.dvi (1293 pages, 7460520 bytes). >> Transcript written on rtl.log. >> make: *** [rtl.dvi] Error 1 >> make: Leaving directory `/home/bobb/freepascal/cvs/fpc/docs' >> >> Thanks, >> >> Bob >> >> _______________________________________________ >> fpc-pascal maillist - >> http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > > > ------------------------------ > > Message: 6 > Date: Wed, 11 May 2005 10:35:24 +0200 (CEST) > From: (Marco van de Voort) > Subject: Re: [fpc-pascal] building docs from cvs > To: FPC-Pascal users discussions > Message-ID: > Content-Type: text/plain; charset=US-ASCII > >> Normally, you can also do it via an environment variable. >> >> export save_size=10000 >> pdflatex rtl.tex >> >> I have received a fix for the makefiles, which I received from the Debian devels. >> I'll see about applying it tonight. > > Added to > > http://www.freepascal.org/wiki/index.php/Release_engineering > > > > ------------------------------ > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > End of fpc-pascal Digest, Vol 9, Issue 11 > ***************************************** > > > > __________ Informacia od NOD32 1.1092 (20050510) __________ > > Tato sprava bola preverena antivirusovym systemom NOD32. > http://www.eset.sk > > _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Anandu R Suri

Hi, how can I create procedure with undefined number of parrameters. Writeln is example of what I am looking for for example procedure add(a,b,c,.... var result)
Pianoman

Declare a Function or a procedure as
    MyProc(P1: String; Args: Array of Const);

And as Michael Van Canneyt said, you can use as many parameters. But dont forget to compile it with -S2 option.

Like C, you must provide some method to distinguish between different data types within the first parameter itself, and access the rest using: Args[ParameterNumber].vChar for Char
Args[ParameterNumber].vString for string and
Args[ParameterNumber].vInteger for integer data types.

Michalis Kamburelis
to Anandu R Suri
Anandu R Suri wrote 17 lines
Hi, how can I create procedure with undefined number of parrameters. Writeln is example of what I am looking for for example procedure add(a,b,c,.... var result) Pianoman Declare a Function or a procedure as MyProc(P1: String; Args: Array of Const); And as Michael Van Canneyt said, you can use as many parameters. But dont forget to compile it with -S2 option. Like C, you must provide some method to distinguish between different data types within the first parameter itself, and access the rest using: Args[ParameterNumber].vChar for Char Args[ParameterNumber].vString for string and Args[ParameterNumber].vInteger for integer data types.

Actually, quite the contrary: Unlike C "..." construct, you *don't* have to encode in 1st parameter exact types of the variable parameters. Args is just an array of TVarRec records:
- you can gen their Length by High(Args),
- and you can check their types at runtime by looking at Args[ParameterNumber].vType

Michalis