Editing
Guide to madagascar programs
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==sfget== {| class="wikitable" align="center" cellspacing="0" border="1" ! colspan="4" style="background:#ffdead;" | Output parameters from the header. |- ! colspan="4" | sfget parform=y all=n par1 par2 ... |- | ''bool '' || '''all=n''' || [y/n] || If output all values. |- | ''bool '' || '''parform=y''' || [y/n] || If y, print out parameter=value. If n, print out value. |} The <tt>sfget</tt> program extracts a parameter value from an RSF file. It is useful mostly for scripting. Here is, for example, a quick calculation of the maximum value on the first axis in an RSF dataset (the output of <tt>sfspike</tt>) using the standard Unix <tt>bc</tt> calculator. <pre> bash$ ( sfspike n1=100 | sfget n1 d1 o1; echo "o1+(n1-1)*d1" ) | bc .396 </pre> See also <tt>sfput</tt>. ====Implementation: [https://github.com/ahay/src/blob/master/system/main/get.c system/main/get.c]==== The implementation is trivial. Loop through all command-line parameters that contain the "=" character. <syntaxhighlight lang="c"> for (i = 1; i < argc; i++) { key = argv[i]; if (NULL != strchr(key,'=')) continue; </syntaxhighlight> Get the parameter value (as string) and output it as either <tt>key=value</tt> or <tt>value</tt>, depending on the <tt>parform</tt> parameter. <syntaxhighlight lang="c"> string = sf_histstring(in,key); if (NULL == string) { sf_warning("No key %s",key); } else { if (parform) printf ("%s=",key); printf("%s\n",string); } </syntaxhighlight>
Summary:
Please note that all contributions to Madagascar are considered to be released under the GNU Free Documentation License 1.3 or later (see
My wiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
English
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Getting Madagascar
download
Installation
GitHub repository
SEGTeX
Introduction
Package overview
Tutorial
Hands-on tour
Reproducible documents
Hall of Fame
User Documentation
List of programs
Common programs
Popular programs
The RSF file format
Reproducibility with SCons
Developer documentation
Adding programs
Contributing programs
API demo: clipping data
API demo: explicit finite differences
Community
Conferences
User mailing list
Developer mailing list
GitHub organization
LinkedIn group
Development blog
Twitter
Slack
Tools
What links here
Related changes
Special pages
Page information