=?iso-8859-1?Q?R=E9f=2E_=3A_RE=3A_Converting_string_characters_in_QTP?=
nicolas.au@bnpparibas.com
nicolas.au@bnpparibas.com
Wed, 17 Oct 2001 14:49:51 +0200
Hi Neil,
>> Also the ability to determine how many occurrences of a string existed
in a
>> string - stringcnt("asd,432,test,end",",") would return 3.
If you are working on the HP3000 platform, you can try this :
RUN XXYY
; This demo program will give the number of occurrences of "," in T-AA
; using the HP3000 system function WORDCNT.
; The number of occurrences is stored in T-BB
ACCESS any-dataset ; or any file
CHOOSE key-item parm prompt 1 times ; or use select if you want
TEMP T-AA CHAR*40
TEMP T-BB NUM*4
TEMP T-CC CHAR*1 ; this is a dummy variable
ITEM T-AA = "asd,432,test,end" ; any string you want to test
ITEM T-CC = "Y" &
IF SETSYSTEMVAL("VAR_AA",(T-AA))
ITEM T-CC = "Y" &
IF SETSYSTEMVAL("VAR_BB","![wordcnt(VAR_AA ,',',1)]")
ITEM T-BB = nco(GETSYSTEMVAL("VAR_BB")) - 1
SUBFILE XYXYSF INCLUDE &
T-AA, &
T-BB
GO
============================
Now you can use QUIZ to see the content in subfile XYXYSF.
> acc *xyxysf
> rep all
> go
17 OCT 2001 ABS 14.00 DICTIONARY as at 31/8/1988 PAGE 1
T-AA T-BB
asd,432,test,end 3
============================
Good luck,
Nicholas.
Internet
neil@nha.co.za@cube.swau.edu - 17/10/2001 11:51
Envoyé par : powerh-l-admin@cube.swau.edu
Pour : powerh-l
cc :
ccc :
Objet : RE: Converting string characters in QTP
I agree that a replace function would be enormously useful.....in QTP,QUIZ
and Quick.
Also the ability to determine how many occurrences of a string existed in a
string - stringcnt("asd,432,test,end",",") would return 3.
You can achieve both of these within PH defines, but laboriously - a bit
like an Excel nested if statement, it used to be fun, life is too short.
Neil
-----Original Message-----
From: Ole Hansen, ScanConsult [mailto:oh@scanconsult.dk]
Sent: 17 October 2001 11:16
To: Chris Sharman; Lemin, Graeme; powerh-l@lists.swau.edu
Subject: Sv: Converting string characters in QTP
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.
>
= = = = = = = = = = = = = = = = = = = = = = = = = = = =
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.
= = = = = = = = = = = = = = = = = = = = = = = = = = = =
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.
This message and any attachments (the "message") is
intended solely for the addressees and is confidential.
If you receive this message in error, please delete it and
immediately notify the sender. Any use not in accord with
its purpose, any dissemination or disclosure, either whole
or partial, is prohibited except formal approval. The internet
can not guarantee the integrity of this message.
BNP PARIBAS (and its subsidiaries) shall (will) not
therefore be liable for the message if modified.
---------------------------------------------
Ce message et toutes les pieces jointes (ci-apres le
"message") sont etablis a l'intention exclusive de ses
destinataires et sont confidentiels. Si vous recevez ce
message par erreur, merci de le detruire et d'en avertir
immediatement l'expediteur. Toute utilisation de ce
message non conforme a sa destination, toute diffusion
ou toute publication, totale ou partielle, est interdite, sauf
autorisation expresse. L'internet ne permettant pas
d'assurer l'integrite de ce message, BNP PARIBAS (et ses
filiales) decline(nt) toute responsabilite au titre de ce
message, dans l'hypothese ou il aurait ete modifie.