[fpc-pascal] arbitrary number of parameters in procedure

2005-08-31 Thread Pianoman
Hi, I have not well understood the docs concerning tvarrecs. How can I
create procedure which will accept arbitrary number of parameters?
To demonstrate what I want:
procedure addnums(a,b,c, of any types var result:sometype);
or writetoscreen(any number of parameters of given type. something like
write or readln procedures.
Thanx for help
Pianoman
- Original Message -
From: <[EMAIL PROTECTED]>
To: 
Sent: Wednesday, August 31, 2005 12:00 PM
Subject: fpc-pascal Digest, Vol 12, Issue 28


Send fpc-pascal mailing list submissions to
fpc-pascal@lists.freepascal.org

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
[EMAIL PROTECTED]

You can reach the person managing the list at
[EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of fpc-pascal digest..."


Today's Topics:

   1. Re:  set envirom variable with pascal in linux (Alain Vitry)
   2. Re:  set envirom variable with pascal in linux
  (Michael Van Canneyt)
   3. Re:  set envirom variable with pascal in linux (Marc Santhoff)
   4.  BMP support improved, feedback welcome. (Michael Van Canneyt)
   5. Re:  set envirom variable with pascal in linux (mondrillo)
   6. Re:  set envirom variable with pascal in linux (mondrillo)
   7.  Re: set envirom variable with pascal in linux (mondrillo)


--

Message: 1
Date: Tue, 30 Aug 2005 12:16:29 +0200
From: Alain Vitry <[EMAIL PROTECTED]>
Subject: Re: [fpc-pascal] set envirom variable with pascal in linux
To: FPC-Pascal users discussions 
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

FYI, see
http://alain.vitry.free.fr/en/devel/devel-pascal.php

Le 30 août 05, à 08:47, mondrillo a écrit :

> Hello list,
>
> In Bach, Perl, can do set SDL_VER=`sdl-config --version`
> and in enviroment has the variable SDL_VER=1.2.3 for example.
> echo $SDL_VER
> 1.2.3
> But in Pascal non have the setenv() procedure as in C :(
>
> Actualy I resolve this problem with sending the output to a file, and
> then reading the file. But, can I pass from C this function?, or call
> a libc (thinks is this lib that has setenv() ) from Pascal to execute
> setenv().
>
> Thank's and regards.
>
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>




--

Message: 2
Date: Tue, 30 Aug 2005 11:13:30 +0200 (Romance Daylight Time)
From: Michael Van Canneyt <[EMAIL PROTECTED]>
Subject: Re: [fpc-pascal] set envirom variable with pascal in linux
To: FPC-Pascal users discussions 
Message-ID: <[EMAIL PROTECTED]>
Content-Type: TEXT/PLAIN; charset=US-ASCII



On Tue, 30 Aug 2005, mondrillo wrote:

> Hello list,
>
> In Bach, Perl, can do set SDL_VER=`sdl-config --version`
> and in enviroment has the variable SDL_VER=1.2.3 for example.
> echo $SDL_VER
> 1.2.3
> But in Pascal non have the setenv() procedure as in C :(
>
> Actualy I resolve this problem with sending the output to a file, and
> then reading the file. But, can I pass from C this function?, or call
> a libc (thinks is this lib that has setenv() ) from Pascal to execute
> setenv().

That will not work.

FPC has a copy of the environment, which it received on startup.
It makes little or no sense to add strings to this, since it is
for internal use only.

If you want to execute another program with a different set of
environment strings, you must use the execve call to specify a
different set of environment variables.

The TProcess component allows you to easily specify the
environment as a TStringList.

Michael.



--

Message: 3
Date: Tue, 30 Aug 2005 14:53:43 +0200
From: Marc Santhoff <[EMAIL PROTECTED]>
Subject: Re: [fpc-pascal] set envirom variable with pascal in linux
To: fpc-pascal@lists.freepascal.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain

Am Dienstag, den 30.08.2005, 08:47 +0200 schrieb mondrillo:
> Hello list,
>
> In Bach, Perl, can do set SDL_VER=`sdl-config --version`
> and in enviroment has the variable SDL_VER=1.2.3 for example.
> echo $SDL_VER
> 1.2.3
> But in Pascal non have the setenv() procedure as in C :(
>
> Actualy I resolve this problem with sending the output to a file, and
> then reading the file. But, can I pass from C this function?, or call
> a libc (thinks is this lib that has setenv() ) from Pascal to execute
> setenv().
>

If you're using a command line to execute a foreign program you can
always tell the shell:

csh: "setenv VAR value; your-foreign-program"
sh:  "VAR=value; your-foreign-program"

Not portable, ugly workaround, but it does do the job.

HTH,
Marc





--

Message: 4
Date: Tue, 30 Aug 2005 21:45:21 +0200 (CEST)
From: Michael Van Canneyt <[EMAIL

Re: [fpc-pascal] arbitrary number of parameters in procedure

2005-08-31 Thread Michael Van Canneyt


On Wed, 31 Aug 2005, Pianoman wrote:

> Hi, I have not well understood the docs concerning tvarrecs. How can I
> create procedure which will accept arbitrary number of parameters?
> To demonstrate what I want:
> procedure addnums(a,b,c, of any types var result:sometype);
> or writetoscreen(any number of parameters of given type. something like
> write or readln procedures.

Something like this:

Procedure AddNums(Var Result : Double; Args : Array of const);

Var 
  I : Integer;

begin
  Result:=0;
  For I:=0 to High(Args) do // High(args) is the last valid index.
   Case Args[i].Vtype of // args[i] is of type TVarRec 
 VtInteger : Result:=Result+Args[ArgPos].VInteger; 
// ... etc
   end; 
end;

Call like

  AddNums(MyDouble,[a,b,c,d]);

And you're all done.  

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal