The
extern keyword let users execute a section of code in an external language and include the result of the execution into
Amel code. At the moment, only
Javascript is supported. In order to use this feature, the user includes javascript in an extern amel block and return an object which properties will be included as constants in the amel environment.
Here is an exemple of text rendered through an external language with the
extern keyword.
Amel
@extern:(
var radius = 2;
var surface = Math.PI * Math.pow(radius,2);
return { surface: surface * 2, radius: radius };
)
The surface of a circle with a radius of @radius is @surface.
Result
The surface of a circle with a radius of 2 is 25.132741228718345.
The javascript code has to return an object containing the variables to import in the current environment. Here, we calculate the surface of a circle with a radius of 2.
Here is another exemple of the
extern keyword listing connected volumes on the current system:
Amel
@extern:(
var fs = require( "fs" );
var files = fs.readdirSync( "/Volumes" );
return { file: files.join( "\n- " ), amount: files.length };
)
There are currently @amount storage devices on this computer:
- @file
Result
There are currently 4 storage devices on this computer:
- BOOTCAMP
- Backup
- Home
- MobileBackups