#
#	tools.wl
#
#	A toolchest of useful object declarations for WebLord
#	Copyright (c) 1997 Udo K Schuermann
#	All rights reserved
#
text = today		{
	# given the external program 'now' (shipped with WebLord) this object produces a string in the
	# format 'xYYYYmmDDhhMM' which can be used to perform time comparisons as accurately as to a
	# single second or as broadly as the weekday or the month or the current year.
	#    The value is made static (value-is-static) to cause this object to store the value once
	# it has been built the first time; and the 'value-is-static' property is made private to this
	# object (i.e. not inheritable by its children--none in this case);
	#    The value has an '.' in front of it to force string comparison (any non-numeric will do)
	#
	value-is-static	= "1";
	value-in-file	= "1";
	exec		= "now \".%Y%m%d%H%M\" >" unique-file-name;
	value		= unique-file-name;
	file-to-delete	= unique-file-name++;
	exec-cleanup	= delete-file;
}



# given 'file-to-delete' (defined by the parent) the 'delete-file' object deletes the named file in an operating
# system specific manner.
#
text = delete-file	{ if=_OS "=" "AMIGA";	then= "c:delete quiet " file-to-delete;		else=delete-file-2; }
text = delete-file-2	{ if=_OS "=" "WIN32";	then= "del " file-to-delete " >nul:";		else=delete-file-3; }
text = delete-file-3	{ if=_OS "=" "UNIX";	then= "/bin/rm -f " file-to-delete " >/dev/null"; }



# provides 'unique-file-name' and 'unique-file-name++' objects to allow objects to obtain a process-unique file-
# name for temporary storage; the '++' version will afterwards "increment" the unique filename to produce a
# different unique filename when the 'unique-file-name' is used next.
#
text = unique-file-name		{ 			value = unique-file-path-1 unique-id ".wlt"; }
text = unique-file-name++	{ 			value = unique-file-path-1 unique-id++ ".wlt"; }
text = unique-file-path-1	{ if=_OS "=" "AMIGA";	then="t:";	else=unique-file-path-2; }
text = unique-file-path-2	{ if=_OS "=" "WIN32";	then=".\\";	else=unique-file-path-2; }
text = unique-file-path-3	{ if=_OS "=" "UNIX";	then="/var/tmp/"; }



# provides an 'image-url' for IMAGE objects that that assembles filenames based on merely a base name as in the
# following example (the IMAGE object defines 'image-name=BASENAME'):
#	"pix/BASENAME-128x72.gif"
# The path ("pix/") can be defined locally with 'image-path'
# The width ("128"), height ("72") and border ("0") can be defined locally with 'width', 'height', and 'border'
# The image-type ("gif") can be defined locally with 'image-type'
#
# The simplest IMAGE object thus looks like this:	image = myimage{ image-name='Test' }
# and references an image file named			pix/Test-128x72.gif
# 
text = image-size-spec	{ ifdef=width height;	value="-" width "x" height}
text = image-type-spec	{ ifdef=image-type;	value="." image-type}

