Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

HP COBOL ACCEPT with a masking character

 
John T. Farmer
Regular Advisor

HP COBOL ACCEPT with a masking character

Hi,

I'm looking for a way to accept a field no echo, but display a character mask like "*" or periods, etc. Does HP COBOL have this ability, or does someone have a routine they can share?

Thanks,

John
john dot farmer at genworth dot com
HP COBOL V2.9, OpenVMS 8.3
4 REPLIES 4
Hein van den Heuvel
Honored Contributor

Re: HP COBOL ACCEPT with a masking character


Not in Cobol.

The terminal driver has a 'item'
TRM$_ALTECHSTR which you can used for IO$_READVBLK | IO$M_EXTEND when you also specify TRM$_EDITMODE -> TRM$K_EM_RDVERIFY and
TRM$_MODIFIERS -> TRM$M_TM_NOECHO.

But IMHO that's a nasty piece of work. Hard to program! It's TRM$_PICSTRNG mig help restrict to valid passowrd charcters IF you can describe that with the 5 bits available.

There is an SMG call SMG$_READ_VERIFY which make this a tad easier, but not much.
I'd be tempted to do a plain single character IO reads with no-echo and do your own echo of a "*" for every character received.

Sorry, no example handy.
I can Email a somewhat working QIO_EXTEND example, but it is not good enough for publication.

Hein.
Fekko Stubbe
Valued Contributor

Re: HP COBOL ACCEPT with a masking character

Hi John
I have a program (alas written in fortran) the does shat you want. Maybe you can convert it to cobol. I attached the code
If you have any questions let me know.
Richard J Maher
Trusted Contributor

Re: HP COBOL ACCEPT with a masking character

Hi John,

COBOL has the ACCEPT WITH NO ECHO but won't display your "*" as you type. I'd stick with that, or FMS if you've got it.

In the mean time, as Hein suggested, there's smg$ (I've attached a time format example). And below is snippets from a $qio read verify program.

Please note that both are in upper-case and use hyphens which would date them at 20+ years old. But FWIW. . .

Cheers Richard Maher

*+
* Read Verify Working Storage
*-
01 READ-VERIFY-ITEM-LIST GLOBAL.
03 ITEM-EDITMODE.
05 PIC 9(4) COMP.
05 PIC 9(4) COMP VALUE EXTERNAL TRM$_EDITMODE.
05 PIC 9(9) COMP VALUE EXTERNAL TRM$K_EM_RDVERIFY.
05 PIC 9(9) COMP.
03 ITEM-MODIFIERS.
05 PIC 9(4) COMP.
05 PIC 9(4) COMP VALUE EXTERNAL TRM$_MODIFIERS.
05 RV-MODS PIC 9(9) COMP.
05 PIC 9(9) COMP.
03 ITEM-ESCBUFF.
05 PIC 9(4) COMP.
05 PIC 9(4) COMP VALUE EXTERNAL TRM$_ESCTRMOVR.
05 PIC 9(9) COMP VALUE 4.
05 PIC 9(9) COMP.
03 ITEM-INISTRNG.
05 PIC 9(4) COMP VALUE 1.
05 PIC 9(4) COMP VALUE EXTERNAL TRM$_INISTRNG.
05 POINTER VALUE REFERENCE I-STRING.
05 PIC 9(9) COMP.
03 ITEM-PICSTRNG.
05 PIC 9(4) COMP VALUE 1.
05 PIC 9(4) COMP VALUE EXTERNAL TRM$_PICSTRNG.
05 POINTER VALUE REFERENCE P-STRING.
05 PIC 9(9) COMP.
03 ITEM-PROMPT.
05 PIC 9(4) COMP VALUE 15.
05 PIC 9(4) COMP VALUE EXTERNAL TRM$_PROMPT.
05 POINTER VALUE REFERENCE RV-PROMPT.
05 PIC 9(9) COMP.
*
01 ITEMLIST-LEN PIC 9(4) COMP GLOBAL VALUE 72.
*
01 RV-PROMPT GLOBAL.
03 PIC X VALUE ESC.
03 PIC X VALUE "[".
03 RV-ROW PIC 9(4).
03 PIC X VALUE ";".
03 RV-COL PIC 9(4).
03 PIC X VALUE "f".
03 PIC X VALUE ESC.
03 PIC XX VALUE "[m".
*
/
01 IN-STRING GLOBAL.
03 PIC XX.
03 IN-CODE PIC XXX.
88 GOLD-KEY VALUE "OP".
88 HELP-LOV VALUES "[28", "OQ".
88 NEXT-CHOICE VALUE "[B".
88 PREV-CHOICE VALUES "[A", "[24".
88 NEXT-PAGE VALUE "[6~".
88 PREV-PAGE VALUE "[5~".
88 SLCT-CHOICE VALUES "[4~", "On", "[29", "OM".
88 EXIT-LOV VALUE "[21".
88 CNCL-LOV VALUES "[19", "[23".
*
01 I-STRING PIC X.
01 P-NUMBER PIC 9(4) COMP VALUE EXTERNAL TRM$M_CV_ANY.
01 P-STRING REDEFINES P-NUMBER.
03 PIC X.
*-
01 IOSB GLOBAL.
03 IOSB-STATUS PIC 9(4) COMP.
03 PIC XX.
03 PIC X(4).
01 IO$_READVBLK PIC 9(9) COMP GLOBAL VALUE EXTERNAL IO$_READVBLK.
01 IO$M_EXTEND PIC 9(9) COMP GLOBAL VALUE EXTERNAL IO$M_EXTEND.
01 TRM$M_TM_NORECALL PIC 9(9) COMP GLOBAL VALUE EXTERNAL TRM$M_TM_NORECALL.
01 TRM$M_TM_NOECHO PIC 9(9) COMP GLOBAL VALUE EXTERNAL TRM$M_TM_NOECHO.
01 TRM$M_TM_TRMNOECHO PIC 9(9) COMP GLOBAL VALUE EXTERNAL TRM$M_TM_TRMNOECHO.
01 TRM$M_TM_ESCAPE PIC 9(9) COMP GLOBAL VALUE EXTERNAL TRM$M_TM_ESCAPE.
01 TRM$M_TM_NOFILTR PIC 9(9) COMP GLOBAL VALUE EXTERNAL TRM$M_TM_NOFILTR.

ADD TRM$M_TM_NORECALL,
TRM$M_TM_TRMNOECHO,
TRM$M_TM_ESCAPE,
TRM$M_TM_NOFILTR,
TRM$M_TM_NOECHO GIVING RV-MODS.

ADD IO$_READVBLK,
IO$M_EXTEND GIVING IO-READ.
PERFORM WITH TEST AFTER UNTIL RETURN-STATUS NOT = SS$_OPINCOMPL AND SS$_DATAOVERUN

CALL "SYS$QIOW" USING BY VALUE 0, CTX-TERM-CHAN, IO-READ
BY REFERENCE IOSB
BY VALUE 0,0
BY REFERENCE IN-STRING
BY VALUE 5, 0, 0
BY REFERENCE READ-VERIFY-ITEM-LIST
BY VALUE ITEMLIST-LEN
GIVING RETURN-STATUS
IF RETURN-STATUS = SS$_NORMAL MOVE IOSB-STATUS TO RETURN-STATUS END-IF

John T. Farmer
Regular Advisor

Re: HP COBOL ACCEPT with a masking character

I started a callable COBOL routine a while back for this. Think I'll dust it off and see if I can get a simple solution working. We use SMG ReadString throughout our system for character data, but not sure I want to dig any deeper than it already goes.

Thanks for the direction...

John