Stripping characters out of fields
Pickering, John (NORBORD)
PICKERIJ@norbord.com
Wed, 6 Oct 1999 12:47:29 -0400
>I'm going to be extracting some information to a non-PowerHouse system
>which can potentially have trouble if certain special characters (mainly
>the # sound) appear in the data.
>
>What's the best way to strip # characters out of data using PH?
>
>My platform is MPE/iX 5.5, PowerHouse 7.09.E. I'll be extracting the
>data using QTP.
The best answer is probably to use Quick rather than Qtp since you can loop
easily through the all of the individual characters in the string looking
for the unacceptable ones. With Qtp you'll have to set yourself a
"reasonable" limit to the number of times the unacceptable character(s) can
occur and hope you never exceed it. Or you'll have to contrive to make Qtp
loop - not hard but ugly. Quick can be wonderfully useful when run in batch
mode if that is what was driving your decision to use Qtp. Use Qtp to
extract the data into a subfile and then process the subfile with Quick just
to get rid of the unwanted characters.
But can version 7.09 Quick read subfiles? I don't remember - 7.09 was so bad
we never used it since it reintroduced all the 6.09 bugs that were fixed in
6.19. Sorry, I'm starting to rant again :-) But maybe it's time to get a
y2k ready version anyway!
Below is a Quick procedure I call from the input procedure to get rid of low
value ascii characters (like horizontal tab and escape). I'll leave it as an
exercise for the reader to change it to remove the # character. If your
string is longer than 50 characters you'll need a couple of other changes
too. And it wouldn't take much to call it from the initialize procedure of a
screen running in a batch job.
TEMP T-REMOVED INT*2
TEMP T-WORK-TEXT CHAR*50
PROCEDURE INTERNAL STRIP-WEIRDIES
BEGIN
; strip out any weird characters
LET T-REMOVED = 0
LET T-WORK-TEXT = FIELDTEXT
FOR 50
IF " " GT T-WORK-TEXT[OCCURRENCE:1]
THEN BEGIN
LET T-WORK-TEXT &
= " " + T-WORK-TEXT[1:OCCURRENCE - 1] &
+ T-WORK-TEXT[OCCURRENCE + 1:50]
LET T-REMOVED = T-REMOVED + 1
END
IF T-REMOVED GT 0
THEN BEGIN
IF "" = T-WORK-TEXT[1:T-REMOVED]
THEN LET FIELDTEXT = T-WORK-TEXT[T-REMOVED + 1:50]
END
END
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Subscribe: "subscribe powerh-l" in message body to majordomo@lists.swau.edu
Unsubscribe: "unsubscribe powerh-l" in message to majordomo@lists.swau.edu
This list is closed, thus to post to the list, you must be a subscriber.