1
General Discussion / Re: Recovery after Windows10 issues
I'd obvisously been more cautious than I remembered. Memory is a fading aptitude for one advancing to the ineveitable...
This section allows you to view all Show Posts made by this member. Note that you can only see Show Posts made in areas you currently have access to.
<?php
/*******************************************************************************
pjgFluteRange.php Version 1.00 based on nwsw_VarDump 1.5
This script will lower/raise notes by an octave until within a defined range
for the amateur flautists this is middle c to four leger lines above the treble clef
HISTORY:
================================================================================
[2010-03-11] Version 1.00: Write new values back to nwc2 taking account of all note
attributes
*******************************************************************************/
require_once("lib/nwc2clips.inc");
$final_exit_value = NWC2RC_SUCCESS ;
$clip = new NWC2Clip('php://stdin');
echo $clip->GetClipHeader()."\n";
foreach ($clip->Items as $item) {
$o = new NWC2ClipItem($item,true);
if ($o->GetObjType() == "Note" && ($t =& $o->GetTaggedOpt("Pos"))) {
// parse the pos option string
if (preg_match('/^([\#bnxv]{0,1})(\-{0,1}[0-9]+)([oxXz]{0,1})(\^{0,1})(\!{0,1}[0-9]{0,1})/',$t,$m)) {
//modify the note positions
while ($m[2]>13) {
$m[2]=$m[2]-7; //reduce by 7s until crtieria reached
}
while ($m[2]<-6) {
$m[2]=$m[2]+7; //increase by 7s until crtieria reached
}
} // end or pregmatch
$t=$m;
}
echo $o->ReconstructClipText()."\n";
unset($o);
}
echo NWC2_ENDCLIP."\n";
exit ($final_exit_value) ;
?>
$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 ;