ParentNumber (Daemon property): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
(Automatically generated page update)
 
(19 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Template:Daemon:ParentNumber subtitle}}
{{Template:Daemon:ParentNumber subtitle}}
<var>ParentNumber</var> returns the user number of the parent thread, the thread that created the thread from which this method is being invoked.


ParentNumber is a member of the [[Daemon class]]
If the thread issuing the <var>ParentNumber</var> method is not an <var>sdaemon</var>, or is an <var>sdaemon</var> but not working for a <var>Daemon</var> object or a [[List of $functions|$COMMxx function]], the <var>ParentNumber</var> property returns a value of <code>-1</code>.  
 
This shared, ReadOnly method returns the user number of the parent thread, the thread that created the thread from which this method is being invoked.
 
If the thread issuing the ParentNumber method is not an sdaemon, or is an sdaemon but not working for a Daemon object or a $COMMxx function, the ParentNumber property returns a value of <tt>-1</tt>.
 
ParentNumber, new as of ''[[Sirius Mods]]'' Version 6.8, takes no arguments and returns a numeric value.


==Syntax==
==Syntax==
Line 13: Line 8:
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%num</th>
<tr><th>%number</th>
<td>A numeric variable to contain the value of the number of the parent thread. </td></tr>
<td>A numeric variable to contain the value of the number of the parent thread.</td></tr>
<tr><th>%(Daemon)</th>
<tr><th><var class="nobr">%(Daemon)</var></th>
<td>The class name in parentheses denotes a shared method. Specifying <tt>%(Daemon):</tt> is not the only way to invoke the method (see [[Daemon class]]_.</td></tr>
<td>The class name in parentheses denotes a [[Notation conventions for methods#Shared methods|shared]] method. <var>ParentNumber</var> can also be invoked via a <var>Daemon</var> object variable, which may be <var>Null</var>.</td></tr>
</table>
</table>


==Usage notes==
==Usage notes==
<ul>
<ul>
<li><var>[[MasterNumber (Daemon property)|MasterNumber]]</var> returns the user number of the master thread, the thread that ultimately created and controls the thread from which this method is being invoked.
<var>[[UserNumber (Daemon property)|UserNumber]]</var> returns the user number of the thread associated with the daemon method object.
<p>
<var>MasterNumber</var> returns the same value as the <var>ParentNumber</var> method if the parent thread has no parent. Otherwise, <var>MasterNumber</var> method follows the parent chain to the highest level, that is, to the parent that does not have a parent. </p>
<li>An asynchronous <var>[[$CommBg]]</var> daemon or an independent daemon start with the <var>[[RunIndependently (Daemon subroutine)|RunIndependently]]</var> method might have a parent thread but never a master thread; master implies control.
<li><var>ParentNumber</var> has a $function equivalent: <var>[[$DaemonParentNumber]]</var>. The $function and method can be used interchangeably, whether the daemons were created with $COMMxx functions or Daemon objects. That is, the method can also be used with daemons that were created via $COMMxx functions, and the $function can also be used with daemons that were created via <var>Daemon</var> objects.
</ul>
==Examples==
<ol>
<li>The following code audits a thread's parent user number:
<li>The following code audits a thread's parent user number:
<p class="code">audit 'My parent''s user number is ' %(daemon):parentNumber
<p class="code">audit 'My parent&#39;'s user number is ' %(daemon):parentNumber
</p>
</p>
<li>In the following example, a daemon runs a request that creates another daemon. <var>ParentNumber</var>, issued on the first daemon thread, returns the user number of the thread that created the first daemon: the user that runs the request.
<li>The [[MasterNumber (Daemon property)]] returns the same value as the ParentNumber method if the parent thread has no parent. Otherwise, the MasterNumber method follows the chain of parents to the highest level, that is, to the parent that does not have a parent.
<p class="code">begin
<li>An asynchronous $COMMBG daemon or an independent daemon start with the RunIndependently method might have a parent thread but never a master thread; master implies control.  
  %speed is object daemon
<li>The ParentNumber method has a $function equivalent: $daemonParentNumber. The $function and method can be used interchangeably, whether the daemons were created with $COMMxx functions or Daemon objects. That is, the method can also be used with daemons that were created via $COMMxx, and the $function can also be used with daemons that were created via Daemon objects.</ul>
  %list is object stringList
  %s is object stringList
  %speed = new
  %n is float
  %n = %speed:usernumber
  print '1st daemon user number is: ' %n


==Example==
  %list = new
  text to %list
In the following example, a daemon runs a request that creates another daemon. The ParentNumber method, issued on the first daemon thread, returns the user number of the thread that created the first daemon: the user that runs the request.
      begin
        %n1 is float
        %n2 is float
        %n3 is float
        %speed2 is object daemon
        %speed2 = new
        %n1 = %speed2:usernumber
        %n2 = %(Daemon):masternumber
        %n3 = %(Daemon):parentnumber
        print %n1
        print %n2
        print %n3
      end
  end text


<p class="code">Begin
  %x = new
%speed is object daemon
  %x = %speed:run(%list)
%list is object stringList
  print '2nd daemon usernum, 1st daemon master and parent are: '
%X is object stringList
  %x:print
%speed = new
%n is float
%n = %speed:usernumber
Print '1st daemon user number is: ' %n
 
%list = new
text to %list
Begin
%n1 is float
%n2 is float
%n3 is float
%speed2 is object daemon
%speed2 = new
%n1 = %speed2:usernumber
%n2 = %(Daemon):masternumber
%n3 = %(Daemon):parentnumber
print %n1
print %n2
print %n3
end
end text
 
%X = new
%X = %speed:run(%list)
Print '2nd daemon usernum, 1st daemon master and parent are: '
%X:print
end
end
</p>
</p>
The example result follows:
The example result follows:
<p class="code">1st daemon user number is: 3
<p class="code">1st daemon user number is: 3
2nd daemon user num, 1st daemon master and parent are:
2nd daemon user num, 1st daemon master and parent are:
Line 73: Line 70:
18
18
18
18
</p>
</p></ol>


==See also==
==See also==
{{Template:Daemon:ParentNumber footer}}
{{Template:Daemon:ParentNumber footer}}
<ul>
<li>The [[UserNumber (Daemon property)]] returns the user number of the thread associated with the daemon method object.
</ul>

Latest revision as of 00:59, 16 February 2014

User number of the parent thread (Daemon class)

ParentNumber returns the user number of the parent thread, the thread that created the thread from which this method is being invoked.

If the thread issuing the ParentNumber method is not an sdaemon, or is an sdaemon but not working for a Daemon object or a $COMMxx function, the ParentNumber property returns a value of -1.

Syntax

%number = %(Daemon):ParentNumber

Syntax terms

%number A numeric variable to contain the value of the number of the parent thread.
%(Daemon) The class name in parentheses denotes a shared method. ParentNumber can also be invoked via a Daemon object variable, which may be Null.

Usage notes

  • MasterNumber returns the user number of the master thread, the thread that ultimately created and controls the thread from which this method is being invoked. UserNumber returns the user number of the thread associated with the daemon method object.

    MasterNumber returns the same value as the ParentNumber method if the parent thread has no parent. Otherwise, MasterNumber method follows the parent chain to the highest level, that is, to the parent that does not have a parent.

  • An asynchronous $CommBg daemon or an independent daemon start with the RunIndependently method might have a parent thread but never a master thread; master implies control.
  • ParentNumber has a $function equivalent: $DaemonParentNumber. The $function and method can be used interchangeably, whether the daemons were created with $COMMxx functions or Daemon objects. That is, the method can also be used with daemons that were created via $COMMxx functions, and the $function can also be used with daemons that were created via Daemon objects.

Examples

  1. The following code audits a thread's parent user number:

    audit 'My parent''s user number is ' %(daemon):parentNumber

  2. In the following example, a daemon runs a request that creates another daemon. ParentNumber, issued on the first daemon thread, returns the user number of the thread that created the first daemon: the user that runs the request.

    begin %speed is object daemon %list is object stringList %s is object stringList %speed = new %n is float %n = %speed:usernumber print '1st daemon user number is: ' %n %list = new text to %list begin %n1 is float %n2 is float %n3 is float %speed2 is object daemon %speed2 = new %n1 = %speed2:usernumber %n2 = %(Daemon):masternumber %n3 = %(Daemon):parentnumber print %n1 print %n2 print %n3 end end text %x = new %x = %speed:run(%list) print '2nd daemon usernum, 1st daemon master and parent are: ' %x:print end

    The example result follows:

    1st daemon user number is: 3 2nd daemon user num, 1st daemon master and parent are: 5 18 18

See also