midrange.com code scratchpad |
Name:
SETSIGN service program
|
Scriptlanguage:
Plain Text
|
Tabwidth:
4
|
Date:
11/30/2007 06:26:19 pm
|
IP:
Logged
|
|
Description:
SETSIGN converts a numeric field to character and places the sign on the left or right as specified.
|
Code:
- SETSIGNPR:
-
- D SetSign PR
- D InputNum 12S 2
- D SignLoc 1A
- D OutString 12A
-
-
- SETSIGN:
-
- *=================================================================*
- * SetSign - Set the sign for a numeric to character conversion
- *=================================================================*
- H
- *=================================================================*
- * Parameters
- * 1. Input: numeric value
- * 2. Output: signed numeric string
- *=================================================================*
- D/copy qsrvsrc,setsignpr
- *-----------------------------------------------------------------*
- * Main entry parameters
- * 1. Input: numeric value
- * 2. Output: signed numeric string
- *-----------------------------------------------------------------*
- D SetSign PI
- D InputNum 12S 2
- D SignLoc 1A
- D OutString 12A
- D
-
- *-----------------------------------------------------------------*
- * Other fields used by the program
- *-----------------------------------------------------------------*
- D DS
- D work1 11s 2
- D work2 11a overlay(work1)
-
- D Pos c ' '
- D Neg c '-'
- D Left c 'L'
- D Right c 'R'
-
- /free
- work1 = %abs(InputNum);
-
- // for Negative numbers
- if InputNum < *zero;
- // Sign on the Right
- if SignLoc = Right;
- OutString = work2 + Neg;
- endif;
- // Sign on the Left
- if SignLoc = Left;
- OutString = Neg + work2;
- endif;
-
- // Positive numbers
- else;
- // Sign on the Right
- if SignLoc = Right;
- OutString = work2 + Pos;
- endif;
- // Sign on the Left
- if SignLoc = Left;
- OutString = Pos + work2;
- endif;
- endif;
-
- Return;
- /end-free
|
|
|