ParentNumber (Daemon property): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 1: Line 1:
<span style="font-size:120%"><b>Thread number of submitting session.</b></span>
{{Template:Daemon:ParentNumber subtitle}}


ParentNumber is a member of the [[Daemon class]]
ParentNumber is a member of the [[Daemon class]]
Line 9: Line 9:
ParentNumber, new as of ''[[Sirius Mods]]'' Version 6.8, takes no arguments and returns a numeric value.
ParentNumber, new as of ''[[Sirius Mods]]'' Version 6.8, takes no arguments and returns a numeric value.


==ParentNumber Syntax==
==Syntax==
<pre>
{{Template:Daemon:ParentNumber syntax}}
%num = %(Daemon):ParentNumber
===Syntax terms===
</pre>
 
===Syntax Terms===
<dl>
<dl>
<dt><i>%num</i>  
<dt><i>%num</i>  
Line 21: Line 18:
<dd>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]]_. </dl>
<dd>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]]_. </dl>


==Usage Notes==
==Usage notes==
<ul>
<ul>
<li>The following code audits a thread's parent user number:
<li>The following code audits a thread's parent user number:
Line 80: Line 77:
</pre>
</pre>


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

Revision as of 04:53, 7 February 2011

User number of the parent thread (Daemon class)


ParentNumber is a member of the Daemon class

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 -1.

ParentNumber, new as of Sirius Mods Version 6.8, takes no arguments and returns a numeric value.

Syntax

%number = %(Daemon):ParentNumber

Syntax terms

%num
A numeric variable to contain the value of the number of the parent thread.
%(Daemon)
The class name in parentheses denotes a shared method. Specifying %(Daemon): is not the only way to invoke the method (see Daemon class_.

Usage notes

  • The following code audits a thread's parent user number:
    audit 'My parent''s user number is ' %(daemon):parentNumber
    
  • 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.
  • 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.
  • 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.

Example

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
%speed is object daemon
%list is object stringList
%X 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