![]() |
![]() HP OpenVMS Systemsask the wizard |
![]() |
The Question is: I am attempting to connect to a remote LAT service using a $QIOW call in Pascal. I used the LAT.C example found in the VMS IO Reference Manual as a guide. According to the example as well as the IO Ref. documentation, the above program should work. I am r eceiving a status of SS$_BADPARAM in W1 of the IO status block. Do you have another example that has been proven to work? If not, could you possibly tell me what is wrong with my test application? Thank you for your time and consideration. The Answer is : Here is a very old example of a related series of Pascal calls: PROGRAM SAMPLE: [INHERIT ('SYS$LIBRARY:STARLET')] PROGRAM lat_setmode(INPUT,OUTPUT); {COPYRIGHT 2002 Compaq Information Technologies Group, L.P.} CONST text_string = 'Please enter your name: '; terminal = 'LTA0:'; {the template device} (* The following symbols are defined in SYS$LIBRARY:LATDEF.MAR *) LAT$_ITM_TARGET_NODE_NAME = 16648; LAT$_ITM_TARGET_PORT_NAME = 16649; LAT$_ITM_PORT_TYPE = 17; LAT$C_PT_APPLICATION = 2; LAT$_ITM_QUEUED = 18; LAT$C_ENABLED = 1; LAT$C_ENT_PORT = 4; LAT$C_ENTS_UNK = 2; LAT$C_ENTS_DEL = 3; TYPE word_integer = [WORD] 0..65535; byte_integer = [BYTE] 0..255; io_block = RECORD io_stat, count : word_integer; dev_info : INTEGER END; item = RECORD nodnam : word_integer; count1 : byte_integer; array1 : packed array [1..5] of char; pornam : word_integer; count2 : byte_integer; array2 : packed array [1..6] of char; portyp : word_integer; actype : integer; queue : word_integer; qtype : integer; END; { *NOTE* remember to adjust the bounds of the array type and variable definitions to suit the length of your server and port names. Rather inelegant, but clarity prevails!} VAR term_chan : word_integer; sys_stat, entity_type : INTEGER; greeting : VARYING [50] of CHAR := 'Hi '; input_string : VARYING [50] of CHAR; output_string : VARYING [50] of CHAR; iostat_block : io_block; item_list : item; servername : packed array [1..5] of CHAR := 'DS200'; portname : packed array [1..6] of CHAR := 'PORT_4'; (* Declare external RTL routine *) PROCEDURE LIB$STOP( %IMMED cond_value: INTEGER); EXTERN; BEGIN {Assign to LTA0:, a new LTA device is created with the channel No. returned} sys_stat:= $ASSIGN( terminal, term_chan); IF NOT ODD( sys_stat) THEN LIB$STOP( sys_stat); {set up the item list for the SETMODE} item_list.nodnam := LAT$_ITM_TARGET_NODE_NAME; item_list.count1 := length(servername); item_list.array1 := servername; item_list.pornam := LAT$_ITM_TARGET_PORT_NAME; item_list.count2 := length(portname); item_list.array2 := portname; item_list.portyp := LAT$_ITM_PORT_TYPE; item_list.actype := LAT$C_PT_APPLICATION; item_list.queue := LAT$_ITM_QUEUED; item_list.qtype := LAT$C_ENABLED; {set up P3 for the SETMODE} entity_type := LAT$C_ENT_PORT + (65536 * LAT$C_ENTS_UNK); {65536 (or 2**16) is used to shift the status to bit positions 16-19} {issue a SETMODE to map the new LTA device to the port} sys_stat:= $QIOW( chan:= term_chan, func:= IO$_TTY_PORT + IO$M_LT_SETMODE, iosb:= iostat_block, p1:= item_list, p2:= size(item_list), p3:= entity_type); IF NOT ODD( sys_stat) THEN LIB$STOP( sys_stat); IF NOT ( iostat_block.io_stat= SS$_NORMAL) THEN LIB$STOP( iostat_block.io_stat ); (* make the connection to LAT port, assuming it will be successful, since the connect request status is only tested for SS$_NORMAL *) sys_stat:= $QIOW( chan:= term_chan, func:= IO$_TTY_PORT + IO$M_LT_CONNECT, iosb:= iostat_block); IF NOT ODD( sys_stat) THEN LIB$STOP( sys_stat); IF NOT ( iostat_block.io_stat= SS$_NORMAL) THEN LIB$STOP( iostat_block.io_stat ); (* Output the message *) sys_stat:= $QIOW( chan:= term_chan, func:= IO$_WRITEVBLK, iosb:= iostat_block, p1:= text_string, p2:= LENGTH(text_string), p4:= 32); IF NOT ODD( sys_stat) THEN LIB$STOP( sys_stat); IF NOT ODD( iostat_block.io_stat) THEN LIB$STOP( iostat_block.io_stat ); (* Read in from the decserver port *) sys_stat:= $QIOW( chan:= term_chan, func:= IO$_READVBLK, iosb:= iostat_block, p1:= input_string.BODY, p2:= LENGTH(input_string.BODY)); IF NOT ODD( sys_stat) THEN LIB$STOP( sys_stat); IF NOT ODD( iostat_block.io_stat) THEN LIB$STOP( iostat_block.io_stat ); (* Initialize VARYING string length with returned byte count *) input_string.LENGTH := iostat_block.count; (* Now output the greeting *) output_string := greeting + input_string; sys_stat:= $QIOW( chan:= term_chan, func:= IO$_WRITEVBLK, iosb:= iostat_block, p1:= output_string.body, p2:= output_string.length, p4:= 32); IF NOT ODD( sys_stat) THEN LIB$STOP( sys_stat); IF NOT ODD( iostat_block.io_stat) THEN LIB$STOP( iostat_block.io_stat ); (* disconnect lat connection *) sys_stat:= $QIOW( chan:= term_chan, func:= IO$_TTY_PORT + IO$M_LT_DISCON, iosb:= iostat_block); IF NOT ODD( sys_stat) THEN LIB$STOP( sys_stat); IF NOT (iostat_block.io_stat = SS$_NORMAL) THEN LIB$STOP( iostat_block.io_stat ); {Now use SETMODE again to delete the port} entity_type := LAT$C_ENT_PORT + (65536 * LAT$C_ENTS_DEL); sys_stat:= $QIOW( chan:= term_chan, func:= IO$_TTY_PORT + IO$M_LT_SETMODE, iosb:= iostat_block, p1:= item_list, p2:= size(item_list), p3:= entity_type); IF NOT ODD( sys_stat) THEN LIB$STOP( sys_stat); IF NOT ( iostat_block.io_stat= SS$_NORMAL) THEN LIB$STOP( iostat_block.io_stat ); {finally, deassign the channel} sys_stat:= $DASSGN( term_chan); IF NOT ODD( sys_stat) THEN LIB$STOP( sys_stat); END.
|