Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: ASUAUTIL

ASUAUTIL.m

Go to the documentation of this file.
ASUAUTIL ;DSD/DFM -UTILITY SUB-ROUTINES;  [ 04/15/98  2:55 PM ]
 ;;3.0;SAMS;**1**;AUG 20, 1993
ARPRINT ;EP; Write out Area Name and save Area Lookup table EIN
 D ARL W " ",ASUK("AREA NAME") Q
AREA ;EP - Lookup Area Name. X=AREA CODE
 S ASUF("LOOKA")=$G(ASUF("LOOKA"))
 S:ASUF("LOOKA")="" ASUF("LOOKA")=1
 I $D(ASUK("AREA","ACCPT")) G ARL
 I ASUF("LOOKA"),'$D(X) D SETAREA^ASUAUARE S ASUF("LOOKA")=0 G ARX
 S ASUK("AREA","ACCPT")=X
ARL ;
 S ASUK("TR1","AREA")=$O(^ASUTB01("B",ASUK("AREA","ACCPT"),0))
 S ASUK("AREA NAME")=$S(ASUK("TR1","AREA")]"":$P(^ASUTB01(ASUK("TR1","AREA"),0),U,2),1:"")
 S ASUF("LOOKA")=$G(ASUF("LOOKA"))
 D:ASUF("LOOKA") LOOKUP^ASUAUARE
ARX ;
 Q
STPRINT ;
 D STL W " ",ASUK("STATION","NAME") Q
STAT ;EP - Lookup Station Name. X=AREA CODE, X1=STATION CODE.
 I $D(ASUK("AREA","ACCPT")) G STK
 I '$D(X) D  G STK
 .S X=$G(ASUK("AREA","ACCPT")) D:X="" SETAREA^ASUAUARE
 S ASUK("AREA","ACCPT")=X D ARL
STK ;
 I $D(ASUK("STATION","CODE")) G STL
 I '$D(X1) S (ASUK("STATION","CODE"),ASUK("STATION","NAME"))="" G STX
 S ASUK("STATION","CODE")=X1
STL ;
 S ASUK("TR1","STATION")=$O(^ASUTB01(ASUK("TR1","AREA"),1,"B",ASUK("STATION","CODE"),0))
 S ASUK("STATION","NAME")=$S(ASUK("TR1","STATION")]"":$P(^ASUTB01(ASUK("TR1","AREA"),1,ASUK("TR1","STATION"),0),U,2),1:"")
STX ;      
 Q
GL ;EP - Lookup GL Account Name. X=GL CODE
 S ASUK("ACCOUNT NAME")=$S($O(^ASUTBLA("B",X,0)):$P(^ASUTBLA($O(^ASUTBLA("B",X,0)),0),U,3),1:"")
 Q
ITEM ;EP - Lookup item Description 1 & 2. X=INDEX NUMBER.
 S (ASUIXM("DESCRIPTION1"),ASUIXM("DESCRIPTION2"))=""
 Q:'X
 Q:$L($O(^ASUINDX("B",X,0)))=0
 S X=$O(^ASUINDX("B",X,0))
 S ASUIXM("DESCRIPTION1")=$P(^ASUINDX(X,0),U,2)
 S ASUIXM("DESCRIPTION2")=$P(^ASUINDX(X,0),U,3)
 Q
LOGV ;EP; SAVE OR PRINT INVENTORY LOG DATA
 S:'$D(ASUK("PRINT QUEUED")) ASUK("PRINT QUEUED")=0
 I ASUK("PRINT QUEUED") D
 .S ASUK("LOG VLIN")=$G(ASUK("LOG VLIN"))+1
 .S ^ASUX(0,"V",ASUK("LOG VLIN"))=ASUTRX
 E  D
 .D:'$D(IO(0)) HOME^%ZIS U IO(0)
 .X ASUTRX
 .S DIR(0)="E" D ^DIR K DIR
 Q
LOG ;EP; SAVE OR PRINT LOG DATA
 S ASUK("LOG LINE")=$G(ASUK("LOG LINE"))+1
 S ^ASUX(0,ASUK("LOG LINE"))=ASUTRX
 S:'$D(ASUK("PRINT QUEUED")) ASUK("PRINT QUEUED")=0
 I ASUK("PRINT QUEUED") Q
 D:'$D(IO(0)) HOME^%ZIS U IO(0)
 X ASUTRX
 Q
PVLOG ;EP - QUEUED JOB LISTING
 I '$D(^ASUX(0,"V")) Q
 D CLS^ASUAULGO
 W !!,"The following are SAMS Inventory System messages from Queued Jobs:",!!
 F  S ASUK("LOG VLIN")=$O(^ASUX(0,"V",$G(ASUK("LOG VLIN")))) Q:ASUK("LOG VLIN")']""  D
 .X ^ASUX(0,"V",ASUK("LOG VLIN"))
 .S DIR(0)="E" D ^DIR K DIR
 W !!,"ALL MESSAGES HAVE BEEN PRINTED",!!
 S DIR(0)="E" D ^DIR K DIR
 K ^ASUX(0,"V"),ASUK("LOG VLIN")
 Q
COMDN ;EP - SET SIGN NEGATIVE, INSERT DECIMALS AND COMMAS
 I X'["." D
 .I $L(X)=1 D
 ..S X=".0"_X
 .E  D
 ..I $L(X)=2 D
 ...S X="."_X
 ..E  D
 ...D INDC
 S X=X*-1
 D COM
 Q
COMD ;EP - INSERT DECIMAL & COMMAS
 I X'["." D
 .D INDC
 D COM
 Q
COMN ;EP - SET SIGN NEGATIVE INSERT COMMAS
 S X=X*-1 D COM Q
COM ;EP - INSERT COMMAS & RIGHT JUSTIFY (X2 = # DECIMAL, X3 = SIZE OF OUTPUT)
 S:'$D(X2) X2=2
 S:'$D(X3) X3=12
 S X=$FN(X,"T,",X2)
 S X=$J(X,X3)
 Q
INDC ;EP INSERT DECIMAL POINT (IF NO X2, DEFAULT IS 2 PLACES)
 S:'$D(X2) X2=2
 I $L(X)<X2 S X4=$E("00000",1,X2-$L(X)),X="."_X4_X Q
 S X=$E(X,1,$L(X)-X2)_"."_$E(X,$L(X)-(X2-1),$L(X))
 Q
RND2D ;EP TO ROUND TO TWO DECIMAL PLACES
 S Y=$FN(X,"T",2) Q
RND0D ;EP TO ROUND TO WHOLE NUMBER
 S Y=$FN(X,"T",0)
PHONE ;EP INPUT TRANSFORM FOR A PHONE NUMBER
 D
 .I $L(X)>8 D
 ..I X'?1"(".3N.1") ".3N.1"-".4N K X
 .E  D
 ..I X'?3N.1"-".4N K X
 Q