! ! C R E A T E _ D E C T E R M . B A S ! ! ! Martin D. Lucas ! Allied Electronics, Inc. ! 7410 Pebble Drive ! Fort Worth, TX 76118 ! (817) 595-3500 ! ! This program creates a DECterm window using the existing display ! as defined by the logical name DECW$DISPLAY. An interactive ! detached process will also be created. This program uses tips and ! techniques from various other programs found on DECUS tapes and ! on DSNLINK. ! ! Requirements: ! ! Privs: ALTPRI, DETACH ! Files: DECW$USER_DEFAULTS:DECW_'nodename'_DECTERM.DAT PROGRAM Create_DECterm OPTION TYPE = EXPLICIT, & SIZE = (REAL DOUBLE, INTEGER LONG), & CONSTANT TYPE = INTEGER %INCLUDE "$JPIDEF" %FROM %LIBRARY "SYS$LIBRARY:BASIC$STARLET" %INCLUDE "$LNMDEF" %FROM %LIBRARY "SYS$LIBRARY:BASIC$STARLET" %INCLUDE "$PRCDEF" %FROM %LIBRARY "SYS$LIBRARY:BASIC$STARLET" %INCLUDE "$SYIDEF" %FROM %LIBRARY "SYS$LIBRARY:BASIC$STARLET" DECLARE STRING Setup_File ! Mapped variables for devices, etc... MAP (Device_Attributes) & STRING Device_Name = 50, & STRING Display_Device = 50, & WORD Name_Length, & STRING Node_Name = 15, & LONG Node_Name_Len, & STRING File_Location=255, & LONG File_Loc_Len, & LONG PID, & LONG PID_LEN, & STRING HEX_PID=8 DECLARE STRING Customization_String, & Terminal_Name DECLARE LONG Return_Status, & Status_Flag EXTERNAL LONG FUNCTION Decw$Term_Port EXTERNAL LONG FUNCTION Sys$Creprc EXTERNAL LONG FUNCTION Sys$GetJpiw EXTERNAL LONG FUNCTION Sys$GetSyiw EXTERNAL LONG FUNCTION Sys$Trnlnm EXTERNAL SUB OTS$CVT_L_TZ ! Declare the itemlist structure RECORD Itembuf GROUP Item(1) VARIANT CASE WORD Buffer_length WORD Item_code LONG Buffer_address LONG Return_length_address CASE LONG List_terminator END VARIANT END GROUP Item END RECORD ItemBUF DECLARE ItemBUF Itemlist ! Begin the main program ! Get process info Itemlist::Item(0)::Buffer_length = 4 Itemlist::Item(0)::Item_code = JPI$_PID Itemlist::Item(0)::Buffer_address = LOC(pid) Itemlist::Item(0)::Return_length_address = LOC(pid_len) Itemlist::Item(1)::List_terminator = 0 Return_Status = SYS$GETJPIW(,,,Itemlist,,,) ! Convert it CALL OTS$CVT_L_TZ(PID,HEX_PID,8% BY VALUE,,) ! Get nodename info Itemlist::Item(0)::Buffer_length = 15 Itemlist::Item(0)::Item_code = SYI$_Nodename Itemlist::Item(0)::Buffer_address = LOC(Node_name) Itemlist::Item(0)::Return_length_address = LOC(Node_Name_Len) Itemlist::Item(1)::List_terminator = 0 Return_Status = SYS$GETSYIW(,,,Itemlist,,,) ! Stop if we the previous function was in error CALL Lib$Stop(Return_Status BY VALUE) IF (Return_Status AND 1%) = 0% ! Find the logical name for where the user's resource files are kept Itemlist::Item(0)::Buffer_length = 255 Itemlist::Item(0)::Item_code = LNM$_String Itemlist::Item(0)::Buffer_address = LOC(File_Location) Itemlist::Item(0)::Return_length_address = LOC(File_Loc_Len) Itemlist::Item(1)::List_terminator = 0 Return_Status = SYS$TRNLNM(,"LNM$JOB","DECW$USER_DEFAULTS",,ItemList) ! Build the file name Setup_File = edit$(File_Location,140) + & "DECW_" + & EDIT$(Node_Name,140) + & "_Decterm.dat" ! Add any special customizations here, other than in the setup file Customization_String = "DECW$TERMINAL.title: " + & EDIT$(Node_name,140) + & " Window " + LF + & "DECW$TERMINAL.iconName: " + & EDIT$(Node_name,140) ! Create a Decterm terminal window, passing the name of a setup file and ! a customization string Return_Status = Decw$Term_Port( , & TRM$(Setup_File), & TRM$(Customization_String), & Device_Name, & Name_Length) Call Lib$Stop(Return_Status BY VALUE) IF (Return_Status AND 1%) = 0% ! Create a detached/interactive process that uses the decterm window for ! its terminal device. The process will appear already logged in. Status_Flag = PRC$M_Detach OR PRC$M_Inter OR PRC$M_Nopassword ! 4% below is the desired priority of the process. If DECTERM.EXE is not ! installed with ALTPRI, the priority will be the default rather than the ! specified value here. Return_Status = SYS$CREPRC(,"Sys$System:Loginout.exe", & Device_Name, & Device_Name,,,, & Hex_Pid, & 4% by value,,, & Status_Flag by value) Call Lib$Stop(Return_Status BY VALUE) IF (Return_Status AND 1%) = 0% END