Formatting a number in PowerHouse - version 8.49.E
Knox, Dave (Carrollton, TX)
KnoxDa01 at UnisourceLink.Com
Tue Sep 1 12:41:04 CDT 2009
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
-----Original Message-----
From: powerh-l-bounces+knoxda01=unisourcelink.com at lists.sowder.com
[mailto:powerh-l-bounces+knoxda01=unisourcelink.com at lists.sowder.com] On
Behalf Of powerh-l-request at lists.sowder.com
Sent: Tuesday, September 01, 2009 12:00 PM
To: powerh-l at lists.sowder.com
Subject: powerh-l Digest, Vol 52, Issue 2
Send powerh-l mailing list submissions to
powerh-l at lists.sowder.com
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.sowder.com/mailman/listinfo/powerh-l
or, via email, send a message with subject or body 'help' to
powerh-l-request at lists.sowder.com
You can reach the person managing the list at
powerh-l-owner at lists.sowder.com
When replying, please edit your Subject line so it is more specific
than "Re: Contents of powerh-l digest..."
Today's Topics:
1. RE:Formatting a number in PowerHouse - version 8.49.E
(Ken Langendock)
----------------------------------------------------------------------
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
***************************************
More information about the powerh-l
mailing list