Post a reply
Username:
Note:If not registered, provide any username. For more comfort, register here.
Subject:
Message body:
Enter your message here, it may contain no more than 60000 characters. 

Smilies
:D :) :( :o :shock: :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen:
Font size:
Font colour
Options:
BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON
Disable BBCode
Disable smilies
Do not automatically parse URLs
Confirmation of post
To prevent automated posts the board requires you to enter a confirmation code. The code is displayed in the image you should see below. If you are visually impaired or cannot otherwise read this code please contact the %sBoard Administrator%s.
Confirmation code:
Enter the code exactly as it appears. All letters are case insensitive, there is no zero.
   

Topic review - How to save procedure into a file and run this file nexttime
Author Message
  Post subject:  Re: How to save procedure into a file and run this file nexttime  Reply with quote
It works. save as a text file with extension .sing and < "name.sing". Thanks
Post Posted: Mon Sep 06, 2010 3:22 pm
  Post subject:  Re: How to save procedure into a file and run this file nexttime  Reply with quote
Forgot to mention:
3.2.5 Editing SINGULAR input files with Emacs
http://www.singular.uni-kl.de/Manual/la ... .htm#SEC36
Quote:
When running ESingular, the C/C++-mode is automatically turned on whenever a file with the suffix .sing, or .lib is loaded.


Furthermore note:

< for file-input ( singular-load-file ) has the key-binding
CTRL-c <
and the LIB command (singular-load-lib) bound to
CTRL-c CTRL-l.
Post Posted: Mon Aug 30, 2010 10:35 am
  Post subject:  Re: How to save procedure into a file and run this file nexttime  Reply with quote
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
Post Posted: Sat Aug 28, 2010 9:44 pm
  Post subject:  How to save procedure into a file and run this file nexttime  Reply with quote
How to save procedure into a file in singular terminal

After saved, How to run this file next time?

Where will it be saved in Linux such as ubuntu?
Post Posted: Sat Aug 28, 2010 3:25 pm


It is currently Fri May 13, 2022 11:07 am
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group