Question: package/module problem

Hi,

The aim is simple. For some defined procedures, I would like to load them with one single line, and show the 'welcome' message, then be able to use the procedures.

Download 7845_test.zip
View file details

============================

In 'hello' file,

hello:=module()
export welcome,a,b;
option package;

welcome:=proc()
   print("welcome to this package");
end proc:

a:=proc(n)
local c;
c:=n-1;
end proc:

b:=proc(n)
local d;
d:=n+1;
end proc:

end module:
============================

in a new worksheet that saved in the same directory

> restart:
> read "hello";
> with(hello);

                           [a, b, welcome]

> a(4);

                                  3

> b(4);

                                  5

it dose not show the 'welcome' message,

and it has to read, then use with, can it be done in single line?

 

============================

In 'he2' file,

 

a:=proc(n)
local c;
c:=n-1;
end proc:

b:=proc(n)
local d;
d:=n+1;
end proc:

print("welcome to this package");

============================

in a new worksheet that saved in the same directory

> restart:
> read he2;

                      "welcome to this package"

> a(4);

                                  3

> b(4);

                                  5
can it lose the '' '' when showing the welcome message?

how can I make it the functions like using the with(hello);

 

I do not want to use something the involves with defining library directory becasue if so, then if I pass the codes to my lecture, he has to defdefining library directory as well, right?

I want all these files are portable, kept in the same directory.

with one single command, read or with, whatever,

will show the welcome message and the defined functions.

what's the best way to do this?

 

Thanks in advance!

casper
 

 

Please Wait...