APLX Help : Help on APL language : System Methods : ⎕VAL Force value result
|
|
|
|
|
Implemented for External classes only. Syntax:
The niladic system method When used on an object which would normally be returned to APL as data, it does nothing; it simply returns the data as normal. Similarly, when used on an object which cannot be converted to simple APL data types, it also does nothing; the object reference is returned. Where In this example, we create an array of three strings in .Net: StringType←'.net' ⎕GETCLASS 'System.String' ⍝ Get Type of System.String
ArrayType←'.net' ⎕GETCLASS 'System.Array' ⍝ Get Type of System.Array
⍝ so we can call static
⍝ method 'CreateInstance'
ArrayType.CreateInstance StringType 3 ⍝ Create array of 3 strings
[NULL OBJECT] [NULL OBJECT] [NULL OBJECT] ⍝ Oops! Array was unboxed
A←ArrayType.CreateInstance.⎕REF StringType 3 ⍝ Keep array as object
A
[.net:String[]] ⍝ Reference to .Net array
A.SetValue 'First Item' 0 ⍝ Insert some values
A.SetValue 'Second Item' 1
A.SetValue 'Third Item' 2
A ⍝ Still a reference
[.net:String[]]
A.⎕VAL ⍝ Unbox array to get contents
First Item Second Item Third Item
⎕DISPLAY A.⎕VAL
┌→────────────────────────────────────────┐
│ ┌→─────────┐ ┌→──────────┐ ┌→─────────┐ │
│ │First Item│ │Second Item│ │Third Item│ │
│ └──────────┘ └───────────┘ └──────────┘ │
└∊────────────────────────────────────────┘
This example in R creates a 'factor' and uses r←'r' ⎕new 'r'
f←r.factor (⊂'abc' 'def' 'abc')
f
[r:factor]
f.⎕val
1 2 1
See also |
|
APLX Help : Help on APL language : System Methods : ⎕VAL Force value result
|
|
Copyright © 1996-2010 MicroAPL Ltd