HP3000-L Archives

June 2000, Week 3

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:
"Emerson, Tom # El Monte" <[log in to unmask]>
Reply To:
Emerson, Tom # El Monte
Date:
Mon, 19 Jun 2000 17:35:24 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (63 lines)
Don't know about more or less "elegent", but typically [i.e., "in BASIC"] I
would use the "mid$" function and the fact that if the third parameter is
ommitted, it means "until the end of the string".  However, that's BASIC and
we're talking CI here. :)

It turns out the RHT function may yet do this -- from the online help:

:HELP RHT
Syntax:     RHT(str,cnt)

Defn:       A CI evaluator function that performs right string
            extraction. When cnt is positive, the rightmost cnt
            characters are extracted from str.  When cnt is
            negative, the string that is extracted begins at
            the index of the absolute value of cnt.

Type:       String

Example:    rht("abc",2)
Result:     bc
Example:    rht('abcdefg',-3)
Result:     cdefg

It's the second behaviour you want -- a NEGATIVE value STARTS at that
position in the string, so if you KNOW were "xxxxxx" ENDS, use the negative
of that number...

> -----Original Message-----
> From: Donna Garverick [mailto:[log in to unmask]]
> Sent: Monday, June 19, 2000 2:23 PM
> To: [log in to unmask]
> Subject: [HP3000-L] string extract?
>
>
> hi all!
>
> just a ponderment....  i'm working on a mpe script blah blah
> blah and i have a string in the following format: # xxxxxx
> yyyyyyyyyy
> where # is a number
>  xxxxx is something but there are no spaces in it (variable
> length)
>  yyyyyy  is also something but there may or may not be
> spaces in it (variable length)
>
> obviously, using the word function to extract # and xxxxx is
> a piece o'cake.  i'm wondering though about extracting
> yyyyyy.  word isn't going to give me what i want because of
> the possibility of spaces (or other default delimiters).
> currently i'm letting word tell me where xxxxx ends,
> determining the length of the entire string and calculating
> the difference to determine the beginning position of yyyyy
> and it's length.  it certainly works, but is rather low on
> the elegance scale.  any suggestions for something more
> elegant/wonderful?               - d
>
> --
> Donna Garverick     Sr. System Programmer
> 925-210-6631        [log in to unmask]
>
> >>>MY opinions, not Longs Drug Stores'<<<
>

ATOM RSS1 RSS2