Interfaces/VBScript/ex1

From J Wiki
Jump to navigation Jump to search
WScript.Echo "== Example 1 =="

Dim A1: A1 = Array(1.1, 1.2, 1.3)

' pass an array
r = j.Set("A1", A1)

' see that the array is boxed
WScript.Echo("   $A1" & vbCrLf & DoR("$A1"))
WScript.Echo("   A1"  & vbCrLf & DoR("A1"))

' unbox the array
j.Do "A2=: >A1"

' see unboxed array
WScript.Echo("   $A2" & vbCrLf & DoR("$A2"))
WScript.Echo("   A2"  & vbCrLf & DoR("A2"))

' calc result
j.Do "B2=: +/\A2"

' box
j.Do "B1=: <""0 B2"

' fetch result
Dim B2: r = j.Get("B1", B2)

' print result
WScript.Echo "   Result:"
WScript.Echo Join(B2, ",")