HP3000-L Archives

October 2003, Week 2

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Olav Kappert <[log in to unmask]>
Reply To:
Olav Kappert <[log in to unmask]>
Date:
Tue, 14 Oct 2003 14:10:39 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (86 lines)
Robert:

I guess it depends if you want the information in the quotes or not.

Let's assume that the information in the quotes is not needed.

 From the top of my head, the logic would go something like the following:

set position of quote_type to -1.
while (position of quote_type is not zero) do
    find the position of a single_quote.
    find the position of a double_quote.
    if (single_quote is less than double_quote and single_quote is not
zero) or
       (single_quote is not zero and double_quote is zero) then
           replace the position of single_quote with "~".
           set quote_type to single.
    else
    if (double_quote is less than single_quote and double_quote is not
zero) or
       (double_quote is not zero and single_quote is zero) then
           replace the position of double_quote with "~".
           set quote_type to double.
    find position of next quote_type.
    if position of next quote_type is > zero then
        replace all characters from position of first quote_type to
position of next quote_type with spaces.
        find the position of a single_quote.
        find the position of a double_quote.
        set position of quote_type to position of single_quote +
position of double_quote.
    else
        set position of quote_type to 0.
        print error "no terminating quote found".
endwhile.

hope this helps.


Olav Kappert.
IOMIT International (HP Application Development Specialist).



Schlosser, Robert J wrote:

>I have been asked to post this to the list:
>
>Robert Schlosser _ MPE-CSM
>Ochsner Health Plan
>(504) 219-8134
>
>
>
>I have a need to scan several lines of JCL some of which may include either single or double quotes, and some of which may not appear in pairs. The commonest example being the appearance of an apostrophe. THis can be made to work provided it is
>not, itself, in a string delimited by double quotes.
>
>The problem is that any of the standard ways of cleaning up a line before processing it don't work! Things I've tried include:
>
>setvar s "Here's an example of a string with a single quote in it!   "
>echo !s
>setvar s3 repl(!s,"'"," ") These work fine for a string with ONLY a single instance of a single quote - we can use the double quotes to surround it.
>
>However, put it in a pair of double quotes, and it doesn't work!  (Similarly for any line with both types of quotes!)
>
>setvar s3 '"'+"!s"+'"'
>calc pos(!s3,"'") returns 0, rather than 6!
>calc pos("!s3","'") has unmatched quotes
>calc pos('!s3',"'") has unmatched quotes, and so on!
>
>
>Now - granted the number of times this is likely to happen is very small, but I have no way of knowning prior to testing, if a line will contain single quotes or double quotes and in what sort of combination.
>
>Bottom line question is - how can I safely process any combination and sequence of single and double quotes in a string, using the only MPE parsing functions?
>
>Tony Furnivall
>
>* To join/leave the list, search archives, change list settings, *
>* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
>
>
>

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2