APLX Help : Help on APL language : System Functions & Variables : ⎕CALL Call external static method
|
|
|
|
|
The dyadic system function The left argument is a character vector which specifies the external environment in which you want to make the call, in the same format as for For example, the .Net System.DateTime class contains a static property Now which returns the current date and time as an instance of the DateTime class: '.net' ⎕CALL 'System.DateTime.Now'
[.net:DateTime]
TS←'.net' ⎕CALL 'System.DateTime.Now'
TS.ToString
10/10/2007 12:06:42
It also contains a static method IsLeapYear which takes an integer argument representing a year, and returns a Boolean value indicating whether the year is a leap year: '.net' ⎕CALL 'System.DateTime.IsLeapYear' 1994
0
'.net' ⎕CALL 'System.DateTime.IsLeapYear' 1996
1
Similarly, in Java, to create a TimeZone object we need to call a static method in the TimeZone class: tz←java ⎕CALL 'java.util.TimeZone.getTimeZone' 'America/Los_Angeles'
⍝ Does this time zone use daylight savings time?
tz.useDaylightTime
1
⍝ What is the time zone called with and without daylight savings time?
tz.getDisplayName 1 (tz.LONG)
Pacific Daylight Time
tz.getDisplayName 0 (tz.LONG)
Pacific Standard Time
Using a class reference to call static methodsAnother way of calling a static method of an external class is to get a reference to the class itself (usually by calling tzclass←'java' ⎕GETCLASS 'java.util.TimeZone'
tz←tzclass.getTimeZone 'America/Los_Angeles'
|
|
APLX Help : Help on APL language : System Functions & Variables : ⎕CALL Call external static method
|
|
Copyright © 1996-2010 MicroAPL Ltd