RE: How Embperl sub routine retun value?

1999-12-16 Thread Albert Liu


Read about how Perl passes parameters :-)

You shift the value of your parameter into $bb, now you modifiy $bb, but $bb
is a variable of it's own, it has nothing to do with the parameter you pass.
Reread my example and write your sub like this:

[$ sub TTEST $]
[- $aa = 3;  -]
p$aa is [+$aa+]
[- $_[0] = $aa; -]
[$ endsub $]



Gerald


It works, but I never thought i can use this way to pass parameter. Indeed
i never read this in "Programming Perl" book. Perhaps it is at some where
it the book

Anyway, thank you.
Albert



RE: How Embperl sub routine retun value?

1999-12-16 Thread G.W. Haywood

Hi there,

On Mon, 13 Dec 1999, Albert Liu wrote:

 It works, but I never thought i can use this way to pass parameter. Indeed
 i never read this in "Programming Perl" book. Perhaps it is at some where
 it the book

Second edition, pages 111 to 121 inclusive.

73
Ged.



RE: How Embperl sub routine retun value?

1999-12-13 Thread Gerald Richter



 Here is the code for  Execute
 [- Execute ({ inputfile = '/mypath/mylibfile.lib', import = 1 }) -]
 [- TTEST($bb); -]
p$bb is [+$bb+]/p

 and here is the code inside the lib file
 [$ sub TTEST $]
[- $bb = shift; -]
[- $aa = 3;  -]
p$aa is [+$aa+]
[- $bb = $aa; -]
 [$ endsub $]


 Then I got the resule:
 $aa is 3
 $bb is


 What do you think?


Read about how Perl passes parameters :-)

You shift the value of your parameter into $bb, now you modifiy $bb, but $bb
is a variable of it's own, it has nothing to do with the parameter you pass.
Reread my example and write your sub like this:

[$ sub TTEST $]
[- $aa = 3;  -]
p$aa is [+$aa+]
[- $_[0] = $aa; -]
[$ endsub $]



Gerald



RE: How Embperl sub routine retun value?

1999-12-13 Thread Gerald Richter


 It works, but I never thought i can use this way to pass parameter. Indeed
 i never read this in "Programming Perl" book. Perhaps it is at some where
 it the book

You can find all the infomations in the Perl man pages. Read

man perlsub

for example and you will find this information. Also a look at

man perlfaq

often helps

Gerald



RE: How Embperl sub routine retun value?

1999-12-11 Thread Gerald Richter


 Thanks, it works, but the sub routine has to be in same files. How about
 the sub routine is "Execute" from external lib file? I test it, it doesn't
 work, do you know how to pass value between sub routines they are not  in
 same file?


This should work, regardless in which file you sub resides. How does yout
test code looks like?

Gerald



RE: How Embperl sub routine retun value?

1999-12-11 Thread Albert Liu

Hi Gerald,

Thanks, it works, but the sub routine has to be in same files. How about
the sub routine is "Execute" from external lib file? I test it, it doesn't
work, do you know how to pass value between sub routines they are not  in
same file?

Regards,
Albert

At 08:47 AM 12/10/99 +0100, Gerald Richter wrote:
Hi,

 Does anyone know how to return or pass a value inside Embperl sub routine?

You can pass argument like to any other perl subroutine. Unfortunately
return doesn't work right now, but you can return a value by assigning it to
one of the arguments.

Like

 [$ sub TTEST $]
[- $aa = 2; -]
p$aa is [+$aa+]
[- $_[0] = $aa; -]
 [$ endsub $]

 [- TTEST($bb); -]
p$bb is [+$bb+]

Gerald


-
Gerald Richterecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:   Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: [EMAIL PROTECTED] Voice:+49 6133 925151
WWW:http://www.ecos.de  Fax:  +49 6133 925152
-