; ************************** AMUS Program Label ******************************
; Filename: JUST.M68                                        Date: 06/10/90
; Category: UTIL         Hash Code: 543-513-736-027      Version: 2.0(100)
; Initials: ULTR/AM      Name: DAVID PALLMANN
; Company: ULTRASOFT CORPORATION                   Telephone #: 5163484848
; Related Files:
; Min. Op. Sys.: AMOSL 1.3D/AMOS32 1.0D        Expertise Level: BEG
; Special: After assembly: .LNKLIT JUST,WLDSCN {/L} Req. 2.0 assembler.
; Description: Allows R. Just to be changed for one or more WRITE 2.0 doc's.
; Supports wildcarding.
;
; ****************************************************************************

;******************************************************************************
;*                                                                          *
;*                                  JUST                                    *
;*          Change Justification in AlphaWRITE 2.0 Document Headers         *
;*                                                                          *
;****************************************************************************
;Copyright (C) 1990 UltraSoft Corporation.  All Rights Reserved.
;
;Written by: David Pallmann
;
;Edit History:
;2.0(100)  01-Jun-90  created. /DFP

       VMAJOR  =2
       VMINOR  =0
       VSUB    =0
       VEDIT   =100.
       VWHO    =0

       AUTOEXTERN

       SEARCH  SYS
       SEARCH  SYSSYM
       SEARCH  WLDSYM

;XCALL argument list - indexed by A3

       .OFINI
       .OFDEF  X.ARGS, 2               ; number of arguments
       .OFDEF  X.TYP1, 2               ; arg 1 - type code
       .OFDEF  X.ADR1, 4               ;       - address
       .OFDEF  X.SIZ1, 4               ;       - size
       .OFDEF  X.TYP2, 2               ; arg 2 - type code
       .OFDEF  X.ADR2, 4               ;       - address
       .OFDEF  X.SIZ2, 4               ;       - size

;XCALL variable types

       .OFINI
       .OFDEF  X.UNF,  2               ; binary
       .OFDEF  X.STR,  2               ; string
       .OFDEF  X.FLT,  2               ; float
       .OFDEF  X.BIN,  2               ; unformatted

       X.ARY   =16.

;AlphaWRITE 2.0 header format

;*********************
;*  DOCUMENT HEADER  *
;*********************

OFINI
;------------------ start of AlphaCALC & AlphaWRITE common area -------------

OFDEF   H.VER,PH.SIZ                    ; document version number
OFDEF   H.SIZE,4.                       ; size of document header in bytes
OFDEF   H.DESC,60.                      ; description
OFDEF   H.AUTH,20.                      ; author
OFDEF   H.DEPT,6.                       ; department
OFDEF   H.OPR,20.                       ; operator name
OFDEF   H.PROT,1.                       ; document protection type
OFDEF   H.ENCR,1.                       ; encryption type
OFDEF   H.PASS,10.                      ; password
OFDEF   H.DCRT,4.                       ; date created
OFDEF   H.TCRT,4.                       ; time created
OFDEF   H.DREV,4.                       ; date last revised
OFDEF   H.TREV,4.                       ; time last revised
OFDEF   H.NREV,2.                       ; number of times revised
OFDEF   H.VREV,4.                       ; version of program when last revised
OFDEF   H.DPRT,4.                       ; date last printed
OFDEF   H.TPRT,4.                       ; time last printed
OFDEF   H.NPRT,2.                       ; number of times printed
OFDEF   H.EPRT,4.                       ; elapsed time to print document
OFDEF   H.TIMO,4.                       ; total time open
OFDEF   H.KEYS,4.                       ; total keystrokes
OFDEF   H.LTXT,8.                       ; lines of text per page
OFDEF   H.LTM,8.                        ; lines in top margin
OFDEF   H.LPP,8.                        ; lines per page (total)
OFDEF   H.CPI,8.                        ; characters per inch (pitch)
OFDEF   H.RJST,8.                       ; right justification
OFDEF   H.WSPC,8.                       ; word spacing
OFDEF   H.LPI,8.                        ; lines per inch
OFDEF   H.LSPC,8.                       ; line spacing (in 1/2 lines)
OFDEF   H.LPO,8.                        ; left paper offset
OFDEF   H.BHED,8.                       ; spaces after title
OFDEF   H.BFOT,8.                       ; spaces before footer
OFDEF   H.OUTF,8.                       ; outline format
OFDEF   H.FORM,8.                       ; printer form name
OFDEF   H.LBFTN,8.                      ; lines before footnote                 [177]
OFDEF   H.TFTN,2.                       ; type of footnote                      [177]
OFDEF   H.FLS,2.                        ; footnote line separator               [177]
OFDEF   H.KERN,2                        ; kerning (None, Light, Medium, Heavy)
OFDEF   H.TXTSIZ,2                      ; size of text on a page (points)
OFDEF   H.TOPMGN,2                      ; size of top margin (points)
OFDEF   H.PAGSIZ,2                      ; size of total page (points)
OFDEF   H.PITCH,2                       ; width of average character (points)
OFDEF   H.LEAD,2                        ; leading (points)
OFDEF   H.LINSPC,2                      ; line spacing (points)
OFDEF   H.LFTOFF,2                      ; left paper offset (points)
OFDEF   H.TTLSIZ,2                      ; space after title (points)
OFDEF   H.FTRSIZ,2                      ; space after footer (points)
OFDEF   H.FTNSIZ,2                      ; space before footnotes (points)
OFDEF   H.ORIENT,2                      ; orientation (P or L)
OFDEF   H.FORMAT,2                      ; formatted Y/N
OFDEF   H.PAGCNT,2                      ; total pages after last pagination
OFDEF   H.DOCFMT,1                      ; document format
OFDEF   H.SPAR,0                        ;       SPARE
OFSIZ   S..HDR                          ; size of header
S..HDR=510.                             ; header size is 510.

;variables

       .OFINI
       .OFDEF  FILE,   D.DDB           ; file DDB
       .OFDEF  FILES,  2               ; file count
       .OFDEF  JUST,   1               ; new justification
       .OFDEF  XXXXXX, 1               ; even address
       .OFSIZ  MEMSIZ                  ;

START:  PHDR    -1,0,PH$REE!PH$REU      ;
       GETIMP  MEMSIZ,A5               ;
       WINIT                           ;
       INIT    FILE(A5)                ;

CMDLIN: BYP                             ;
       LIN                             ;
       JEQ     USAGE                   ;
       WSPEC                           ;
       JNE     EXIT                    ;

;get Y or N from command line

GETJST: BYP                             ;
       MOVB    @A2,D1                  ;
       UCS                             ;
       CMPB    D1,#'Y                  ;
       BEQ     10$                     ;
       CMPB    D1,#'N                  ;
       JNE     FMTERR                  ;
10$:    MOVB    D1,JUST(A5)             ;

LOOP:   CTRLC   EXIT                    ;
       WSCAN                           ;
       JNE     DONE                    ;
       CMPW    D.EXT(A4),#[WRT]        ;
       BNE     LOOP                    ;

       MOVW    D.DEV(A4),FILE+D.DEV(A5);
       MOVW    D.DRV(A4),FILE+D.DRV(A5);
       MOV     D.FIL(A4),FILE+D.FIL(A5);
       MOVW    D.EXT(A4),FILE+D.EXT(A5);
       MOVW    D.PPN(A4),FILE+D.PPN(A5);
       CLR     FILE+D.DVR(A5)          ;

       LOOKUP  FILE(A5)                ;
       JNE     LOOP                    ;

       MOV     FILE+D.BAS(A5),FILE+D.REC(A5);
       READ    FILE(A5)                ;
       MOV     FILE+D.BUF(A5),A3       ;
       ADD     #2,A3                   ;
       ADDW    FILE+D.FMT(A5),A3       ;

       MOV     @A3,D7                  ;
       AND     #^B<1111111100001111>,D7
       CMPW    D7,#2_8.+0              ; 2.0 document?
       JNE     LOOP                    ;   no

       PFILE   @A4                     ;
       INCW    FILES(A5)               ;

       MOVB    JUST(A5),H.RJST(A3)     ;

       WRITE   FILE(A5)                ;

       CRLF                            ;
       JMP     LOOP                    ;

DONE:   CLR     D1                      ;
       MOVW    FILES(A5),D1            ;
       BEQ     NOFILES                 ;
       DCVT    0,OT$TRM!OT$TSP         ;
       TYPE    document                ;
       CMPW    D1,#1                   ;
       BEQ     10$                     ;
       TYPE    s                       ;
10$:    TYPECR  < modified>             ;
       CRLF                            ;
       EXIT                            ;

NOFILES:
       TYPECR  %No documents modified  ;
       CRLF                            ;

EXIT:   EXIT                            ;

FMTERR: TYPECR  ?Command Format Error   ;
       CRLF                            ;

USAGE:  TYPECR  JUST allows you to change the justification in AlphaWRITE 2.0 document headers
       CRLF                            ;
       TYPECR  Usage: .JUST document justification
       CRLF                            ;
       TYPECR  Ex:    .JUST *.WRT N    ;
       CRLF                            ;
       EXIT                            ;

       END