Formatting a number in PowerHouse - version 8.49.E
Peter Bateman
peterbateman808 at hotmail.com
Thu Sep 3 11:34:46 CDT 2009
Hi all;
Guy makes an interesting point.
I think the following sed command would get rid of the comma
in INNUM. Note the ` to cause the output from sed to be put in the variable.
It has been awhile since I have coded UNIX scripts. Guy if you have access to
an UNIX box please try it.
> def INNUM char*20 = "1,234,567.89"
>
> def OUTNUM num = nconvert(lj(getsystemval("OUTVAR"))) * 1000 &
> If setsystemval("OUTVAR",( "`sed 's/,//g' < echo " + INMUM ) )
> Subject: RE: Formatting a number in PowerHouse - version 8.49.E
> Date: Wed, 2 Sep 2009 08:04:26 -0500
> From: guy.werry at hbms.ca
> To: powerh-l at lists.sowder.com
>
> The original post didn't specify what system they're running on. What
> about tools like Unix's awk or perhaps even Perl?
> I haven't attempted this at all, but I have used awk pretty often in the
> past for similar situations. It may well be smart enough to figure this
> field out for you.
>
> Guy L. Werry
> Senior Systems Analyst
> Hudson Bay Mining & Smelting Co., Limited.
>
> -----Original Message-----
> From: powerh-l-bounces+guy.werry=hbms.ca at lists.sowder.com
> [mailto:powerh-l-bounces+guy.werry=hbms.ca at lists.sowder.com] On Behalf
> Of Knox, Dave (Carrollton, TX)
> Sent: Tuesday, September 01, 2009 12:41 PM
> To: powerh-l at lists.sowder.com
> Subject: RE:Formatting a number in PowerHouse - version 8.49.E
>
> The almost fool proof solution (for HP3000 MPE at least).
>
> Just need to remove the commas. Using getsystemval/setsystemval and an
> MPE FUNCTION you can strip them out in one statement. No formatting
> control required, and all done in one statement. Any number of decimals
> (or none).
>
> def INNUM char*20 = "1,234,567.89"
>
> def OUTNUM num = nconvert(lj(getsystemval("OUTVAR"))) * 1000 &
> If setsystemval("OUTVAR",'![repl("' + trunc(INNUM) + '",",","")]')
>
> ;; the setsystemval is evaluated before the getsystemval is actioned.
>
>
> rep INNUM OUTNUM pic "^^^^^^^^^.^^^"
> go
>
> INNUM OUTNUM
>
> 1,234,567.89 1234567.890
>
>
> Caveat
> Matchpattern required if input data not trustworthy.
> TRAILING negatives can be a problem (flip to front if necessary)
> No idea if this works on other platforms!
>
> Regards
> Dave Knox
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 1 Sep 2009 12:56:34 -0400
> From: "Ken Langendock" <ken.langendock at rogers.com>
> Subject: RE: Formatting a number in PowerHouse - version 8.49.E
> To: <powerh-l at lists.sowder.com>
> Message-ID: <001701ca2b25$2a577740$7f0665c0$@langendock at rogers.com>
> Content-Type: text/plain; charset="us-ascii"
>
> There is no fool proof solution unless the string is exactly the same
> every time.and from what he said here, this is not the case.
>
> By using INDEX, this solution is relatively easy:
>
>
>
> TEMP T-XAmount CHARACTER * 20
>
> ITEM T-XAmount = Field OF InputFile
>
> ; remove 1st ','
>
> ITEM T-XAmount = T-XAmount [INDEX(T-XAmount,',') + 1:20] &
>
> IF 0 NE INDEX(T-XAmount,',')
>
> ; remove 2nd ','
>
> ITEM T-XAmount = T-XAmount [INDEX(T-XAmount,',') + 1:20] &
>
> IF 0 NE INDEX(T-XAmount,',')
>
> ; remove 3rd ','
>
> ITEM T-XAmount = T-XAmount [INDEX(T-XAmount,',') + 1:20] &
>
> IF 0 NE INDEX(T-XAmount,',')
>
> . etc.
>
> ITEM T-Amount = NCONVERT(T-XAmount)
>
>
>
> Ken
>
>
>
> From: powerh-l-bounces+ken.langendock=rogers.com at lists.sowder.com
> [mailto:powerh-l-bounces+ken.langendock=rogers.com at lists.sowder.com] On
> Behalf Of Lowe, Chuck J
> Sent: August 31, 2009 1:04 PM
> To: powerh-l at lists.sowder.com
> Subject: [Bulk] Formatting a number in PowerHouse - version 8.49.E
>
>
>
> I have a file from an outside vendor. They are sending it pipe
> delimited "|", There is an amount field that is left justified. Is there
> anyway to take that character field and convert it to a numeric field
> without doing
> INDEX and bit extracts. Sometimes the field is 123.45 and sometimes
> 3,123.45. I thought I could use the FORMATNUMBER function but that is
> for doing the opposite.
>
>
>
> The vendor states they can not send it unformatted.
>
>
>
> Thanks in advance.
>
>
>
> Chuck Lowe Quest Diagnostics | Sr. Programmer/Analyst,SYS Billing
> System/Denver| 400 Egypt Rd. | West Norriton, PA 19403 USA | phone
> 610-650-6679| fax 610-650-2111 |
> <mailto:Chuck.J.Lowe at questdiagnostics.com>
> Chuck.J.Lowe at questdiagnostics.com
> | <http://www.questdiagnostics.com/> www.QuestDiagnostics.com
>
> Please think about resource conservation before you print this message
>
>
>
>
> ------------------------------------------
> The contents of this message, together with any attachments, are
> intended only for the use of the person(s) to which they are addressed
> and may contain confidential and/or privileged information. Further, any
> medical information herein is confidential and protected by law. It is
> unlawful for unauthorized persons to use, review, copy, disclose, or
> disseminate confidential medical information. If you are not the
> intended recipient, immediately advise the sender and delete this
> message and any attachments.
> Any distribution, or copying of this message, or any attachment, is
> prohibited.
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://lists.sowder.com/pipermail/powerh-l/attachments/20090901/de04668f
> /attachment.html
>
> ------------------------------
>
> --
> = = = = = = = = = = = = = = = = = = = = = = = = = = = = Mailing list:
> powerh-l at lists.sowder.com
> Subscribe: "subscribe" in message body to
> powerh-l-request at lists.sowder.com
> Unsubscribe: "unsubscribe <password>" in message body to
> powerh-l-request at lists.sowder.com
> http://lists.sowder.com/mailman/listinfo/powerh-l
> This list is closed, thus to post to the list you must be a subscriber.
> Add 'site:lists.sowder.com powerh-l' to your search terms to search the
> list archive at Google.
>
> End of powerh-l Digest, Vol 52, Issue 2
> ***************************************
>
>
> --
> = = = = = = = = = = = = = = = = = = = = = = = = = = = = Mailing list:
> powerh-l at lists.sowder.com
> Subscribe: 'subscribe' in message body to
> powerh-l-request at lists.sowder.com
> Unsubscribe: 'unsubscribe <password>' in message body to
> powerh-l-request at lists.sowder.com
> http://lists.sowder.com/mailman/listinfo/powerh-l
> This list is closed, thus to post to the list you must be a subscriber.
> Add 'site:lists.sowder.com powerh-l' to your search terms to search the
> list archive at Google.
>
> The information in this e-mail and any attachments is confidential and may be subject to legal professional privilege. It is intended solely for the attention and use of the named addressee(s). If you are not the intended recipient, or person responsible for delivering this information to the intended recipient, please notify the sender immediately. Unless you are the intended recipient or his/her representative you are not authorised to, and must not, read, copy, distribute, use or retain this message or any part of it.
>
> --
> = = = = = = = = = = = = = = = = = = = = = = = = = = = =
> Mailing list: powerh-l at lists.sowder.com
> Subscribe: 'subscribe' in message body to powerh-l-request at lists.sowder.com
> Unsubscribe: 'unsubscribe <password>' in message body to powerh-l-request at lists.sowder.com
> http://lists.sowder.com/mailman/listinfo/powerh-l
> This list is closed, thus to post to the list you must be a subscriber.
> Add 'site:lists.sowder.com powerh-l' to your search terms to search the list archive at Google.
_________________________________________________________________
Click less, chat more: Messenger on MSN.ca
http://go.microsoft.com/?linkid=9677404
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.sowder.com/pipermail/powerh-l/attachments/20090903/c874fe6d/attachment.htm
More information about the powerh-l
mailing list