Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Question about device information in YottaDB

55 views
Skip to first unread message

Kevin Toppenberg

unread,
Mar 14, 2024, 2:09:32 PM3/14/24
to Everything MUMPS
In the console, programs often have to change modes of IO operation.  For example to handle escape sequences, or to draw in special ways on the screen.  INITKB^XGF() in the VistA system, will set up a special processing to enable arrow keys.  And when done, one my USE $P to return to  prior functioning. 

I have been having trouble with AUTOMARG^XVEMKY, which issues an escape sequence to query the terminal as to its actual size.  Sometimes this works and sometimes it doesn't.  I big variable seems to be if I have run my debugger first.  When I do, it apparently changes some parameter such that it doesn't work. And I am having a hard time figuring out the problem. 

In my debugger, as I display to the screen the current program location and code text listing, I first save off the current device, draw the screen, then try to restore the previous IO environment.

SET SAVEDIO=$IO
then USE $P:(WIDTH=tmgScrWidth:NOWRAP)
then <draw to screen>
then USE SAVEDIO   <--------- This will loose any prior device parameters.

Again, this works most of the time, but not always.

The problem is that if $IO has some device parameters, such as NOWRAP etc etc, then these will be lost.

yottadb>zshow "D"
/dev/pts/1 OPEN TERMINAL NOPAST NOESCA NOREADS TYPE WIDTH=165 LENG=51 FIL=ESCAPES

Above seems to show some device parameters that I could parse out , but I don't recognize that "OPEN" and "TERMINAL" parts.  Should I just start at the 4th one and onward?

Questions:
1) I have never seen anyone else's code seem to try to save off device parameters when switching, so that the prior can be restored.  Is this not needed?  What am I missing?

2) What are the 'OPEN' and 'TERMINAL'  entries from the zshow "D" from above?

3) Does ZSHOW "D" show all the information known about a device?  For example, I think that $X and $Y are device dependent.  And I suspect that after switching, they will be restored.  How would one see that info?  And having to manually parse of the text output from ZSHOW seems archaic.  Is there not a more direct way?

4) $IO stores the current device, but not the current device parameters.  Why does M depend on a YottaDB extension to provide access to device parameters?

Thanks in advance. 

Kevin

K.S. Bhaskar

unread,
Mar 14, 2024, 2:48:09 PM3/14/24
to Everything MUMPS
Kevin –

The OPEN in ZSHOW "D" says that the device is OPEN. A device can also be CLOSED, if the NODESTROY device parameter (https://docs.yottadb.com/ProgrammersGuide/ioproc.html#destroy) is used with CLOSE. For example:

YDB>zshow "d"
/dev/pts/1 OPEN TERMINAL NOPAST NOESCA NOREADONLY TYPE WIDTH=133 LENG=40

YDB>set f="/tmp/tmp.tmp" open f use f write $zversion,! close f:nodestroy

YDB>zshow "d"
/dev/pts/1 OPEN TERMINAL NOPAST NOESCA NOREADONLY TYPE WIDTH=133 LENG=40
/tmp/tmp.tmp CLOSED

YDB>set f="/tmp/tmp.tmp" open f use f write $zversion,! close f:destroy

YDB>zshow "d"
/dev/pts/1 OPEN TERMINAL NOPAST NOESCA NOREADONLY TYPE WIDTH=133 LENG=40

YDB>set f="/tmp/tmp.tmp" open f use f write $zversion,! use $principal

YDB>zshow "d"
/dev/pts/1 OPEN TERMINAL NOPAST NOESCA NOREADONLY TYPE WIDTH=133 LENG=40
/tmp/tmp.tmp OPEN RMS

YDB>


The TERMINAL says that the device is a terminal (https://docs.yottadb.com/ProgrammersGuide/ioproc.html#using-terminals), and for historical reasons the sequential file (https://docs.yottadb.com/ProgrammersGuide/ioproc.html#using-sequential-files) is referred to as an RMS file.

$X and $Y are intrinsic special variables that the debugger can save and restore, after adjusting for any changes that the debugging session made to the X and Y positions.

Regards
– Bhaskar

Kevin Toppenberg

unread,
Mar 14, 2024, 4:44:41 PM3/14/24
to Everything MUMPS
Bhaskar, thank you for your reply.

Based on your reply, I see that $X and $Y are not intrinsically maintained for each device, and that when switching between devices, the user must manually set them to their correct values.  That seems odd.  Is that really the way it works?

As another issue, it seems that when specifying a device parameter, it does NOT affect other device parameters. 

yottadb>zshow "D"
/dev/pts/0 OPEN TERMINAL NOPAST NOESCA NOREADS TYPE WIDTH=80 LENG=45

yottadb>use $P:(WIDTH=81)

yottadb>zshow "D"
/dev/pts/0 OPEN TERMINAL NOPAST NOESCA NOREADS TYPE WIDTH=81 LENG=45

yottadb>use $P

yottadb>zshow "D"
/dev/pts/0 OPEN TERMINAL NOPAST NOESCA NOREADS TYPE WIDTH=81 LENG=45


Above shows that setting WIDTH does not affect NOESCAPE, for example. 

Thus, if a subroutine were to add a device parameter to a device, then trying to recover with a simple USE $P would NOT be sufficient.  One would have to know how to REMOVE each device parameter that may have been added -- i.e. it's opposite value.   This can be troublesome in that there are so many different device parameters possible, depending on all the different types of devices (https://docs.yottadb.com/ProgrammersGuide/ioproc.html#open).  

E.g. to remove ESCAPE, one would enter NOESCAPE. 
But how to remove things like SHELL="xxx" or COMMAND="yyy"
And if RECORDSIZE was previously set to 1024, would RECORDSIZE=0 be the way to remove it??

Is there a method to CLEAR parameters from a device?

Thanks
Kevin

Kevin Toppenberg

unread,
Mar 14, 2024, 5:24:29 PM3/14/24
to Everything MUMPS
Also,

Is there a list of abbreviations for device parameters? 

In the manual, there is discussion of READSYNC and NOREADSYNC.  ZSHOW "D" is displaying "NOREADS", which I assume is a shortening of NOREADSYNC.   And NOPAST (which I would have thought to mean to let the past slip away) seems to be a shortened form of NOPASTHRU, which is something different entirely.

Is there a rule of how names are shortened, or a standardized listing of the mapping between the two?

Thanks

Kevin

Maury Pepper

unread,
Mar 14, 2024, 5:53:15 PM3/14/24
to everyth...@googlegroups.com
Kevin,

$X and $Y belong to the device not the user. That's especially important with printers. A job needs to know if the device is not at top-of-form with the carriage returned.  Checking $X and $Y allows a print job to determine if it first needs to eject a page before printing.

You should be aware that READ and WRITE will correctly set $X and $Y when executing a ! or #, but not when it's done with something like *13,*10 or $C(13), $C(10) or some escape sequence. Likewise, $X and $Y are typically not updated when the cursor is positioned with an escape sequence.

You might want to create a call or function to clear the current device. You can also have functions to save and restore the current device parameters. I'm not familiar with all of YDB's I/O features, but when I used MSM, it was quite simple to save and restore all parameters for a given device. I'd be surprised if YDB doesn't have something similar. MSM allowed user defined zz-commands and zz-functions, so I defined ZZCLR, a command for clearing the current device. I found that truly clearing a terminal to be more complicated than first expected. Here's what it looked like:

; -----------------------------------------------------
CLR     ; clear screen
        U $IO::"X3.64-1979"
        W /MSMRGN(1,24)         ; restore normal scroll region
        W /SGR(0)               ; set attribute to normal
        W *27,"(B"              ; turn off DEC graphics: turned on w/ ESC(0
        W *15                   ; turn off DEC graphics: turned on w/ *14
        W *27,"[?25h"           ; turn cursor back on.
        U $I:(:::::1)           ; make sure echo is on.
        W /CUP(25,1),/EL        ; erase line 25.
        W /CUP(1,1),/ED         ; erase top 24 lines.
        Q
; -----------------------------------------------------

A similar routine would obviously look different in YDB, but little by little I found all of these steps were required.

    -maury-
--
You received this message because you are subscribed to the Google Groups "Everything MUMPS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to everythingmum...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/everythingmumps/a98805c3-2f98-4fe8-b8aa-8c4ba8bbf193n%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kevin Toppenberg

unread,
Mar 14, 2024, 6:17:12 PM3/14/24
to Everything MUMPS
Maury,

Thanks for this reply.    I agree that $X and $Y should belong to the device.  That is why I was asking how to see what the values are for the various devices, i.e. via ZSHOW "D".  But from Bhaskar's reply, it looks like it is not directly available.  One would have to USE the device in question and then access $X or $Y.

Regarding clearing parameters, it looks like you are using MSM mumps, is this correct?  Looks like you are using U $I:(:::::1), i.e. several (5) blank parameters, and then a 1, to clear out parameters. I wonder if this would work in YottaDB


Kevin

Maury Pepper

unread,
Mar 14, 2024, 6:48:18 PM3/14/24
to everyth...@googlegroups.com
Kevin,

Yes, it is MSM code. I doubt if YDB supports that syntax. It's a holdover from DSM. When PC's became powerful enough to replace PDP-11's, MSM took off by copying DSM's features. Conversion was straight forward.  Per the comment, U $I:(:::::1) simply turned on echo. The blank parameters meant no change to the features controlled by each position. I confess to being to lazy (or busy) to dig into YDB to see how all of this stuff works in that environment.

    -maury-

Sam Habiel

unread,
Mar 14, 2024, 10:04:39 PM3/14/24
to Kevin Toppenberg, Everything MUMPS
Kevin,

No use debugging AUTOMARG^XVEMKY interactively. This call relies on quick internal XTerm terminal responses and make debugging it impossible. Use tracing techniques.

--Sam

--
You received this message because you are subscribed to the Google Groups "Everything MUMPS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to everythingmum...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages