The following code example calls up the "addvector" function and adds five to each element of the "vect"
variables:
new vect[3] = [ 1, 2, 3 ]
addvector(vect, [5, 5, 5], 3)
/* vect[] now comprises the values 6, 7 and 8 */
13.4.7.2 Named parameters versus fixed parameters
In the previous examples, the order of the parameters in a function call were important as each parameter
was copied to the same position of the function parameter. For example, in the "weekday" function (defined
below), the expression "weekday(12 ,31, 1999)" would be used to get the weekday of the last day of the last
century.
weekday(month, day, year)
{
/* returns the day of the week: 0=Saturday, 1=Sunday, etc. */
if (month <= 2)
month += 12, --year
new j = year % 100
new e = year / 100
return (day + (month+1)*26/10 + j + j/4 + e/4 - 2*e) % 7
}
The date format changes depending on the culture and country, while the USA use the month/day/year
format, European countries frequently use the day/month/year format and technical publications use the
year/month/day (ISO/IEC 8824) format. In other words, the sequence of the parameters is not "standardised"
or "normal". For this reason, there is an alternative way of transferring parameters to a function, by using
"named parameters". These are illustrated in the next example (the function was declared in the same way as
the previous example).
new wkday1 = weekday( .month = 12, .day = 31, .year = 1999)
new wkday2 = weekday( .day = 31, .month = 12, .year = 1999)
new wkday3 = weekday( .year = 1999, .month = 12, .day = 31)
In "named parameters", a dot (".") precedes the name of the argument. The argument of the function can be
set to any expression that is valid for the argument. In the event of a named parameter, the equals sign ("=")
does not refer to an allocation but instead links the expression with a function argument.
Fixed and named parameters can be mixed together, although the fixed parameters must be specified before
the named parameters.
13.4.7.3 Standard values of function arguments
A function argument can have a standard value. The standard value of a function argument must be a
constant. To specify a standard value, add an equals sign ("=") and the value to the name of the parameter.
The standard value is adopted if a placeholder is specified instead of a valid function parameter during a
function call. The placeholder is the underscore character ("_"). The argument placeholder is only valid for
parameters with a standard value.
The right argument placeholders can be removed from the list of arguments.
230
Rev. 05
Summary of Contents for myDatalogEASY V3
Page 2: ......
Page 13: ...Chapter 2 Declaration of conformity Chapter 2 Declaration of conformity Rev 05 13 ...
Page 14: ......
Page 42: ......
Page 76: ......
Page 88: ......
Page 102: ......
Page 110: ......
Page 116: ......
Page 234: ......
Page 244: ......
Page 252: ......
Page 254: ......
Page 266: ......
Page 276: ......