Difference between revisions of "IsHandle"

 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[Category:Data Type Functions]]
 
[[Category:Data Type Functions]]
''New to [[What's new in Analytica 4.2?|Analytica 4.2]]''
 
 
= IsHandle( X'', local'') =
 
  
 +
== IsHandle(X'', local'') ==
 
[[IsHandle]](X) tests whether the value in «X» is a [[handle]].  When «X» is array-valued, it tests whether each cell of the array contains a handle.   
 
[[IsHandle]](X) tests whether the value in «X» is a [[handle]].  When «X» is array-valued, it tests whether each cell of the array contains a handle.   
  
[[IsHandle]](X,local:true) tests whether a local variable «X» contains a [[handle]].  This form doesn't resolve «X» to its value, and really the only way to tell whether a local variable is acting as an alias of another object.  When «X» is something other than the name of a local variable, the optional ''local'' parameter has no effect.
+
[[IsHandle]](X, local: true) tests whether a local variable «X» contains a [[handle]].  This form doesn't resolve «X» to its value, and really the only way to tell whether a local variable is acting as an alias of another object.  When «X» is something other than the name of a local variable, the optional «local» parameter has no effect.
 
 
= Library =
 
  
 +
== Library ==
 
Special
 
Special
  
= Examples =
+
== Examples ==
 
 
 
For the examples, assume these global variables are defined as follows:
 
For the examples, assume these global variables are defined as follows:
 +
:<code>Index I := [1, 2, 3, 4]</code>
 +
:<code>Variable hI := Handle(I)</code>
 +
:<code>Variable B := Table(I)(0, Null, hI, Handle(hI))</code>
  
Index I := [1,2,3,4]
+
:<code>IsHandle(I) &rarr; [0, 0, 0, 0] { ''Indexed by I'' }</code>
Variable hI := [[Handle]](I)
+
:<code>IsHandle(hI) &rarr; 1</code>
Variable B := [[Table]](I)(0,[[Null]],hI,Handle(hI))
+
:<code>IsHandle(B) &rarr; [0, 0, 1, 1] { ''Indexed by I; local: true has no effect when «X» is not a local variable'' }</code>
 
+
:<code>IsHandle(I, local: true) &rarr; [0, 0, 0, 0] { ''Indexed by I'' }</code>
[[IsHandle]](I) &rarr; [0,0,0,0] ''indexed by I''
+
:<code>IsHandle(hI, local: true) &rarr; 1</code>
[[IsHandle]](hI) &rarr; 1
+
:<code>IsHandle(B, local: true) &rarr; [0, 0, 1, 1] { ''Indexed by I'' }</code>
[[IsHandle]](B) &rarr; [0,0,1,1] ''indexed by ''I''
 
{ Note: local:true has no effect when «X» is not a local variable: }
 
[[IsHandle]](I,local:true) &rarr; [0,0,0,0] ''indexed by I''
 
[[IsHandle]](hI,local:true) &rarr; 1
 
[[IsHandle]](B,local:true) &rarr; [0,0,1,1] ''indexed by ''I''
 
 
 
[[Var..Do|Var]] x := I Do [[IsHandle]](x) &rarr; [0,0,0,0] ''indexed by I''
 
[[Var..Do|Var]] x := I Do [[IsHandle]](x,local:true) &rarr; 0
 
[[Var..Do|Var]] x := [[Handle]](I) Do [[IsHandle]](x) &rarr; [0,0,0,0] ''indexed by I''
 
[[Var..Do|Var]] x := [[Handle]](I) Do [[IsHandle]](x,local:true) &rarr; 1
 
[[Var..Do|Var]] x := hI Do [[IsHandle]](x) &rarr; [0,0,0,0] ''indexed by I''
 
[[Var..Do|Var]] x := hI Do [[IsHandle]](x,local:true) &rarr; 1
 
[[Var..Do|Var]] x := B Do [[IsHandle]](x) &rarr; [0,0,1,1] ''indexed by I''
 
[[Var..Do|Var]] x := B Do [[IsHandle]](x,local:true) &rarr; 0
 
  
[[LocalAlias..Do|LocalAlias]] x := I Do [[IsHandle]](x) &rarr; [0,0,0,0] ''indexed by I''
+
:<code>Var x := I Do IsHandle(x) &rarr; [0, 0, 0, 0] { ''Indexed by I'' }</code>
[[LocalAlias..Do|LocalAlias]] x := I Do [[IsHandle]](x,local:true) &rarr; 0
+
:<code>Var x := I Do IsHandle(x, local: true) &rarr; 0</code>
[[LocalAlias..Do|LocalAlias]] x := [[Handle]](I) Do [[IsHandle]](x) &rarr; [0,0,0,0] ''indexed by I''
+
:<code>Var x := Handle(I) Do IsHandle(x) &rarr; [0, 0, 0, 0] { ''Indexed by I'' }</code>
[[LocalAlias..Do|LocalAlias]] x := [[Handle]](I) Do [[IsHandle]](x,local:true) &rarr; 1
+
:<code>Var x := Handle(I) Do IsHandle(x, local: true) &rarr; 1</code>
[[LocalAlias..Do|LocalAlias]] x := hI Do [[IsHandle]](x) &rarr; [0,0,0,0] ''indexed by I''
+
:<code>Var x := hI Do IsHandle(x) &rarr; [0, 0, 0, 0] { ''Indexed by I'' }</code>
[[LocalAlias..Do|LocalAlias]] x := hI Do [[IsHandle]](x,local:true) &rarr; 1
+
:<code>Var x := hI Do IsHandle(x, local: true) &rarr; 1</code>
[[LocalAlias..Do|LocalAlias]] x := B Do [[IsHandle]](x) &rarr; [0,0,1,1] ''indexed by I''
+
:<code>Var x := B Do IsHandle(x) &rarr; [0, 0, 1, 1] { ''Indexed by I'' }</code>
[[LocalAlias..Do|LocalAlias]] x := B Do [[IsHandle]](x,local:true) &rarr; 0
+
:<code>Var x := B Do IsHandle(x, local: true) &rarr; 0</code>
  
[[MetaVar..Do|MetaVar]] x := I Do [[IsHandle]](x) &rarr; [0,0,0,0] ''indexed by I''
+
:<code>LocalAlias x := I Do IsHandle(x) &rarr; [0, 0, 0, 0] { ''Indexed by I'' }</code>
[[MetaVar..Do|MetaVar]] x := I Do [[IsHandle]](x,local:true) &rarr; 0
+
:<code>LocalAlias x := I Do IsHandle(x, local: true) &rarr; 0</code>
[[MetaVar..Do|MetaVar]] x := [[Handle]](I) Do [[IsHandle]](x) &rarr; 1
+
:<code>LocalAlias x := Handle(I) Do IsHandle(x) &rarr; [0, 0, 0, 0] { ''Indexed by I'' } </code>
[[MetaVar..Do|MetaVar]] x := [[Handle]](I) Do [[IsHandle]](x,local:true) &rarr; 1
+
:<code>LocalAlias x := Handle(I) Do IsHandle(x, local: true) &rarr; 1</code>
[[MetaVar..Do|MetaVar]] x := hI Do [[IsHandle]](x) &rarr; 1
+
:<code>LocalAlias x := hI Do IsHandle(x) &rarr; [0, 0, 0, 0] { ''Indexed by I'' }</code>
[[MetaVar..Do|MetaVar]] x := hI Do [[IsHandle]](x,local:true) &rarr; 1
+
:<code>LocalAlias x := hI Do IsHandle(x, local: true) &rarr; 1</code>
[[MetaVar..Do|MetaVar]] x := B Do [[IsHandle]](x) &rarr; [0,0,1,1] ''indexed by I''
+
:<code>LocalAlias x := B Do IsHandle(x) &rarr; [0, 0, 1, 1] { ''Indexed by I'' }</code>
[[MetaVar..Do|MetaVar]] x := B Do [[IsHandle]](x,local:true) &rarr; 0
+
:<code>LocalAlias x := B Do IsHandle(x, local: true) &rarr; 0</code>
  
[[Index..Do|Index]] J := 1..5 Do [[IsHandle]](J) &rarr; [0,0,0,0,0] ''indexed by J''
+
:<code>MetaVar x := I Do IsHandle(x) &rarr; [0, 0, 0, 0] { ''Indexed by I'' }</code>
[[Index..Do|Index]] J := 1..5 Do [[IsHandle]](J,local:true) &rarr; 1
+
:<code>MetaVar x := I Do IsHandle(x, local: true) &rarr; 0</code>
[[MetaIndex..Do|MetaIndex]] J := [0,[[Null]],hI,[[Handle]](I)] Do [[IsHandle]](J) &rarr; [0,0,1,1] ''indexed by J''
+
:<code>MetaVar x := Handle(I) Do IsHandle(x) &rarr; 1</code>
[[MetaIndex..Do|MetaIndex]] J := [0,[[Null]],hI,[[Handle]](I)] Do [[IsHandle]](J,local:true) &rarr; 1
+
:<code>MetaVar x := Handle(I) Do IsHandle(x, local: true) &rarr; 1</code>
 +
:<code>MetaVar x := hI Do IsHandle(x) &rarr; 1</code>
 +
:<code>MetaVar x := hI Do IsHandle(x, local: true) &rarr; 1</code>
 +
:<code>MetaVar x := B Do IsHandle(x) &rarr; [0, 0, 1, 1] { ''Indexed by I'' }</code>
 +
:<code>MetaVar x := B Do IsHandle(x, local: true) &rarr; 0</code>
  
[[Function]] F(X:Variable) := [[IsHandle]](X,local:true) &rarr; 1 {always}
+
:<code>Index J := 1..5 Do IsHandle(J) &rarr; [0, 0, 0, 0, 0] { ''Indexed by J'' }</code>
[[Function]] F(X:Object)  := [[IsHandle]](X,local:true) &rarr; 1 {always}
+
:<code>Index J := 1..5 Do IsHandle(J, local: true) &rarr; 1</code>
 +
:<code>MetaIndex J := [0, Null, hI, Handle(I)] Do IsHandle(J) &rarr; [0, 0, 1, 1] { ''Indexed by J'' }</code>
 +
:<code>MetaIndex J := [0, Null, hI, Handle(I)] Do IsHandle(J, local: true) &rarr; 1</code>
  
= See Also =
+
:<code>Function F(X: Variable) := IsHandle(X, local: true)  &rarr; 1 { always }</code>
 +
:<code>Function F(X: Object)  := IsHandle(X, local: true)  &rarr; 1 { always }</code>
  
 +
== See Also ==
 
* [[Data Type Functions]]
 
* [[Data Type Functions]]
* [[Var..Do]], [[MetaVar..Do]], [[LocalAlias..Do]]
+
* [[Var..Do]]
 +
* [[MetaVar..Do]]
 +
* [[LocalAlias..Do]]
 
* [[Handle Functions]]
 
* [[Handle Functions]]

Latest revision as of 04:40, 22 January 2016


IsHandle(X, local)

IsHandle(X) tests whether the value in «X» is a handle. When «X» is array-valued, it tests whether each cell of the array contains a handle.

IsHandle(X, local: true) tests whether a local variable «X» contains a handle. This form doesn't resolve «X» to its value, and really the only way to tell whether a local variable is acting as an alias of another object. When «X» is something other than the name of a local variable, the optional «local» parameter has no effect.

Library

Special

Examples

For the examples, assume these global variables are defined as follows:

Index I := [1, 2, 3, 4]
Variable hI := Handle(I)
Variable B := Table(I)(0, Null, hI, Handle(hI))
IsHandle(I) → [0, 0, 0, 0] { Indexed by I }
IsHandle(hI) → 1
IsHandle(B) → [0, 0, 1, 1] { Indexed by I; local: true has no effect when «X» is not a local variable }
IsHandle(I, local: true) → [0, 0, 0, 0] { Indexed by I }
IsHandle(hI, local: true) → 1
IsHandle(B, local: true) → [0, 0, 1, 1] { Indexed by I }
Var x := I Do IsHandle(x) → [0, 0, 0, 0] { Indexed by I }
Var x := I Do IsHandle(x, local: true) → 0
Var x := Handle(I) Do IsHandle(x) → [0, 0, 0, 0] { Indexed by I }
Var x := Handle(I) Do IsHandle(x, local: true) → 1
Var x := hI Do IsHandle(x) → [0, 0, 0, 0] { Indexed by I }
Var x := hI Do IsHandle(x, local: true) → 1
Var x := B Do IsHandle(x) → [0, 0, 1, 1] { Indexed by I }
Var x := B Do IsHandle(x, local: true) → 0
LocalAlias x := I Do IsHandle(x) → [0, 0, 0, 0] { Indexed by I }
LocalAlias x := I Do IsHandle(x, local: true) → 0
LocalAlias x := Handle(I) Do IsHandle(x) → [0, 0, 0, 0] { Indexed by I }
LocalAlias x := Handle(I) Do IsHandle(x, local: true) → 1
LocalAlias x := hI Do IsHandle(x) → [0, 0, 0, 0] { Indexed by I }
LocalAlias x := hI Do IsHandle(x, local: true) → 1
LocalAlias x := B Do IsHandle(x) → [0, 0, 1, 1] { Indexed by I }
LocalAlias x := B Do IsHandle(x, local: true) → 0
MetaVar x := I Do IsHandle(x) → [0, 0, 0, 0] { Indexed by I }
MetaVar x := I Do IsHandle(x, local: true) → 0
MetaVar x := Handle(I) Do IsHandle(x) → 1
MetaVar x := Handle(I) Do IsHandle(x, local: true) → 1
MetaVar x := hI Do IsHandle(x) → 1
MetaVar x := hI Do IsHandle(x, local: true) → 1
MetaVar x := B Do IsHandle(x) → [0, 0, 1, 1] { Indexed by I }
MetaVar x := B Do IsHandle(x, local: true) → 0
Index J := 1..5 Do IsHandle(J) → [0, 0, 0, 0, 0] { Indexed by J }
Index J := 1..5 Do IsHandle(J, local: true) → 1
MetaIndex J := [0, Null, hI, Handle(I)] Do IsHandle(J) → [0, 0, 1, 1] { Indexed by J }
MetaIndex J := [0, Null, hI, Handle(I)] Do IsHandle(J, local: true) → 1
Function F(X: Variable) := IsHandle(X, local: true) → 1 { always }
Function F(X: Object) := IsHandle(X, local: true) → 1 { always }

See Also

Comments


You are not allowed to post comments.