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

CIAUBCDA.m

Go to the documentation of this file.
  1. CIAUBCDA ;MSC/IND/PLS - Converts barcode CODABAR to HPCL-compatible format ;04-May-2006 08:19;DKM
  1. ;;1.2;CIA UTILITIES;;Mar 20, 2007
  1. ;;Copyright 2000-2006, Medsphere Systems Corporation
  1. ;=================================================================
  1. ; Inputs:
  1. ; TXT = Data string to print in bar code
  1. ; ORN = Orientation of bar code/Check digit
  1. ; 0 = portrait/no check digit(default)
  1. ; 1 = landscape/no check digit
  1. ; 2 = portrait/check digit
  1. ; 3 = landscape/check digit
  1. ; HGT = Height of bar code in dots (1/300 inch)
  1. ; HOR = Horizontal position on page in dots
  1. ; VER = Vertical position on page in dots
  1. ; WID = Width of bar in dots (3=default)
  1. ; SSC = Start/Stop characters (a/a = default)
  1. ; Purpose:
  1. ; Accepts a barcode CODABAR string and writes an HPCL-compatible
  1. ; string that will display the barcode on an HP laser printer.
  1. ; A barcode font cartridge is not required. The print position
  1. ; on entry is restored upon exit.
  1. ;=================================================================
  1. BC(TXT,ORN,HGT,HOR,VER,WID,SSC) ;
  1. N DD,CHK,CH,ZDD,C,P,Z,Z1,Z2,Z3,Z4,Z5,X
  1. S X=0 X ^%ZOSF("RM")
  1. S CHK=$S($G(ORN)>1:1,1:0),ORN=$S($G(ORN)#2:1,1:0)
  1. S CH="0123456789-$:/.+"
  1. S DD="" F ZDD=1:1:$L(TXT) S DD=DD_$S(CH[$E(TXT,ZDD):$E(TXT,ZDD),1:"") ;STRIP UNPRINTABLE CHARACTERS
  1. S TXT=DD,TXT="a"_TXT_"a" ;ADD START AND STOP CODES
  1. I +$G(CHK) S TXT=$$CHK(TXT)
  1. S C=$C(27)_"*c",P=$C(27)_"*p+",WID=$G(WID,3),HGT=$G(HGT,60),ORN=''$G(ORN)+1
  1. W $C(27),"&f0S" ;Push cursor position
  1. W:$D(HOR) $C(27)_"*p"_+HOR_"X"
  1. W:$D(VER) $C(27)_"*p"_+VER_"Y"
  1. W C_HGT_$E("BA",ORN)
  1. F Z=1:1:$L(TXT) D
  1. .S Z1=$S("AaTt"[$E(TXT,Z):$P($T(16),";",4),"BbNn"[$E(TXT,Z):$P($T(17),";",4),"Cc*"[$E(TXT,Z):$P($T(18),";",4),"DdEe"[$E(TXT,Z):$P($T(19),";",4),1:$P($T(@($F(CH,$E(TXT,Z))-2)),";",4)),Z4=13,Z5=0
  1. .F Z2=1:1:$L(Z1) D
  1. ..S Z3=+$E(Z1,Z2),Z4=Z4-Z3,Z3=Z3*WID
  1. ..Q:'Z3
  1. ..I Z2#2 W C_Z3_$E("ab",ORN)_"0P" S Z5=Z3
  1. ..E W P_(Z3+Z5)_$E("XY",ORN) S Z5=0
  1. .S Z4=Z4*WID+Z5
  1. .W P_(Z5+WID)_$E("XY",ORN)
  1. W $C(27),"&f1S" ;Pop cursor position
  1. Q ""
  1. CHK(X) ;CALCULATE CHECK DIGIT AND RETURN STRING TO PRINT
  1. Q:X="" ""
  1. N Z1,Y,CHK,XX
  1. S CHK=0,Y=X
  1. S XX=$E(X,1)_$E(X,$L(X)) ;STRIP OFF S/S CODES AND CALCULATE CHECKSUM
  1. F Z1=1:1:$L(XX) S CHK=CHK+$S("AaTt"[$E(XX,Z1):16,"BbNn"[$E(XX,Z1):17,"Cc*"[$E(XX,Z1):18,"DdEe"[$E(XX,Z1):19,1:0)
  1. ;ADD TO CHECKSUM THE VALUES OF THE DATA
  1. S X=$E(X,2,$L(X)-1) F Q:X="" S CHK=$F(CH,$E(X))-2+CHK,X=$E(X,2,255)
  1. S CHK=$E(CH,$S('CHK#16:1,1:16-CHK#16+1))
  1. Q $E(Y,1,$L(Y)-1)_CHK_$E(Y,$L(Y))
  1. 0 ;;0;1111133
  1. 1 ;;1;1111331
  1. 2 ;;2;1113113
  1. 3 ;;3;3311111
  1. 4 ;;4;1131131
  1. 5 ;;5;3111131
  1. 6 ;;6;1311113
  1. 7 ;;7;1311311
  1. 8 ;;8;1331111
  1. 9 ;;9;3113111
  1. 10 ;;-;1113311
  1. 11 ;;$;1133111
  1. 12 ;;:;3111313
  1. 13 ;;/;3131113
  1. 14 ;;.;3131311
  1. 15 ;;+;1131313
  1. 16 ;;AaTt;1133131
  1. 17 ;;BbNn;1313113
  1. 18 ;;Cc*;1113133
  1. 19 ;;DdEe;1113331