HP3000-L Archives

September 2007, Week 4

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Tom Emerson <[log in to unmask]>
Reply To:
Tom Emerson <[log in to unmask]>
Date:
Wed, 26 Sep 2007 13:11:48 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (127 lines)
Michael wrote:

> the problem starts with the compile.
> If I define a field 01 Display-Amount  PIC z,zzz,zzz.zz.
> and in Special-Names I say decimal-point is comma, I get a compile error
> Q  MULTIPLE POINT CHARACTERS IN PICTURE.

Rather than mess with the compiler, a simple "inspect/replacing" statement
will convert the number for you -- Below is an example and the resulting
output (and as suggested elsewhere, uses an environment variable to
determine the format)

you could write this up as an XL routine which takes in the number to be
"formattted" and a flag to indicate US or "other" formats and returns the
appropriately localized version of the number. 

:print localize.source

$CONTROL USLINIT,LIST,WARN,POST85
 IDENTIFICATION DIVISION.
*================================================================*
 PROGRAM-ID.      BUGGER.
 INSTALLATION.    USA.
 DATE-WRITTEN.    Sept 26, 2007.
 REMARKS.         localization routine (commas vs. decimal point).

 ENVIRONMENT DIVISION.
*================================================================*

 CONFIGURATION SECTION.
***********************

 SOURCE-COMPUTER. HP3000 WITH DEBUGGING MODE.
 OBJECT-COMPUTER. HP3000.

 INPUT-OUTPUT SECTION.
**********************

$PAGE
 DATA DIVISION.
*================================================================*
 WORKING-STORAGE SECTION.
*************************
 01  WS-VERSION.
     05  WS-VERSION-APPNAME      PIC X(06) VALUE "BUGGER".
     05  FILLER                  PIC X(01) VALUE ".".
     05  WS-VERSION-MAJOR        PIC 9 VALUE 0.
     05  FILLER                  PIC X(01) VALUE ".".
     05  WS-VERSION-MINOR        PIC 9 VALUE 1.

 01  input-amount                pic s9(9)v99.
 01  comp-amount                 pic s9(9)v99 comp-3.
 01  edited-amount               pic zzz,zzz,zz9.99-.
 01  localized-amount redefines edited-amount.
     05  lcl-integer             pic x(11).
     05  lcl-dp                  pic x.
     05  lcl-fraction            pic x(3).

 01  format-flag                 pic x.
     88 FORMAT-NON-US                value "*".

 01  HPCIGETVAR-STMT.
     05  HPCI-GV-NAME            PIC X(50) VALUE SPACES.
     05  HPCI-GV-STATUS          PIC S9(9) VALUE +0 COMP.
     05  HPCI-GV-ITEM            PIC 9(09) VALUE 2.
     05  HPCI-GV-RETURN          PIC X(08) VALUE SPACES.

$PAGE
 PROCEDURE DIVISION.
*================================================================*

 MAIN.

     DISPLAY WS-VERSION.
     DISPLAY " ".

     accept input-amount free

     move "FORMATFLAG;" to HPCI-GV-NAME

     CALL INTRINSIC "HPCIGETVAR" USING HPCI-GV-NAME,
                                 HPCI-GV-STATUS,
                                 HPCI-GV-ITEM,
                                 HPCI-GV-RETURN

     move HPCI-GV-RETURN to FORMAT-FLAG

     move input-amount to comp-amount
     perform localize-number
     display input-amount " with formatting: " edited-amount

     stop run.

 LOCALIZE-NUMBER.

***  this could be an XL routine with comp-amount & edited-amount
***  as level 77 variables (i.e., parameters)

     move comp-amount to edited-amount

     if FORMAT-NON-US

         inspect lcl-integer replacing all "," by "."
         move "," to lcl-dp

     end-if.

***---------------------------------------------------------------

%run localize.prog
BUGGER.0.1
 
-1234.56
-000001234.56 with formatting:       1,234.56-

%setvar formatflag "*"
%do run
run localize.prog
BUGGER.0.1
 
-1234.56
-000001234.56 with formatting:       1.234,56-
%

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2