$! REMOTEPRINT.COM
$
$
$!	Version 1.00 - Original
$!	Version 1.01 - Add more explanatory text.
$!	VERSION 1.02 - Filter directory and nodes names from filespec sent
$!			with QUEUE command.  FORCE::'s DECNET directory 
$!			will contain the files that are to be printed;
$!			therefore they should not have any directory or 
$!			node name associated.
$!	Version 1.03 - Allow a target node name for the printing to be
$!			specified along with the queue name.  This procedure
$!			can then ship the files to whatever node the user
$!			desires.
$
$! This will copy the appropriate file to the specified node
$! from which it will be printed to the appropriate 
$! printer. 
$! 
$!	Uses concept of network communication between two DCL processes
$!	to send file to remote queues.
$!
$! Parameters:
$!
$!	P1 - File name(s) to be printed
$!	P2 - NODE::Queue name (no default)   
$!	P3 - Form name, (defaults to DEFAULT)
$!	P4 - Copies (default = 1)
$!	P5 - Any other switches needed to tack onto command
$!
$	wo = "write sys$output"
$	NODENAME = f$logical("sys$node") - "_" - "::"
$	acct = F$Directory()
$	Owner = f$GETJPI("","OWNER")
$	Def_queue = "FORCE::SYS$PRINT"
$	Printnodes = "*FORCE*CHEWIE*C3PO*"
$	IF Owner .eqs. "" then Owner = F$GETJPI("","username")
$!	Determine if user wants information only
$!
$	SET ON
$	ON ERROR THEN GOTO ERR_EXIT
$	ON CONTROL_Y THEN GOTO ABORT_EXIT
$
$	if P1 .eqs. "??" then goto listqueonly
$	if P1 .eqs. "?" then goto helpsect
$!
$!	Check out real commands...
$
$!  Check P2 for nonblank and P4 for blank.  In this case, the user probably
$!  issued all of the command except for copies; therefore fill in the default.
$
$	If P2 .nes. "" .and. P4 .eqs. "" then P4 = "1"
$
$	If P1 .eqs. "" then inquire P1 "File(s)"
$Qloop:
$	If P2 .eqs. "" then -
	    	inquire P2 "NODE::Queue name (Node name, only, for list)"
$	If P2 .eqs. "" then P2 = def_queue
$	Gosub Separate_Node
$	if P2 .nes. "" then goto P3inquiry
$	write sys$output -
		"Queue name        Available Form(s) on node ''to_node'"
$	type 'To_node'::sys$manager:formnames.dat
$	Goto Qloop
$
$P3inquiry:
$	If P3 .nes. "" then Goto Passdefault
$	Open/read infile 'to_node'::sys$manager:formnames.dat
$Defloop1:
$	Read/end_of_file=Endfname infile l
$	q = F$EDIT(f$extract(0,20,l), "TRIM")
$	p = F$EDIT(f$extract(20,255,l), "TRIM")
$	If q .nes. p2 then goto defloop1
$	p3 = p
$	Close infile
$	Inquire P3 "Form name <''p3'>"
$	if p3 .eqs. "" then P3 = P	! Person took default, reload it.
$	If f$loc(" or ", P3) .eq. f$len(p3) then goto passdefault
$	wo "No default.  You must enter a form name here."
$	P3 = ""
$	Goto p3inquiry
$
$endfname:
$	wo "Queue ''P2' does not exist on node ''to_node'"
$	wo ""
$	P2 = ""
$	goto Qloop
$
$passdefault:
$	If P4 .eqs. "" then Inquire P4 "Number of copies"
$	If p4 .eqs. "" then p4 = "1"
$	Goto setup_cmd
$
$Listqueonly:
$
$!	Let 'em have current que list
$
$	outcom="SHOW"
$	gosub separate_node
$	GOTO FORCE_CMD
$
$setup_cmd:
$
$!  Process base file names out of the file name string.  We want to eliminate
$!  node and directory names from the print command.  (The files that are
$!  actually printed will be local to the printing node.)
$
$	I = 0
$	FILES = ""
$
$FILELOOP1:
$	t = f$element(I,",",p1)
$	If t .eqs. "," then goto assemble_it
$	t = f$parse(t,,,"name") + f$parse(t,,,"type")
$	If files .nes. "" then files = FILES + "," + T
$	IF files .eqs. "" then Files = T
$	I = I + 1
$	Goto fileloop1
$
$ASSEMBLE_IT:
$
$	outcom="PRINT/QUE=''P2'/FORM=''P3'/COPIES=''P4'''P5'/DELETE ''FILES'"
$                 
$FORCE_CMD:
$	set on
$	on error then goto err_exit
$	IF outcom .nes. "SHOW" THEN copy 'p1' 'to_node'""::*.*/replace/prot=w:rwed
$	open/write/READ netout 'To_node'""::"task=netprint"
$	write netout "''OUTCOM'"
$	write netout "''p2'"
$	If outcom .eqs. "SHOW" then goto loop1
$	write netout "''nodename'::''acct' by ''Owner'"
$loop1:
$	READ/end_of_file=finish NETOUT RESULT
$	wo "''RESULT'"
$	goto loop1
$!
$finish:
$	CLOSE NETOUT
$ 	exit
$
$helpsect:
$
$	wo "Command form is: "
$	wo "RPRINT file(s) [node::]queuename [formname] [copies] [other qualifiers]" 
$	wo ""
$	wo "(Commands in [] are optional. Node name defaults to FORCE::"
$	wo " Print queue defaults to SYS$PRINT.  Copies defaults to 1.)"
$	wo ""
$	wo "Two or more filenames should be separated by a comma (,)"
$	wo "No wildcards are permitted."
$	wo ""
$	wo "RPRINT ?? (two question marks) displays current queue contents."
$	exit
$
$!    		Here only for errors.
$
$Separate_node:
$!		Separates the node name from the rest of the queue name
$
$	To_node = "FORCE"
$	I = F$LOC("::", P2)
$	IF I .EQ. F$LEN(P2) THEN RETURN
$	TO_NODE = F$EXT(0,I, P2)
$	P2 = F$EXT(I+2, 255, P2)
$Check_node:
$	if f$locate("''to_node'",printnodes) .lt. f$length(printnodes) -
		then return
$	wo "''to_node' is not a valid printer node.  Valid nodes are:"
$	wo ""
$	next=0
$next_node:
$	next=next + 1
$	nextnode = f$element(next,"*",printnodes)
$	if nextnode .eqs. "*" then goto ask_node
$	wo "	''nextnode'"
$	goto next_node
$ask_node:
$	inquire to_node "Enter node name"
$	to_node = to_node - "::"
$	goto check_node
$	wo "ERROR in check_node
$
$
$ABORT_EXIT:
$
$	CLOSE/NOLOG INFILE
$	CLOSE/NOLOG NETOUT
$	EXIT
$
$ err_exit:
$ 	exit $status
