Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Announcement: Try the Ask AI chatbot for answers to your technical questions about Juniper products and solutions.

close
header-navigation
keyboard_arrow_up
close
keyboard_arrow_left
Automation Scripting User Guide
Table of Contents Expand all
list Table of Contents
file_download PDF
{ "lLangCode": "en", "lName": "English", "lCountryCode": "us", "transcode": "en_US" }
English
keyboard_arrow_right

result

date_range 13-Jan-21

Syntax

content_copy zoom_out_map
result expression;
content_copy zoom_out_map
result { 
  /* body */
}

Description

Define the return value for a function. The value can be a simple scalar value, an XML element or XPath expression, or a set of instructions that emit the value to be returned.

Attributes

result expression

XPath expression defining the return value of the function.

SLAX Example

The following example defines three extension functions, my:size(), my:box-parts(), and my:ark(). The my:ark() function returns a node set containing an <ark> element that encloses the node set returned by the my:box-parts() function. The my:box-parts() function returns a node set containing a <box> element enclosing three <part> child elements. The content of each <part> element is the value returned by the my:size() function. The return value of the my:size() function is the product of the three parameters width, height, and scale.

content_copy zoom_out_map
version 1.1;
ns my  exclude = "http://www.example.com/myfunctions";

function my:size ($x, $y, $scale = 1) {
    result $x * $y * $scale;
}
function my:box-parts ($width, $height, $depth, $scale = 1) {
    result <box> {
        <part count=2> my:size($width, $depth);
        <part count=2> my:size($width, $height);
        <part count=2> my:size($depth, $height);
    }
}
function my:ark () {
    result {
        <ark> {
            copy-of my:box-parts(2.5, 1.5, 1.5);
        }
    }
}
  
match / {
    var $res = my:ark();
    copy-of $res;
}

Release Information

Statement introduced in version 1.1 of the SLAX language, which is supported in Junos OS Release 12.2 and later releases.

footer-navigation