View Single Post
  #2  
Old 09-24-2003, 07:33 PM
eric.zarko eric.zarko is online now
Registered User
 
Join Date: 12-31-1969
Location: CA
Posts: 6
PerlScript support (cont.)

# create a new temporary macro with the value or add a string to end of the given
# temporary macro, separating each string with Tab char delimiter, and return the updated value
sub vbld_AddDelimValue($$)
{
my($macroName, $val) = @_;
my $macros = $Application->Macros(vbldMacroTemporary);
my $macro = $macros->Item($macroName);
if (!defined($macro)) # create initial value if it doesn't exist
{
$macro = $macros->Add($macroName, $val);
}
else # add delimiter and value if already exists
{
$macro->{Value} .= "\t" . $val;
}
return $macro->Value();
}

# given the name of a macro containing delimited strings (populated via
# vbld_AddDelimValue), remove the *first* delimited string from the value
# and return or return Null if the macro does not exist
sub vbld_NextDelimValue($)
{
my($macroName) = @_;
my $macros = $Application->Macros(vbldMacroTemporary);
my $val = undef;
{
my $macro = $macros->Item($macroName);
$val = $macro->Value()
if (defined($macro));
}
return undef
if (!defined($val)); # macro doesn't exist, return null

my $ret;
my $pos = index($val, "\t"); # find next delimiter
if ($pos < 0) # if no more delimiters, return the remaining value
{
$ret = $val;
$macros->Remove($macroName); # and delete the macro
}
else
{
$ret = substr($val, 0, $pos); # retrieve the next value
$macros->Add($macroName, substr($val, $pos+1)); # and remove from the macro
}
return $ret;
}

# alternate name for adding delimited value to end of a macro
sub vbld_PushDelimValue($$)
{
my($macroName, $value) = @_;
return vbld_AddDelimValue($macroName, $value);
}

# given the name of a macro containing delimited strings (populated via
# vbld_AddDelimValue), remove the *last* delimited string from the value
# and return or return Null if the macro does not exist
sub vbld_PopDelimValue($)
{
my($macroName) = @_;
my $macros = $Application->Macros(vbldMacroTemporary);
my $val = undef;
{
my $macro = $macros->Item($macroName);
$val = $macro->Value()
if (defined($macro));
}
return undef
if (!defined($val)); # macro doesn't exist, return null

my $ret;
my $pos = rindex($val, "\t"); # find last delimiter
if ($pos < 0) # if no more delimiters, return the remaining value
{
$ret = $val;
$macros->Remove($macroName); # and delete the macro
}
else
{
$ret = substr($val, $pos+1); # retrieve last delimited value
$macros->Add($macroName, substr($val, 0, $pos));# and remove from the macro
}
return $ret;
}
]]></code>
</script>

************************************************** ********************
The views and opinions expressed in this message are those of the author. The contents of this message have not been reviewed or approved by Intel.
************************************************** ********************
Reply With Quote