Singular https://www.singular.uni-kl.de/forum/ |
|
How to save procedure into a file and run this file nexttime https://www.singular.uni-kl.de/forum/viewtopic.php?f=10&t=1851 |
Page 1 of 1 |
Author: | Guest [ Sat Aug 28, 2010 3:25 pm ] |
Post subject: | How to save procedure into a file and run this file nexttime |
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? |
Author: | gorzel [ Sat Aug 28, 2010 9:44 pm ] |
Post subject: | Re: How to save procedure into a file and run this file nexttime |
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
* 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 |
Author: | gorzel [ Mon Aug 30, 2010 10:35 am ] |
Post subject: | Re: How to save procedure into a file and run this file nexttime |
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. |
Author: | Guest [ Mon Sep 06, 2010 3:22 pm ] |
Post subject: | Re: How to save procedure into a file and run this file nexttime |
It works. save as a text file with extension .sing and < "name.sing". Thanks |
Page 1 of 1 | All times are UTC + 1 hour [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |