<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.sternwarte.uni-erlangen.de/wiki/index.php?action=history&amp;feed=atom&amp;title=Changing_qualifiers_before_passing_them_on</id>
	<title>Changing qualifiers before passing them on - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.sternwarte.uni-erlangen.de/wiki/index.php?action=history&amp;feed=atom&amp;title=Changing_qualifiers_before_passing_them_on"/>
	<link rel="alternate" type="text/html" href="https://www.sternwarte.uni-erlangen.de/wiki/index.php?title=Changing_qualifiers_before_passing_them_on&amp;action=history"/>
	<updated>2026-04-11T12:14:53Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.7</generator>
	<entry>
		<id>https://www.sternwarte.uni-erlangen.de/wiki/index.php?title=Changing_qualifiers_before_passing_them_on&amp;diff=911&amp;oldid=prev</id>
		<title>Lorenz at 13:36, 12 April 2018</title>
		<link rel="alternate" type="text/html" href="https://www.sternwarte.uni-erlangen.de/wiki/index.php?title=Changing_qualifiers_before_passing_them_on&amp;diff=911&amp;oldid=prev"/>
		<updated>2018-04-12T13:36:10Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 13:36, 12 April 2018&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l3&quot; &gt;Line 3:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In S-Lang (and thus also isis) it is possible to pass options to functions as qualifiers rather than arguments. This is useful, e.g., if you only want to specify certain options sometimes and use a predefined value else.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In S-Lang (and thus also isis) it is possible to pass options to functions as qualifiers rather than arguments. This is useful, e.g., if you only want to specify certain options sometimes and use a predefined value else.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Defining a function, qualifiers can be used as (from the [[http://pulsar.sternwarte.uni-erlangen.de/hanke/science/X-ray/ISIS/cgi/help.cgi?subj=qualifier|S-Lang help for &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;''&lt;/del&gt;qualifier&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;''&lt;/del&gt;]]):&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Defining a function, qualifiers can be used as (from the [[http://pulsar.sternwarte.uni-erlangen.de/hanke/science/X-ray/ISIS/cgi/help.cgi?subj=qualifier|S-Lang help for &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;quot;&lt;/ins&gt;qualifier&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;quot;&lt;/ins&gt;]])&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;LINK DOES NOT EXIST ANYMORE?&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/span&amp;gt;&lt;/ins&gt;:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;define echo (text)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;define echo (text)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Lorenz</name></author>
	</entry>
	<entry>
		<id>https://www.sternwarte.uni-erlangen.de/wiki/index.php?title=Changing_qualifiers_before_passing_them_on&amp;diff=909&amp;oldid=prev</id>
		<title>Lorenz: Created page with &quot;== changing qualifiers before passing them on ==  In S-Lang (and thus also isis) it is possible to pass options to functions as qualifiers rather than arguments. This is usefu...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.sternwarte.uni-erlangen.de/wiki/index.php?title=Changing_qualifiers_before_passing_them_on&amp;diff=909&amp;oldid=prev"/>
		<updated>2018-04-12T13:30:08Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== changing qualifiers before passing them on ==  In S-Lang (and thus also isis) it is possible to pass options to functions as qualifiers rather than arguments. This is usefu...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== changing qualifiers before passing them on ==&lt;br /&gt;
&lt;br /&gt;
In S-Lang (and thus also isis) it is possible to pass options to functions as qualifiers rather than arguments. This is useful, e.g., if you only want to specify certain options sometimes and use a predefined value else.&lt;br /&gt;
&lt;br /&gt;
Defining a function, qualifiers can be used as (from the [[http://pulsar.sternwarte.uni-erlangen.de/hanke/science/X-ray/ISIS/cgi/help.cgi?subj=qualifier|S-Lang help for ''qualifier'']]):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
define echo (text)&lt;br /&gt;
{&lt;br /&gt;
   variable fp = qualifier (&amp;quot;out&amp;quot;, stdout);&lt;br /&gt;
   () = fputs (text, fp);&lt;br /&gt;
}&lt;br /&gt;
echo (&amp;quot;hello&amp;quot;);              % writes hello to stdout&lt;br /&gt;
echo (&amp;quot;hello&amp;quot;; out=stderr);  % writes hello to stderr&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To pass a bunch of qualifiers as a single struct instead of comma separated set of name-value pairs, you need to let the parser know that you are using a structure-valued argument. Use a double semicolon to do so:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
variable quals = struct{ out=stderr };&lt;br /&gt;
echo(&amp;quot;hello&amp;quot;;; quals);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Sometimes it is just useful to switch the behavior of a function via a qualifier without a value (or the &amp;lt;code&amp;gt;NULL&amp;lt;/code&amp;gt; value) by just checking for its existence via &amp;lt;code&amp;gt;qualifier_exists(&amp;quot;qualifier_name&amp;quot;)&amp;lt;/code&amp;gt; (again from the S-Lang help):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
define echo (text)&lt;br /&gt;
{&lt;br /&gt;
   variable fp = stdout;&lt;br /&gt;
   if (qualifier_exists (&amp;quot;use_stderr&amp;quot;))&lt;br /&gt;
     fp = stderr;&lt;br /&gt;
   () = fputs (text, fp);&lt;br /&gt;
}&lt;br /&gt;
echo (&amp;quot;hello&amp;quot;; use_stderr);  % writes hello to stderr&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Qualifiers can also be passed on from one function to another function that is called in the definition: &amp;lt;code&amp;gt;__qualifiers()&amp;lt;/code&amp;gt; returns the active set of qualifiers as a structure. You can just use it directly with a double semicolon to pass the qualifiers as shown above:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
define line_segment (x0, y0, x1, y1)&lt;br /&gt;
{&lt;br /&gt;
   moveto (x0, y0);&lt;br /&gt;
   lineto (x1, y1 ;; __qualifiers());&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So any qualifier specified in &amp;lt;code&amp;gt;line_segment&amp;lt;/code&amp;gt; is directly passed to &amp;lt;code&amp;gt;lineto&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
But what if you want to modify some of the qualifiers first? Just use [[http://pulsar.sternwarte.uni-erlangen.de/hanke/science/X-ray/ISIS/cgi/help.cgi?subj=struct_combine|struct_combine]] (or the equivalent dereference operator) and take advantage of the facts that&lt;br /&gt;
* it is NULL-safe and&lt;br /&gt;
* more than one structure may have the same field name, in which case the value is given by the last structure:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
define get_pixel_array(dat, gainf, range)&lt;br /&gt;
{&lt;br /&gt;
   variable pix = qualifier(&amp;quot;pixel&amp;quot;, [0:31]);&lt;br /&gt;
   variable arr = Struct_Type[length(pix)];&lt;br /&gt;
   variable i;&lt;br /&gt;
   _for i(0, length(arr)-1)&lt;br /&gt;
      arr[i] = vtoen(dat, gainf, range;; struct { @__qualifiers(), pixel=[pix[i]] });&lt;br /&gt;
   return arr;&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
More complicated solution: &amp;lt;del&amp;gt;Just save the structure returned by the function &amp;lt;nowiki&amp;gt;__qualifiers()&amp;lt;/nowiki&amp;gt; into a variable, change/add/remove fields in that structure and then pass the new structure on. But be careful not to produce errors if no qualifier is used:&amp;lt;/del&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
define get_pixel_array(dat, gainf, range)&lt;br /&gt;
{&lt;br /&gt;
   variable pix = qualifier(&amp;quot;pixel&amp;quot;,[0:31:1]);&lt;br /&gt;
   variable arr = Struct_Type[length(pix)];&lt;br /&gt;
   variable i;&lt;br /&gt;
   &lt;br /&gt;
   variable qual = __qualifiers();&lt;br /&gt;
   if (typeof(qual) == Null_Type){ % if there are no qualifiers, there also is no struct&lt;br /&gt;
      qual = struct{pixel};&lt;br /&gt;
   }else if (struct_field_exists(qual,&amp;quot;pixel&amp;quot;) == 0){&lt;br /&gt;
      qual=struct_combine(qual, &amp;quot;pixel&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   _for i(0,length(arr)-1,1)&lt;br /&gt;
   {&lt;br /&gt;
      qual.pixel=[pix[i]];&lt;br /&gt;
      arr[i] = vtoen(dat,gainf,range;; qual);&lt;br /&gt;
   }&lt;br /&gt;
   return arr;&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Usually, it would probably be easier to change the original function but for example in this case for just a quick trouble shooting, I did not want to mess around with my function &amp;lt;code&amp;gt;vtoen&amp;lt;/code&amp;gt;, which usually takes the qualifier &amp;lt;code&amp;gt;pixel&amp;lt;/code&amp;gt; to know which pixels to sum up after gain correction. However, if you want an array of all individual pixels instead, i.e., loop through the entries in &amp;lt;code&amp;gt;pixel&amp;lt;/code&amp;gt; while leaving other qualifiers untouched, the presented option is a quick workaround to still be able to access the other possible qualifiers (as, e.g., time or flag filtering).&lt;br /&gt;
&lt;br /&gt;
If you want to look at how the &amp;lt;code&amp;gt;struct&amp;lt;/code&amp;gt; for qualifiers looks like, you can do:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
define qual(){ return __qualifiers(); }&lt;br /&gt;
variable test = qual(;noval, someval=1, anarray=[&amp;quot;a&amp;quot;,&amp;quot;b&amp;quot;]);&lt;br /&gt;
print(test);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Isis / Slang]]&lt;/div&gt;</summary>
		<author><name>Lorenz</name></author>
	</entry>
</feed>