previous Chapterpreviousupnextnext Chapter  german   Contents    Index  

11.5 Functions

In order to be able to insert the values of some environment variables during the evaluation process, the Document Generator provides several functions that may be used in entity definitions or templates:

&base(file);
removes path information and extension from the file specification.
Example: &base(/home/bscw/www/faq.dtm); -> faq

&rel(path);
generates a relative path name out of an absolute one. The generated path name is relative to the document that will be generated (set in the evaluation parameter document). Example: If the expression &rel(/Images); is used in a template, that generates the document /faq/index.htm, this expression will be evaluated to ../Images. If one uses the same expression in a template that generates the document /faq/question/install.htm, it will be evaluated to ../../Images.

&size(file, [B|K|M|G]);
returns the size of a file in bytes, kilobytes, megabytes or gigabytes, depending on the value of the second parameter.
Example: &size(/Download/bscw34.exe, M); -> 8.43

&date(format);
returns the current date and time. The following directives may be used in the format string. They are shown here without the optional field width and precision specifications.

Directive   Meaning
%aLocale’s abbreviated weekday name.
%ALocale’s full weekday name.
%bLocale’s abbreviated month name.
%BLocale’s full month name.
%cLocale’s appropriate date and time representation.
%dDay of the month as a decimal number [01, 31].
%HHour (24-hour clock) as a decimal number [00, 23].
%IHour (12-hour clock) as a decimal number [01, 12].
%jDay of the year as a decimal number [001, 366].
%mMonth as a decimal number [01, 12].
%MMinute as a decimal number [00, 59].
%pLocale’s equivalent of either AM or PM.
%SSecond as a decimal number [00, 61].
%UWeek number of the year (Sunday as the first day of the week) as a decimal number [00, 53]. All days of a year preceding the first Sunday belong to week 0.
%wWeekday as a decimal number [0 (Sunday), 6].
%WWeek number of the year (Monday as the first day of the week) as a decimal number [00, 53]. All days of a year preceding the first Monday belong to week 0.
%xLocale’s appropriate date representation.
%XLocale’s appropriate time representation.
%yYear without century as a decimal number [00, 99].
%YYear with century as a decimal number.
%ZTime zone name (or empty string if no time zone exists).
%%The character ‘%’.

Example: On October 10, 2005 the result of &date(%M %Y); is October 2005.


 previous Chapterpreviousupnextnext Chapter  german   Contents    Index