.;
.;  command file RMDEVEL
.;
.;  Copyright (C) 1982 by
.;  Digital Equipment Corporation, Maynard, Mass.
.;
.;
.;  MODULE DESCRIPTION
.;
.;  This procedure performs operations to assist in the development
.;  of a LABSTATION 23 task.
.;
.;  It performs the following tasks:
.;
.;  1) Establishes the locations of LABSTATION 23 system image files.
.;
.;  2) Establishes the target node for which the task is destined.
.;
.;  3) Invokes the editor, Fortran IV compiler and task builder for
.;     the user.
.;
.;  4) VMR's the correct system image with the new task.
.;
.;  5) Updates the host loader tables with the task name and location,
.;     if necessary.
.;
.;  6) Downline loads the new system image to the target node.
.;
.;
.;  The user can execute this file by assigning the full filespec
.;  to a logical variable.  For example, if the file is located
.;  in DR0:[3,64],
.;
.;  ASN DR0:[3,64]RMDEVEL.CMD=RMDEVEL
.;
.;  The file can then be invoked by 
.;
.;  @RMDEVEL filename
.;
.;     where filename is the name of a FORTRAN IV source program
.;     (extension omitted).
.;
.;  ************************************************************
.;
.;  ASSUMPTIONS
.;
.;  The user requires the following privileges:
.;
.;	CMKRNL - to set UIC 
.;
.;	LOG_IO - to run VMR on system images
.;
.;	OPER - to downline load LABSTATION 23 nodes
.;
.;  ************************************************************
.;	
.;  LDP Development Group
.;
.;  Created  27-Sep-1982 	R.H.Bauman
.;
	.ENABLE GLOBAL
	.ENABLE ESCAPE
	.ENABLE SUBSTITUTION
	.DISABLE LOWERCASE
.;
.;  Determine host (use DECnet/RSX codes)
.;
	.SETN $TSYS 4
	.IF <SYSTEM> = 1 .SETN $TSNUM 1		! Host is 11M
	.IF <SYSTEM> = 6 .SETN $TSNUM 2		! Host is 11M+
	.IF <SYSTEM> = 5 .SETN $TSNUM 4		! Host is VAX/VMS
.;
	.IF $TSNUM = 1 .SETS $TSSTR "RSX-11M"
	.IF $TSNUM = 2 .SETS $TSSTR "RSX-11M+"
	.IF $TSNUM = 4 .SETS $TSSTR "VAX/VMS"
.;
	.SETF $RSX
	.SETF $VMS
	.IF $TSNUM = 1 .SETT $RSX
	.IF $TSNUM = 2 .SETT $RSX
	.IF $TSNUM = 4 .SETT $VMS
.;
	.IFT $VMS .GOTO X30
    ;
    ;   This command procedure has not been debugged for use under
    ;   an '$TSSTR' host.
    ;
	.EXIT
.X30:
.;
.;
.;  The necessary global symbols can be predefined by the user in an
.;  indirect file called RMUSER.CMD.  If RMUSER.CMD is found in the current
.;  directory, it is executed to define the global symbols.  
.;  The following is an example RMUSER.CMD file.
.;
.;  .ENABLE GLOBAL
.;
.;  .SETS $RMLOC "DR0:[3,64]"	! Device and UIC of the LABSTATION 23
.;				! system images.
.;
.;  .SETS $RMTAR "ARGON"	! Node name of target LABSTATION 23 node
.;				! where task is to be run.
.;
.;  .SETF $RMQT			! Set true if command file 
.;				! informational text should be 
.;				! suppressed, else set false.
.;
.;  .SETT $RMEOX		! Set true if end of execution
.;				! breakpoints are desired, false
.;				! if not.
.;
.;
.;   Test for the presence of RMUSER.CMD.
.;
	.TESTFILE RMUSER.CMD
	.IF <FILERR> NE 1 .GOTO X40
.;
.;   RMUSER.CMD was found.  Invoke it to define the symbols.
.;
	@RMUSER.CMD
.;
.X40:
.;
.;   Determine which globals were defined.
.;
	.SETF DRMLOC
	.SETF DRMTAR
	.SETF DRMEOX
	.SETF DRMQT
	.IFDF $RMLOC .SETT DRMLOC
	.IFDF $RMTAR .SETT DRMTAR
	.IFDF $RMEOX .SETT DRMEOX
	.IFDF $RMQT  .SETT DRMQT
	.IFNDF $RMQT .SETF $RMQT
.;
.;  Get the device and group UIC from $RMLOC if defined.
.;
	.IFF DRMLOC .GOTO X45
	.PARSE $RMLOC ":[," RMDEV N1 GRPUIC N2
.X45:
.;
.;
.;  Print preliminary text information if quiet disabled.
.;
	.IFT $RMQT .GOTO L20
.L10:
     ;
     ; ===========================================================
     ;        LABSTATION 23 Task Development Procedure
     ;           Started at '<TIME>' on '<DATE>'
     ;           Host system is '$TSSTR'
     ; ===========================================================
.;
.;  Give the user any preliminary comments
.;
     ;
     ;   You can get additional information by typing ESC in response
     ;   to any question.
     ;
.L20:
.;
.;   RMUSER.CMD was not found or an error was detected during its
.;   execution.  Ask for the definition of symbols. 
.;   
.X50:
	.IFT DRMLOC .GOTO X53
	.IFT $RMQT .GOTO L55
.L50:
     ;
     ;  During the sysgen and netgen procedures for LABSTATION 23,
     ;  you specified a target device and group UIC number for 
     ;  system.
     ;
.L55:
.;
	.ASKS RMDEV What was the target device during sysgen and netgen
	.IFT <ESCAPE> .GOTO L50
	.ASKN [::3] GRPUIC What was the group UIC number specified
	.IFT <ESCAPE> .GOTO L50
.;
.X53:
	.TEST RMDEV
	.SETS CHAR RMDEV[<STRLEN>:<STRLEN>] 
	.IF CHAR NE ":" .SETS RMDEV "'RMDEV'"+":"
	.TESTFILE 'RMDEV'['GRPUIC',64]RMMAST.SYS
	.IF <FILERR> EQ 1 .GOTO X55
.;
.;  Here if error detected while looking for image file.
.;
     ;
     ;  An error was detected while trying to access needed files
     ;  on 'RMDEV'['GRPUIC',64].
     ;
     ;  This file and others in the requested location are required
     ;  for this procedure.  Please confirm the location of the 
     ;  LABSTATION 23 system files.
     ;
	.EXIT
.X55:
	.SETS $RMDEV "'RMDEV'"
	.SETS $RMUIC "['GRPUIC',64]"
	.SETS $RMLOC "'RMDEV'['GRPUIC',64]"
.;
.;  Request the target node name.
.;
.X60:
	.IFT DRMTAR .GOTO X61
	.IFT $RMQT .GOTO L65
.L60:
;
;  Tasks developed using this procedure are destined to execute in
;  a LABSTATION 23 node.  This node is known to the network by a node
;  name.
;
.L65:
	.ASKS $RMTAR [1:6] What is the LABSTATION 23 target node name
	.IFT <ESCAPE> .GOTO L60
.;
.; We can check the LABSTATION 23 data file for the entered node name.
.; If it's not there, it hasn't been configured.
.;
.X61:
	.OPENR #1 '$RMLOC'RMNODES.DAT
	.SETF FOUND
.X62:
	.READ #1 LINE
	.IF <FILERR> NE 1 .GOTO X66
	.IFF $VMS .GOTO X64
	.SETS TOKEN "'$RMTAR'"
	.SETN X 'F$LOCATE(TOKEN,LINE)'
	.GOTO X65
.X64:
.X65:
	.TEST LINE
	.IF <STRLEN> EQ X .GOTO X62
	.SETT FOUND
.;
.;  Also extract the system image file name for this node.
.;  We need the file name for VMRing the image with the new task.
.;
	.PARSE LINE "  " N1 N2 N3 $RMIMG
.X66:
	.CLOSE #1
	.IFT FOUND .GOTO X70
;
;  Node '$RMTAR' is not configured as a LABSTATION 23 node.  Either
;  configure '$RMTAR' as a LABSTATION 23 node or select another target
;  node.
;
	.EXIT
.;
.;  Ask about turning off messages.
.;
.X70:
	.IFT DRMQT .GOTO X80
	.IFT $RMQT .GOTO L75
.L70:
;
;  Informational remarks during this procedure can be suppressed
;  by answering yes to the following question.  Note that error
;  information is always displayed.
;
.L75:
	.ASK $RMQT Should informational remarks be suppressed
	.IFT <ESCAPE> .GOTO L70
.;
.; Ask about end-of-execution breakpoints
.;
.X80:
	.IFT DRMEOX .GOTO X85
	.IFT $RMQT .GOTO L85
.L80:
;
;  End of execution breakpoints occur after the execution of the
;  editor, compiler, task builder and the VMR task.  You can request
;  these breakpoints by answering yes to the following question.
;
.L85:
	.ASK $RMEOX Do you want end-of-execution (EOX) breakpoints
	.IFT <ESCAPE> .GOTO L80
.X85:
.;
.X200:
.;
.;
.;  All symbols have been defined.  Just the filename can be entered
.;  here.  If the user supplied a filename during invocation, it is
.;  in P1.
.;
	.IF P1 EQ "" .GOTO X205
	.SETS $RMFIL P1[1:6]
	.GOTO L220
.X205:
	.IFT $RMQT .GOTO L210
.L200:
;
;  Enter is the source file name of the target task.  Do not enter the
;  file extension as .FTN is assumed.
;
.L210:
	.ASKS $RMFIL What is the target task name
	.IFT <ESCAPE> .GOTO L200
	.IF $RMFIL EQ "" .GOTO L200
.L220:
	.SETS FILEXT ".FTN"
.;
.;  Define needed tasks.
.;
	ASN '$RMLOC'11MTKB.TSK=TKB
	ASN '$RMLOC'11MVMR.TSK=VMR
.;
.;  Establish the present directory.
.;
	.SETS SAVDIR "'<UIC>'"
	.IFF $VMS .GOTO X505
	.SETS SAVDEV "'F$LOGICAL("SYS$DISK")'"
	.SETS SAVUIC "'F$USER()'"
	.SETS LIBDEV "'F$LOGICAL("SYS$SYSDEVICE")'"
.X505:
.;
.;  This is the main development loop starting point.
.;
.X300:
.;
.;  Reset to the original directory.
.;
	SET UIC 'SAVUIC'
	SET DEF 'SAVDIR'
.;
.;  Invoke the editor.
.;
	ASN TT:=SYS$INPUT
	EDT '$RMFIL''FILEXT'
.;
.X310:
	.SETS MSG "Source editing complete.  Ready to compile."
	.SETS ENTRY "X300"
	.GOSUB X1000
.X400:
.;
.;  Compile the task.
.;
	FOR '$RMFIL','$RMFIL'/-SP='$RMFIL''FILEXT'
	.SETN STATUS '<EXSTAT>'
	PURGE '$RMFIL'.LST
	.IF STATUS EQ 1 .GOTO X410
.;
	.SETS MSG " Error during compilation."
	.SETS ENTRY "X300"
	.GOSUB X1100
.X410:
	.SETS MSG "Compilation complete.  Ready to task build."
	.SETS ENTRY "X300"
	.GOSUB X1000
.;
	COPY '$RMFIL'.OBJ '$RMLOC''$RMFIL'.OBJ
	PURGE '$RMFIL'.OBJ,'$RMLOC''$RMFIL'.OBJ
.;
.X500:
.;
.;  Task build the image.  From here on, all activity must take place
.;  in the LABSTATION 23 system directory since the utilities require
.;  UIC's, not VMS literal directory spec.
.;
	ASN '$RMDEV'=SY:
	ASN '$RMDEV'=SY0:
	ASN '$RMDEV'=LB:
	ASN '$RMDEV'=LB0:
	SET DEF '$RMDEV'
	SET UIC '$RMUIC'
.;
.;  If the user has a file with an extension of .TKB, it's task
.;  builder command file for $RMFIL.  So use it instead of the 
.;  standard file.
.;
	.TESTFILE '$RMFIL'.TKB
	.IF <FILERR> NE 1 .GOTO X510
.;
	TKB @'$RMFIL'.TKB
	.SETN STATUS '<EXSTAT>'
	.GOTO X520
.;
.X510:
	.OPEN #1 RMTKB.TMP
.ENABLE DATA #1
'$RMLOC''$RMFIL'.TSK/PR:0/AL/FP,'$RMFIL'/-SP='$RMFIL'
'$RMLOC'R11LIB.OLB/LB
'$RMLOC'NETFOR.OLB/LB
'$RMLOC'FOROTS.OLB/LB
'$RMLOC'11SLIB.OLB/LB
'$RMLOC''$RMIMG'.STB/SS
/
RESCOM=KPAGE/RW:7
TASK='$RMFIL'
PAR=GEN
//
.DISABLE DATA #1
.;
	.CLOSE #1
.;
	TKB @RMTKB.TMP
	.SETN STATUS '<EXSTAT>'
	DEL RMTKB.TMP;0
	.IFT $VMS SET PROT=WORLD:RWE '$RMFIL'.TSK
	.IFT $VMS PURGE '$RMFIL'.TSK,'$RMFIL'.MAP
.X520:
	.IF STATUS EQ 1 .GOTO X530
.;
	.SETS MSG " Error during task build."
	.SETS ENTRY "X300"
	.GOSUB X1100
.X530:
.SETS MSG "Task build complete.  Ready to update '$RMTAR' image."
	.SETS ENTRY "X300"
	.GOSUB X1000
.;
.X700:
.;
.;  Update the host loader tables with the task name.
.;
.;  If the host loader table knows about the task under the target
.;  node name, we are done.  Otherwise update the table to reflect
.;  the task.
.;
	.IFT $VMS .OPENR #1 SYS$SYSTEM:HLD.DAT
	.IFT $VMS .OPEN #2 SYS$SYSTEM:HLD.TMP
	.SETF FOUND
.L700:
	.READ #1 LINE
	.IF <FILERR> NE 1 .GOTO L770
.;
.;  Copy the line to the new file.
.;
	.DATA #2 'LINE'
.;
.;  First find the node corresponding to the target node.  This is
.;  guaranteed since the node name was found in RMNODES.DAT.
.;
	.IFT $VMS .SETN X 'F$LOCATE("HNODE$",LINE)'
	.TEST LINE
	.IF <STRLEN> EQ X .GOTO L700
.;
.;  Node definition found.
.;
	.IFF $VMS .GOTO L705
	.SETS TOKEN "'$RMTAR'"
	.SETN X 'F$LOCATE(TOKEN,LINE)'
	.TEST LINE
	.IF <STRLEN> EQ X .GOTO L700
.;
.;  Target node found.  If the next line in the file is not a task
.;  definition line, then no task definition exists for this node,
.;  so add this task.
.;
.X710:
	.READ #1 LINE
	.IF <FILERR> NE 1 .GOTO 770
	.IFF $VMS .GOTO X715
.X715:
	.SETN X 'F$LOCATE("HTASK$",LINE)'
	.TEST LINE
	.IF <STRLEN> EQ X .GOTO L760
.;
.;  Here if a task definition line was found.  Is it our task?
.;
	.SETS TOKEN "'$RMFIL'"
	.IFF $VMS .GOTO X717
	.SETN X 'F$LOCATE(TOKEN,LINE)
.X717:
	.IF <STRLEN> NE X .GOTO L720
.;
.;  Our task not found.  Copy the task line and read another.
.;
	.DATA #2 'LINE'
	.GOTO X710
.L720:
.;
.;  Here if the task was found.  We don't need a new host loader 
.;  table, so close and delete the temporary file.
.;
	.CLOSE #1
	.CLOSE #2
	.SETT FOUND
	.IFT $VMS DELETE SYS$SYSTEM:HLD.TMP;0	
	.GOTO X790
.L760:
.;
.;  Here if the task was not found in the tables.  Add the task
.;  definition and the line we read.
.;
	.DATA #2 HTASK$ '$RMFIL',<'$RMLOC''$RMFIL'.TSK>
	.DATA #2 'LINE'
.;
.;  Copy the rest of the file.
.;
.L765:
	.READ #1 LINE
	.IF <FILERR> NE 1 .GOTO L768
	.DATA #2 'LINE'
	.GOTO L765
.;
.L768:
	.CLOSE #1
	.CLOSE #2
	.IFT $VMS RENAME SYS$SYSTEM:HLD.TMP SYS$SYSTEM:HLD.DAT
	.IFT $VMS SET PROT=WORLD:RWED SYS$SYSTEM:HLD.DAT
	.IFT $VMS PURGE SYS$SYSTEM:HLD.DAT KEEP=3
	.GOTO X790
.;
.L770:
;
;  LABSTATION 23 data tables and the host loader tables do not
;  agree.  Please reconfigure the network using the LABSTATION 23
;  network configuration procedure.
;
	.GOTO X990
.;
.X790:
.X600:
.;
.;  Update the correct system image with the new task using VMR.
.;  
.;
	.OPEN #1 RMVMR.TMP
.;
	.DATA #1 '$RMIMG'
	.IFT FOUND .DATA #1 REM '$RMFIL'
	.DATA #1 INS '$RMFIL'
.;
	.CLOSE #1
.;
	VMR @RMVMR.TMP
.;
	.SETN STATUS '<EXSTAT>'
.;	DEL @RMVMR.TMP
	.IF STATUS EQ 1 .GOTO X610
.;
	.SETS MSG " Error during VMR of system image."
	.SETS ENTRY "X300"
	.GOSUB X1100
.X610:
.;
.SETS MSG "VMR process complete.  Ready to downline load node '$RMTAR'"
	.SETS ENTRY "X300"
	.GOSUB X1000
.;
.X800:
.;
.;  Downline load the target system.
.;
	.OPEN #1 RMNCP.TMP
	.IFT $VMS .DATA #1 RUN SYS$SYSTEM:NCP
	.DATA #1 LOAD NODE '$RMTAR'
	.CLOSE #1
.;
	.IFT $VMS @RMNCP.TMP
	.IFT $RSX NCP @RMNCP.TMP
	.IFT $VMS DELETE RMNCP.TMP;0
.;
.X850:
	.SETS MSG "End of downline load."
	.SETS ENTRY "X300"
	.GOSUB X1100
.;
.X990:
.;
.;  EXIT POINT
.;
.;  Make sure the default directory and uic are reset.
.;
	SET UIC 'SAVUIC'
	SET DEF 'SAVDEV''SAVDIR'
.;
	.IFT $RMQT .GOTO X995
;
;  End of procedure.
;
.X995:
	.EXIT
.;
.;  Subroutines
.;
.X1000:
.;
.;  This subroutine issues the end of breakpoint messages and 
.;  transfers control based on the response.  It also prints informative
.;  messages if enabled.
.;
	.IFT $RMQT .GOTO X1010
    ;
    ; 'MSG'
    ;
.X1010:
	.IFF $RMEOX .RETURN
.ASKS Q  Do you want to continue <RET>, exit <E>, pause <P>, or repeat <R>
	.IF Q EQ "" .RETURN
	.IF Q EQ "E" .GOTO X990
	.IF Q EQ "R" .GOTO 'ENTRY'
	.IF Q NE "P" .GOTO X1000
	.PAUSE
	.GOTO X1000
.;
.X1100:
.;
.;  This subroutine issues the end of breakpoint messages and 
.;  transfers control unconditionally.
.;
    ;
    ; 'MSG'
    ;
.X1110:
.ASKS Q  Do you want to continue <RET>, exit <E>, pause <P>, or repeat <R>
	.IF Q EQ "" .RETURN
	.IF Q EQ "E" .GOTO X990
	.IF Q EQ "R" .GOTO 'ENTRY'
	.IF Q NE "P" .GOTO X1110
	.PAUSE
	.GOTO X1100
