Help Search Campus Map Directories Webmail Home Alumnae Academics Admission Athletics Student Life Offices & Services Library & Technology News & Events About the College Navigation Bar
MHC Home Using the Document Interface

The .SET Command

Syntax: .SET [Local] [name[=value]]

This command is used to create, modify, and display variables. Please refer to the page on variables for a description of their use.

In its simplest form, the .SET command simply displays all variables that are currently defined. The output is automatically done using the <PRE> paragraph tag:

<!--.set-->

BeginCenter   = <p align=center>
Count         = 3,642
CountLong     = This page has been accessed 3,642 times since April 25, 1998.
CountSince    = April 25, 1998
Date          = Mon Feb 13 02:58:15 EST 2012
DateFmt       = %c
DIVersion     = 20110111101326
DocName       = set.shtml
EndCenter     = </p>
FileBase      = 
HasClientMaps = 0
HasFontSize   = 1
HasFrames     = 0
HasImageMaps  = 1
HasImages     = 1
HasTables     = 1
HTTPHeaders   = 
LastMod       = Tue Jun 11 09:41:19 EDT 2002
NewsMod       = 0
OnCampus      = 0
Referer       = 
SQLJavascript = <SCRIPT language="JavaScript">
<!--
var isNS4 = (navigator.appName=="Netscape")?1:0;
function DI_validate_text_key( event, okchars ) {
	var key = isNS4 ? event.which : event.keyCode;
	if( key < 32 || key >= 255 || key == 127 ) return true;	// control chars
	if( okchars.indexOf(String.fromCharCode(key)) < 0 ) return false;
	return true;
}
function DI_validate_text_blur( obj, label, places, min, max, blank ) {
	if( blank && obj.value=='' ) return true;
	if( isNaN(obj.value) ) {
		alert( DI_fieldname(label,'This field')+' requires a number' );
		return false;
	}
	var num = Number(obj.value);
	if( !isNaN(min) && num<min ) {
		alert( "The minimum value for "+DI_fieldname(label,'this number')+
			" is "+DI_zero_pad(min,places) );
		obj.value=num=min;
	}
	if( !isNaN(max) && num>max ) {
		alert( "The maximum value for "+DI_fieldname(label,'this number')+
			" is "+DI_zero_pad(max,places) );
		obj.value=num=max;
	}
	if( places>=0 ) {
		var p = Math.pow(10,places);
		obj.value = Math.round(num*p)/p;
		if( places>0 )
			obj.value = DI_zero_pad(obj.value,places);
	}
	return true;
}
function DI_zero_pad( num, places ) {
	var s = new String(num);
	if( places>0 ) {
		if( s.indexOf('.')<0 ) s += '.';
		while( s.length-s.indexOf('.') <= places )
			s += '0';
	}
	return s;
}
function DI_textarea_limit( obj, label, evnt, len ) {
	if( evnt && evnt.type=="keypress" ) {
		var key = isNS4 ? evnt.which : evnt.keyCode;
		if( key < 32 || key == 127 ) return true;
	}
	if( obj.value.length >= len ) {
		var msg = "There is a limit of "+len+" characters in "+
			DI_fieldname(label,'this field')+'.';
		if( obj.value.length > len ) msg += " \nYou have entered "+obj.value.length+" so far.";
		alert( msg );
		if( !evnt || evnt.type!="keypress" ) obj.focus();
		return false;
	}
	return true;
}
function DI_fieldname(label,alt) {
	return label!='' ? '"'+label+'"' : alt;
}
// -->
</SCRIPT>

To create a new variable, or modify the contents of an existing variable, specify a name=value:

<!--.set foo="My variable"-->
<!--.echo "foo is set to <B>$foo</B>"-->

foo is set to My variable

To output the value of a variable that already exists, omit the =value part. This is identical to using the .ECHO command:

<!--.set foo="My variable"-->
foo is set to <B><!--.set foo--></B><BR>
foo is set to <B><!--.echo "$foo"--></B><BR>

foo is set to My variable
foo is set to My variable

For a description of the Local parameter, please refer to the section on functions.

You can also create and modify hashes and arrays using this command. See the section on databases for more information:

<!--.
set myarray[0]="zero";
set myarray[1]="one";
set myarray[3]="three";
echo "<P>$&join(' | ','$myarray')";

set myhash{1}="value1";
set myhash{2}="value2";
set myhash{3}="value3";
echo "<FORM>Here's a popup: $&selectlist(choice1,2,hash='$myhash') </FORM>";
-->

zero | one | | three

Here's a popup:

Notice how an empty slot was automatically created in the array at index [2] when index [3] was assigned.

----------------------------------------

Home | Directories | Web Email | Calendar | Campus Map | Search | Help

About the College | Admission | Academics | Student Life | Athletics
Offices & Services | Giving | News & Events | Alumnae | Library & Technology

Copyright © 2002 Mount Holyoke College. This page created by the OIS Operations Group and maintained by Webmaster. Last modified on June 11, 2002.