From:	MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX" 14-JUN-1992 23:46:52.36
To:	info-vax@kl.sri.com
CC:	
Subj:	Regarding: Need $SEND program

MFS> From: "Michael F. Santangelo" <MIKE@KAVISHAR.UMD.EDU>
MFS> Subject: Need simple $ SEND program
MFS> 
MFS> Some time ago, someone posted a relatively simple source (was in FORTRAN)
MFS> for a $ SEND command that simply sent a message to a locally logged
MFS> on user, for example:
MFS>  
MFS>   $ SEND JOHNDOE "Hi there, you must get comments about your username!"
MFS>  
MFS> All it did was front-end the $BRKTHRU (?) system service passing the
MFS> appropriate info from the command line args.  Could someone re-post
MFS> this program?  I know it is probably on some ancient DECUS sig-tape,
MFS> but I don't have access to any and I just want to get this put up
MFS> quick-and-dirty.  Thanks!

Hello Michael

Below my signature please find a simple program in VAX Basic that utilizes the
SYS$BRKTHRU system service to send messages to another user's terminal(s).

You will need to cut out the first 3 lines and save in SEND.CLD, and the rest
in SEND.BAS. To compile SEND.BAS type:

                $ BAS SEND
                $ LINK SEND

You will need to replace DISK$PATH in SEND.CLD with Device/path where SEND.EXE 
resides.

To use send type:

                $ Set Command SEND
                $ SEND user_name "message_text".

You will need to execute the command SET COMMAND SEND only once per session.
Hope this helps.

.-Sal A Kabalani------------------------+-Internet : SK89221 @ Acad.Drake.Edu-.
| Supervisor of Operations/Data Systems | Bitnet   : SK89221 @ DRAKE          |
| Iowa Network Services                 | WWIV-link: 12 @ 25555               |
| 4201 Corporate Drive                  | Fax-Net  : (515) 830-0123/0124      |
| Des Moines, Iowa 50265                | Phone-Net: (515) 830-0436/0110      |
| Disclaimer: My opinions are not mine. I dont even know this Sal person.     |
`----------------------- Programmers Do It With a Byte -----------------------'


!-------------------------- CUT HERE AND SAVE IN SEND.CLD ---------------------!
Define Verb SEND
    Image     Disk$Path:send
    Parameter P1 Label=USR, PROMPT="Send to ", Value(REQUIRED, TYPE=$Quoted_String)
    Parameter P2 Label=TXT, PROMPT="Message ", Value(REQUIRED, TYPE=$Quoted_String)    

!-------------------------- CUT HERE AND SAVE IN SEND.BAS ---------------------!

!------------------------------------------------------------------------------.
!  Program name : SEND.BAS   
!       Purpose : Sends a message to logged in user terminal(s)           
!        Author : Saleh Kabalani, INS.                                    
!          Date : 14-JUN-1992                                             
!         Usage : $ Set Command SEND
!                 $ Send user_name message_text
!   Mod History : Ver  INI	Date		Description                          
!------------------------------------------------------------------------------'
option type = explicit
%include "$BRKDEF" %from %library "SYS$LIBRARY:BASIC$STARLET.TLB"
%include "$SSDEF" %from %library "SYS$LIBRARY:BASIC$STARLET.TLB"
!
    Record IO_Status_Block
        Word Stat
        Word Succ
        Word Timeout
        Word nobrd
    End Record 
    RECORD      Item_List_3  
        GROUP   item (0)     
            WORD    Buffer_Length 
            WORD    Item_Code     
            LONG    Buffer_Address
            LONG    Return_Length_Address  
        END GROUP
        LONG    Terminator
    END RECORD
!
External Long Function  SYS$Brkthru, Sys$GetJPI
External sub CLI$GET_Value
!                        
External Long Constant Brk$C_UserName, JPI$_Username
External Long Constant SS$_Normal, SS$_AccVIO, SS$_BadParam, SS$_ExQuota, &
                       SS$_InsfMem, SS$_NonLocal, SS$_Nooper, SS$_NoSuchDev
!
map (buff_map)      string  all_msg   = 240%
map (buff_map)      string  MsgBuf80  =  80%
map (buff_map)      string  MsgBuf160 = 160%   
map (buff_map)      string  MsgBuf240 = 240%
map (brkthru_Vars)  String  sendto    = 12% , &
                    Long    Sndtyp       , &
                    Long    Stat         , &
                    Long    TimOut       , &
                    Long    Carcon
Common (getjpi_buff) String     Username = 12%
                
Declare string msgbuf
DECLARE	WORD username_Length, Sys_Status
Declare	Item_List_3	Item_List
Declare IO_Status_Block IOSB

! Get username

    Item_List::Item(0)::Buffer_Length = 12%                        
    Item_List::Item(0)::Item_Code = JPI$_username                  
    Item_List::Item(0)::Buffer_Address = LOC(username)         
    Item_List::Item(0)::Return_Length_Address = LOC(username_length)
    Item_List::Terminator = 0                                       
    Sys_Status = SYS$GetJPI (,,,Item_List,,,)                       

! Get command line parameters

    Call CLI$GET_Value ("USR", sendto)
    Call CLI$GET_Value ("TXT", msgbuf)
    msgbuf = edit$(username, 2%) + " > " + msgbuf
    All_Msg = msgbuf

! send message to user

    Select len(msgbuf)
        Case <= 80  ! if message <= 80 bytes long
            Stat = SYS$Brkthru (!efn!, Msgbuf80, SendTo,         &
                   Brk$C_UserName by VALUE, iosb by REF, '5'L,   &
                   !flags!,!reqid!, '5'L,!astadr!,!astprm!)
        Case <= 160 ! if 80 < message <= 160 bytes long
            Stat = SYS$Brkthru (!efn!, Msgbuf160, SendTo,        &
                   Brk$C_UserName by VALUE, iosb by REF, '5'L,   &
                   !flags!,!reqid!, '5'L,!astadr!,!astprm!)
        Case <= 240 ! if 160 < message <= 240
            Stat = SYS$Brkthru (!efn!, Msgbuf240, SendTo,        &
                   Brk$C_UserName by VALUE, iosb by REF, '5'L,   &
                   !flags!,!reqid!, '5'L,!astadr!,!astprm!)
    End Select
    
    select Stat
        Case = SS$_Normal
            Select IOSB::Stat
                Case = SS$_DEVOFFLINE
                    Print "%SEND-E-NOSUCHUSER User not logged on."
                Case = SS$_Normal
                    Print "%SEND-I-USERNOTFID User notified";
                    if iosb::Succ > 1 then
                        Print ", (";iosb::Succ;") terminals."
                    Else
                        Print "."
                    End if
                Case = 0%
                    Print "%SEND-E-NOBRDCST User terminal set to NOBROADCAST." If IOSB::nobrd
                    Print "%SEND-E-TIMEOUT  User is not accepting output."     If IOSB::timeout
                Case else
            End Select
        Case = SS$_DEVOFFLINE
            Print "%SEND-E-NOSUCHUSER User not logged on."
        Case Else
            Print "%SEND-E-GENERAL Error";Stat;". Message not sent."
    End Select
End ! SEND.BAS

