[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: RE: [sqr-users] Putting single quotes in a string



Here is a replace that I use and it should work fine for you.  $start_string 
should be your original string, $comma is what you are replacing, $param is 
what you are replacing with and $end_string is what will be the result.  Here 
is my displays after I ran it.

before
abc,def,ghi

after
'abc','def','ghi'




 Procedure Process-Main
     
             let $quote = ''''
             let $comma            = ','
             let $param = $quote || $comma || $quote
             let $start_string = 'abc,def,ghi'
             do replace-string($start_string,$comma,$param,$end_string)
             let $end_string = $quote || $end_string || $quote
    
      End-Procedure  Process-Main
    
    
      begin-procedure replace-string($in1,$inOld, $inNew, :$outStr)
    
         let $outStr          = ''
         let #len             = length($in1)
         let #adj             = length($inOld)
         let #old             = 1
         let #new             = 0
    
         while #new           < #len
            let #new          = instr($in1, $inOld, #old)
            if  #new          = 0
                let #new      = #len + 1
            end-if
            if  #old          < #new
                let $outStr = $outStr || substr($in1, #old, #new - #old)
            end-if
            if  #new          < #len
                let $outStr = $outStr || $inNew
                let #old      = #new + #adj
            end-if
         end-while
    
      End-Procedure replace-string
    




> 
> I have not actually tried it, but maybe you can use the function replace to 
> change all the commas into ','
> 
> 
> >From: "Turner, Ivan" <Ivan.Turner@qwest.com>
> >Reply-To: "This list is for discussion about the SQR database 
> >reportinglanguage from Hyperion Solutions." <sqr-users@sqrug.org>
> >To: <sqr-users@sqrug.org>
> >Subject: [sqr-users] Putting single quotes in a string
> >Date: Wed, 10 Mar 2004 23:13:40 -0600
> >
> >If I have a string:
> >$a = 'abc,def,ghi' as user input
> >
> >How can I make it look like 'abc','def','ghi'?
> >
> >I tried "translate" and can't get it to work.  Does anyone know of a 
> >function available to do this?  Maybe I have to resort to parsing the 
> >string and rebuilding it via hard coded logic.
> >
> >Any suggestions?
> >
> >_______________________________________________
> >sqr-users mailing list
> >sqr-users@sqrug.org
> >http://www.sqrug.org/mailman/listinfo/sqr-users
> 
> _________________________________________________________________
> The new MSN 8: smart spam protection and 2 months FREE*  
> http://join.msn.com/?page=features/junkmail
> 
> 
> _______________________________________________
> sqr-users mailing list
> sqr-users@sqrug.org
> http://www.sqrug.org/mailman/listinfo/sqr-users

Bob Melosi  x5-8427


_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users