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 defi­nitions or templates:

&base(file);     
removes path information and extension from the file specification.      
Example: &base(/home/bscw/www/faq.dtm); results in 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 docu­ment).
Example: If the expression &rel(/Images); is used in a template, that gener­ates the document /faq/index.htm, this expression will be evaluated to ../Images. If one uses the same ex­pression 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); results in 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 specifica­tions.

 

Directive   

Meaning

%a

Locale’s abbreviated weekday name.

%A

Locale’s full weekday name.

%b

Locale’s abbreviated month name.

%B

Locale’s full month name.

%c

Locale’s appropriate date and time representation.

%d

Day of the month as a decimal number [01, 31].

%H

Hour (24-hour clock) as a decimal number [00, 23].

%I

Hour (12-hour clock) as a decimal number [01, 12].

%j

Day of the year as a decimal number [001, 366].

%m

Month as a decimal number [01, 12].

%M

Minute as a decimal number [00, 59].

%p

Locale’s equivalent of either AM or PM.

%S

Second as a decimal number [00, 61].

%U

Week number of the year (Sunday as the first day of the week) as a deci­mal number [00, 53]. All days of a year preceding the first Sunday belong to week 0.

%w

Weekday as a decimal number [0 (Sunday), 6].

%W

Week number of the year (Monday as the first day of the week) as a deci­mal number [00, 53]. All days of a year preceding the first Monday be­long to week 0.

%x

Locale’s appropriate date representation.

%X

Locale’s appropriate time representation.

%y

Year without century as a decimal number [00, 99].

%Y

Year with century as a decimal number.

%Z

Time zone name (or empty string if no time zone exists).

%%

The character ‘%’.

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