Sv: Converting string characters in QTP

Ole Hansen, ScanConsult oh@scanconsult.dk
Wed, 17 Oct 2001 11:16:09 +0200


String substitutions are nasty in PowerHouse and as demonstrated ecpecially nasty in QTP/QUIZ, so maybe we should take the opportunity to ask Cognos to consider a new function in PowerHouse, e.g.

REPLACE(original-string,search-string,replace-string)

When we had a similar problem (with Danish special characters), we made a subfile and converted its records with a Pascal program, and accessed the converted subfile from QUIZ. The whole 3-stage process was put in a jobfile and executed on-line.

/Ole Hansen

====================================================================
E-mail: oh@scanconsult.dk                Cell Phone: +45 40 40 11 50
====================================================================
ScanConsult IT-Partners ApS                Voice   : +45 87 38 74 74
Jegstrupvej 96A                            Fax     : +45 87 38 74 75
DK-8361 Hasselager                  Support : support@scanconsult.dk
Denmark                             Sales   :   sales@scanconsult.dk
                     http://www.scanconsult.dk
===     ParaSuite :  A Suite of Air Cargo Handling solutions     ===
===     ParaSafe  :  A Suite of IT-Security solutions            ===
===  We partner with  Hewlett-Packard, Cognos, Lotus and others  ===

-----Oprindelig meddelelse-----
Fra: Chris Sharman <chris.sharman@ccagroup.co.uk>
Til: Lemin, Graeme <graeme.lemin@team.telstra.com>; powerh-l@lists.swau.edu <powerh-l@lists.swau.edu>
Dato: 17. oktober 2001 10:05
Emne: RE: Converting string characters in QTP


>
>
>> Can any one suggest how to convert commas in a string into another
>>character in QTP?
>
>No easy way.
>If the goal is to remove embedded commas to create a csv, you can enclose
>the string in quotes (although then you have the same problem with the
>quotes).
>
>In Powerhouse:
>
>; assuming a length of 80, substituting ";" for ","
>def i1 int*4 = index(original, ",")
>def str1 char*80 = original if (i1=0) else original[1:i1 -
>1]+";"+original[i1+1:80 - i1]
>; 1st taken care of ...
>def i2 int*4 = 0 if (i1=0) else index(str1,",")
>def str2 char*80 = str1 if (i2=0) else str1[1:i2 - 1]+";"+str1[i2+1:80 - i2]
>; 2nd taken care of ...
>def i3 int*4 = 0 if (i2=0) else index(str2,",")
>def str3 char*80 = str2 if (i3=0) else str2[1:i3 - 1]+";"+str2[i3+1:80 - i3]
>; 3rd taken care of ...
>; continue as long as seems necessary.
>
>Note that this is quite inefficient:
>i1 is evaluated 4 times in the evaluation of str1, 5 in the evaluation of i2
>(if there's a comma).
>Similarly i2 and i3.
>For this reason you may get better performance doing multiple passes,
>removing 1, or a few, commas each time, rather than trying to remove a large
>number of commas in one pass.
>
>Alternatively, you could use TPU (on VMS) or perl, or some similar tool.
>
>Chris
>
>
>
>-----------------------------------------------------------------------
>
>Any views expressed in this message are those of the sender and not
>necessarily those of CCA Group.  The unauthorized use, disclosure,
>copying or alteration of this message is forbidden.  The contents of
>this message may be confidential and/or privileged, copyright CCA Group
>and are intended solely for the use of the individual or entity to whom
>they are addressed.  Whilst this message has been scanned, CCA Group
>cannot guarantee that it is virus free or compatible with your systems
>and accepts no responsibility for any loss or damage arising from its
>use. The recipient is advised to run their own anti-virus software. If
>you receive this message in error please contact
>postmaster@ccagroup.co.uk immediately, destroy any copies and delete it
>from your computer systems.
>
>= = = = = = = = = = = = = = = = = = = = = = = = = = = =
>Mailing list: powerh-l@lists.swau.edu
>Subscribe: "subscribe" in message body to powerh-l-request@lists.swau.edu
>Unsubscribe: "unsubscribe" in message body to powerh-l-request@lists.swau.edu
>http://lists.swau.edu/mailman/listinfo/powerh-l
>This list is closed, thus to post to the list you must be a subscriber.
>