[Thread Prev][Thread Next][Index]

Re: [ferret_users] blank symbol



Hi Mark, Ansley & Andrew,
                           There is one more way to do manipulate strings:
using Linux commands within Ferret, invoked using spawn. The advantage with
this method is that, you will have access to all the options provided for 
the linux command......a handfull of them indeed! A simple example using 
"sed" is given below : search for blank spaces, and remove it.

      let a = "a"
      let b = ""
      let c = "c"
      let d = a + b + c 

      let cc = {spawn: "echo `d` | sed -e 's/ //g'"}

      list cc 

This method will work just fine with b = "" or b = " "

Regards,

Jaison

On Mon, 17 Sep 2007, Jaison Kurian wrote:

> Hi Mark,
>           The PPL string editing using $EDIT have the following options
> (see Ch7 Sec9.  PLOT+ STRING EDITING TOOLS and Appendix B Sec7.8.1  $EDIT).
> The command syntax is 
> 
>     SET sym_out $EDIT (sym_in, arg1 [ arg2 arg3...] ) 
> 
> where, arg1 can be
> 
>     UPCASE   - changes string in sym_in to upper case
>     TRIM     - trims leading and trailing blanks from sym_in
>     COMPRESS - removes extra blanks from sym_in (reduces each group 
>                      of blanks to a single blank)
>     COLLAPSE - removes all blanks from sym_in 
> 
> So the answer to your question is "COLLAPSE". Here is a modified version
> of your example :
> 
>        def sym a  a
>        def sym b  ""
>        def sym c  c
>        def sym d  ($a)($b)($c)
> 
>        show sym d
> 
>        ppl set e  $EDIT (d, COLLAPSE)  ! no $ sign required for "d"
> 
>        show sym e
> 
> Ferret also offer few direct string editing tools which are listed in
> Ch7 Sec2.  STRING FUNCTIONS. An example using string addition utility is
> shown below:
> 
>        let a = "a"
>        let b = ""
>        let c = "c"
>        let d = a + b + c
> 
>        say "d = `d`"
> 
> However, with b = " ", this method will fail (but will work fine with 
> symbol example shown first).
> 
> Hope this helps....
> 
> Regards,
> 
> Jaison
>  
> 
> On Mon, 17 Sep 2007 Mark.Collier@xxxxxxxx wrote:
> 
> > Hi Group,
> > 
> >  
> > 
> > If I:
> > 
> >  
> > 
> > yes? def sym a a
> > 
> > yes? def sym b b
> > 
> > yes? def sym c c
> > 
> > yes? def sym d ($a)($b)($c)
> > 
> > yes? show sym d
> > 
> > D = "abc"
> > 
> >  
> > 
> > However, if I define a blank symbol b like:
> > 
> >  
> > 
> > yes? def sym a a
> > 
> > yes? def sym b ""
> > 
> > yes? def sym c c
> > 
> > yes? def sym d ($a)($b)($c)
> > 
> > yes? show sym d
> > 
> > D = "a c"
> > 
> >  
> > 
> > Is it possible for the blank symbol to not take up any characters and
> > produce "ac" automatically?
> > 
> > Regards,
> > 
> > Mark.
> > 
> > 
> > 
> 
> 

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



[Thread Prev][Thread Next][Index]

Contact Us
Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement