Variable - class representing a session variable
Steven J. McDowall <sjm@aptest.com>
Copyright 2002-2011 Applied Testing and Technology, Inc. All Rights Reserved.
use Variable; create a new Variable object my $sess = new Variable("variable name"); set it's title $sess-E<gt>title("A sample session");
The Variable object contains all important information and accesors about one particular variable (i.e. option) defined within the framework. This object is normally used in conjunction with the the VariableSet object that organizes and manipulates the set of options for a whole test suite.
the name of the option
$var = new Variable(name);
Creates a new option object, optionally specifying its several parameters:
the name of the option
returns a reference to the Variable object.
$var->release();
This method undefines the data structures associated with the option.
$var->print():
$var->addOption( VarOption );
$var->derivedfromString( token-string ) ;
$value = $var->callDerivedFunc(varHash);
varHash is a hash of other variables and their values.
Returns the return value of the deriving function.
$var->format_field([current]);
current is a reference to the current value(s) for this item. It will be a scalar (string) or a reference to an array (for list selection items).
returns an html formatted selection item in two table cells, suitable for use in a table row.
$var->title(); $var->title(value);
returns the title description.
$label = $var->label();
$var->name(); $var->name(fieldName);
returns a string containing the name of the option, or undef if the name is not defined.
$str = $var->asHtml( value ) ;
$stat = $var->isDate() ;
Returns 1 if the field is date only, 2 if it is a date/time field, and 0 if it is neither.
$stat = $var->isGraphable() ;
$stat = $var->isList() ;
$field->isNumber() ;
Returns true if it is numeric, and false if it is not.
$field->isRange();
$type = $var->type( type ) ;
$evaltype = $var->evaltype( evaltype ) ;
$class = $var->class( class ) ;
$var->addOptions( values );
values is a comma-separated list of values. Each value may be preceded by an asterisk, in which case it is a default value. Each value may also be followed by space-separated list of one or more values from a "dependsOn" field, enclosed in braces. E.g.,:
*value1,value2,value3{oval oval2 oval3}
Sets up option objects for each value.
$var->setSize(size);
size is a scalar that acts as the height for a menu, or the maximum length for a text string. In the case of a textarea, it is two values separated by an 'x'.
$var->setFlags(flaglist);
Takes a comma-separated list of flags, and sets those flags in the object. If a flag has an = after it, use the value after it as the value. Otherwise set the flag to true.
$str = $var->getFlags();
$state = $var->readonly();
$state = $var->ordered();
$state = $var->hidden() ;
$default = $var->default() ;
$state = $var->setByAccount() ;
$sql_type = $field->SQL_type() ;
Returns a string that can be used to define this field in a SQL table.
$field->SQL_value(value)
Returns a value that is ready for insertion into a SQL store. Currently only converts date or datetime into a SQL friendly date format.
$state = $var->suppress() ;
$state = $var->mandatory() ;
$len = $var->maxlen() ;
$state = $var->required() ;
$width = $var->width() ;
$height = $var->height() ;
$state = $var->graphable() ;
$state = $var->selectable() ;
@list = $var->optionList() ;
@list = $var->descsList() ;
@list = $var->valuesList() ;
$desc = $var->descOf($value) ;
Returns the associated description if the variable is a list. If value if a reference to an array, then returns a reference to an array of descriptions.
$state = $var->derivedwhen() ;
$func = $var->derivedfunc() ;
$state = $var->derifedfrom() ;
$dep = $var->dependson() ;
$option = new Variable::VarOption(value, title, selected, deps, obsolete);
$state = $option->val() ;
$title = $option->title() ;
$state = $option->selected() ;
$deps = $option->dependencies() ;
$obs = $option->isObsolete(); $obs = $option->isObsolete( 1 );
Copyright © 2000-2013 Applied Testing and Technology, Inc. All rights reserved.