Due to a vendor requirement, I need to add a ~ symbol if the OBX segment will be greater than 255 characters. The interface then rmeoves this character (does not print it in the end). My thought is to put the ~ after each period (.) character to ensure it's there in longer segments, as they are part of a report, and vary in length. This is the suggestion given by the vendor stated earlier.
So my question is, how do I do this? I tried some of the suggested links and came up with this:
// Get a count of all OBX fields
var obxArray = message.GetAllNodes('OBX-5');
// Iterate through each
for (var i=0; i < obxArray.length; i++) {
var obx5 = '' + obxArray[i]; // Get current value of the OBX-5 segment on the OBX line we're on
message.setNode('OBX-5', StringUtils.replace(obx5, '.' , '.~' ));
}
The idea is that if OBX-5 had a sentence such as the following:
This is the sentence that would be contained in the mentioned field. Since we don't know how long it might be, we'd like to add the tilde after each period. That will ensure the length will not cause a problem, per the vendor's statement.
After would look like:
This is the sentence that would be contained in the mentioned field.~ Since we don't know how long it might be, we'd like to add the tilde after each period.~ That will ensure the length will not cause a problem, per the vendor's statement.~
This however is giving me rather strange results, as it is injecting the value of the last OBX-5 segment into the first OBX-5 segment, and replacing nothing. Since I'm treating the two characters I'm looking to replace as strings, I don't think I'm triggering a special function.