Guest wrote:
1.) How to save procedure into a file in singular terminal
2.) After saved, How to run this file next time?
3.) Where will it be saved in Linux such as ubuntu?
I will answer your questions in reversed order.
3.) It will be stored at that place which you indicate.
This means, if you enter
Code:
write("dummy.sig","string s = \"hello\";s;");
then a file dummy.sig will be stored in that directory
from which you have called Singular.
If you want to store it somewhere else, then use absolute and
relative paths as usual.
Note that the completion with TAB also works here:
This means
Code:
write("../
shows you the directories and from first letters the directory
name will be completeted.
Note that write just appends to an exisiting file, if your
not using > in front of the file name.
For > and >> with write ee my answers in
viewtopic.php?f=10&t=1850 2.) Once you have this file dummy.sig which
contains correct Singular code, then you can bring
it into Singular with
<. This will execute its contents.
Code:
> < "dummy.sig";
hello
(The command
read will only read the file and return
a string which may be then activated by
execute.)
3.) I will explain how to store the procs, but this is not
the recommended solution for developping procedure.
If you have a procedure e.g.
Code:
proc p(int k)
{
"Increment your input";
return(k+1);
}
p(2);
Increment your input
3
then convert it with the cast string.
write("myproc.sig","proc "+nameof(p) + "(){ " +string(p) + "} ");
Instead nameof(p) you could also just write "proc p( ) "
or give it another name for the proc.
Then
Code:
> kill p;
> p(2);
? `p(2)` is undefined // Okay !
? error occurred in or before STDIN line 41: `p(2);`
> <"myproc.sig"; // Now it is back again!
> p(2);
Increment your input
3
Now the
recommended solution for writing procs.
Develop the procs with an editor, for instance call ESingular
which uses emacs. Then
* split the window, ESC-x 3
* open an new file, (if you will not use *scratch*)
* enable c++-mode (ESC-x c++-mode)
repeat{
* develop your proc code
* save it to some file (e.g. myproc.sig)
you may also use ESC-x write-region for marked text
* in the other window bring this code into Singular by
< "myproc.sig";
} until your code is OK.
For more advance programming, you may write an whole library,
http://www.singular.uni-kl.de/Manual/la ... .htm#SEC88 which has to be read by
LIB --------
Christian Gorzel