The slur can be treated as the accidental see the slightly tidied up clunky code bits
$optVal = rtrim($optVal) ;
$ModOptVal=$optVal; \\new variable to hold stripped optVal
// is there a colour if so strip the colour code
$pgiend = strpos($optVal,'!');
if ($pgiend>0) $ModOptVal = substr($ModOptVal,0,$pgiend);
// is there a slur if so strip the slur code
$pgiend = strpos($optVal,'^');
if ($pgiend>0) $ModOptVal = substr($ModOptVal,0,$pgiend);
// is there an accidental if so remove the accidental
$pgacclist = '\#bnxv';
if (strpbrk($pgacclist,substr($ModOptVal,0,1))) $ModOptVal = substr($ModOptVal,1);
\\ now check for a valid modification using the stripped optVal
switch ($comp)
{
case "<=" : if (!($ModOptVal <= $this->comparesTo[$opt])) return FALSE ; break ;
case "<" : if (!($ModOptVal < $this->comparesTo[$opt])) return FALSE ; break ;
case "==" : if (!($ModOptVal == $this->comparesTo[$opt])) return FALSE ; break ;
case ">=" : if (!($ModOptVal >= $this->comparesTo[$opt])) return FALSE ; break ;
case ">" : if (!($ModOptVal > $this->comparesTo[$opt])) return FALSE ; break ;
case "!=" : if (!($ModOptVal != $this->comparesTo[$opt])) return FALSE ; break ;
}
}
// well, it didn't disqualify itself, so I'd better return TRUE
return TRUE ;
.................
lines skipped
........................
switch ($this->GetAction())
{
case GM_DELETE: break ; // do nothing, as the action is to NOT PRINT
case GM_MOD:
$opts = gm_getTaggedOpt($this->ActionTarget,$o) ;
if ($opts === FALSE && !(in_array($this->ActionMod, array("+=", "-=")))) // if value doesn't exist, can't modify
{
inform("Couldn't perform ".$this->ActionTarget.$this->ActionMod.$this->ActionValue." in " . $o->ReconstructClipText()."\n");
break ;
}
if ($opts == FALSE) $opts = 0; // but we make an exception for += and -=, since 0 is often a default value for these
//is there a colour if so strip the colour code
$pgcolour = '';
$pgbcolour = FALSE;
$pgiend = strpos($opts,'!');
if ($pgiend>0)
{
$pgcolour = substr($opts,$pgiend+1);
$opts = substr($opts,0,$pgiend);
$pgbcolour = TRUE;
}
//is there a slur if so strip the slur code
$pgslur = '';
$pgbslur = FALSE;
$pgiend = strpos($opts,'^');
if ($pgiend>0)
{
$pgslur = substr($opts,$pgiend+1);
$opts = substr($opts,0,$pgiend);
$pgbslur = TRUE;
}
//is there an accidental if so remove the accidental
$pgacclist = '\#bnxv';
$pgbacc = FALSE;
$pgacc = '';
if (strpbrk($pgacclist,substr($opts,0,1)))
{
$pgacc = substr($opts,0,1);
$pgbacc = TRUE;
$opts = substr($opts,1);
}
switch ($this->ActionMod) // now we can do the action
{
case "+=" : $opts += $this->ActionValue ; break ;
case "-=" : $opts -= $this->ActionValue ; break ;
case "*=" : $opts *= $this->ActionValue ; break ;
case "/=" : $opts /= $this->ActionValue ; break ;
}
$opts = (string) round($opts) ; // convert numbers back to string for correct interpretation by ReconstructClipText
if ($pgbacc) $opts = $pgacc.$opts;
if ($pgbcolour) $opts = $opts."!".$pgcolour;
if ($pgbslur) $opts= $opts."^";
gm_setTaggedOpt($this->ActionTarget,$o,$opts) ;
break ;
case GM_SET:
gm_setTaggedOpt($this->ActionTarget,$o,$this->ActionValue) ;
break ;