diff --git a/PROMS/Volian.Controls.Library/DisplayText.cs b/PROMS/Volian.Controls.Library/DisplayText.cs index 39c736c7..56e181a5 100644 --- a/PROMS/Volian.Controls.Library/DisplayText.cs +++ b/PROMS/Volian.Controls.Library/DisplayText.cs @@ -417,12 +417,12 @@ namespace Volian.Controls.Library if (m != null && m.Groups.Count > 7 && m.Groups[7].ToString() == "ReferencedObject") { // if previous processed (next ro) was found, then see if it has an 'and' between it and the previous - if (prevValue != null) - { - int endIndx = m.Index + m.Length; - string tr = text.Substring(endIndx).Replace(@"\v0","").TrimStart(); - if (!tr.ToUpper().StartsWith("AND")) prevValue = null; - } + //if (prevValue != null) + //{ + // int endIndx = m.Index + m.Length; + // string tr = text.Substring(endIndx).Replace(@"\v0","").TrimStart(); + // if (!tr.ToUpper().StartsWith("AND")) prevValue = null; + //} int myIndex = m.Groups[4].Index; int myLength = m.Groups[4].Length; if (m.Groups[3].Value != " ") @@ -441,8 +441,9 @@ namespace Volian.Controls.Library int rodbid = int.Parse(myMatch.Groups[3].Value); ROFstInfo myROFst = _MyItemInfo.MyDocVersion.GetROFst(rodbid); bool isSetpoint=myROFst.IsSetpointDB(dbid, _MyItemInfo.MyDocVersion); - string newvalue = DoROFormatFlags(gg, beforeRO, afterRO, isSetpoint, prevValue); - if (!_MyItemInfo.ActiveFormat.PlantFormat.FormatData.ROData.AllUnits) prevValue = newvalue; + string newvalue1 = DoROFormatFlags(gg, beforeRO, afterRO, isSetpoint); + string newvalue = RemoveMultipleUnits(prevValue, newvalue1); + if (!_MyItemInfo.ActiveFormat.PlantFormat.FormatData.ROData.AllUnits) prevValue = newvalue1; newvalue = DoROReplaceWords(_MyFormat.PlantFormat.FormatData.SectData.ReplaceStrList, newvalue, _MyItemInfo.IsHigh); if (isSetpoint) newvalue = ReplaceSpaceWithHardspace(newvalue); if (gg != newvalue) @@ -1265,7 +1266,7 @@ namespace Volian.Controls.Library // string spaces = @" \u160?"; // return (spaces.IndexOf(ch) >= 0); //} - private string DoROFormatFlags(string roText, string beforeRO, string afterRO, bool isSetpoint, string prevValue) + private string DoROFormatFlags(string roText, string beforeRO, string afterRO, bool isSetpoint) { string rtnstr = roText; // The RO text is being changed to match it's context. Since it is changed in reverse order, the text before the RO @@ -1354,15 +1355,25 @@ namespace Volian.Controls.Library rtnstr = tstr; } + return rtnstr; + } + + private string RemoveMultipleUnits(string prevValue, string rtnstr) + { //In a sequence of RO values, the unit appears with every value //(e.g., "25 gpm and 30 gpm" vs. "25 and 30 gpm") if (!_MyItemInfo.ActiveFormat.PlantFormat.FormatData.ROData.AllUnits && prevValue != null) { string units = null; - Match m = Regex.Match(prevValue, "[^0-9]"); - if (m.Success) + //Match m = Regex.Match(prevValue, "[^0-9]"); + int ind = prevValue.LastIndexOfAny("0123456789".ToCharArray()); + if (ind>=0) { - units = prevValue.Substring(m.Index); + string mynum = prevValue.Substring(0, ind+1); + // Handle Hex characters which are part of the Units such as the degree character + if (Regex.IsMatch(mynum, @".*\\'[A-Fa-f0-9]{2,2}$")) + ind -= 4; + units = prevValue.Substring(ind+1); if (rtnstr.EndsWith(units)) { rtnstr = rtnstr.Replace(units, "");