From: Kenneth H. Fairfield [Kenneth.H.Fairfield@intel.com] Sent: Thursday, November 15, 2001 1:44 PM To: Info-VAX@Mvb.Saic.Com Subject: CJL's NOTLIB_PAGINATE.C (Was: Re: LIB$xxx) By request (well _one_ request :-) here's a copy of Carl Lydick's original comp.os.vms post showing how to make LIB$PUT_OUTPUT "page" its output. Enjoy! -Ken ----------------------------------------------------------------------- Someone recently complained about the fact that applications using LBR$OUTPUT_HELP to display help don't paginate the results. Well, I've written a small set of routines that allow one to do such pagination. They won't, of course, help at all with utilities already out there, but if you're planning to write an application that uses LBR$OUTPUT_HELP (or any other application that writes to SYS$OUTPUT and for which you'd like to have the results paginated, you might find them useful. NOTLIB_PAGINATE_OUTPUT has the same semantics as LIB$PUT_OUTPUT, but, if the output device is a terminal, paginates the output. NOTLIB_PAGINATE_INPUT has the same semantics as LIB$GET_INPUT, but resets the line counter used by NOTLIB_PAGINATE_OUTPUT. NOTLIB_PAGINATE_RESET resets the static variables used by NOTLIB_PAGINATE_OUTPUT to their initial state. #include dvidef #include descrip long stat; #define ckstat(x) if (((stat = x) & 7) != 1) return stat notlib_paginate_output(struct dsc$descriptor *string) { return notlib_paginate(0, string); } notlib_paginate_input(struct dsc$descriptor *result, struct dsc$descriptor *prompt, unsigned short *reslen) { notlib_paginate(1, 0); return LIB$GET_INPUT(result, prompt, reslen); } notlib_paginate_reset() { return notlib_paginate(2, 0); } notlib_paginate(int action, struct dsc$descriptor *string) { static int paglen = 0, initialized = 0, curline = 0, istty = 0; static $DESCRIPTOR(devnam, "SYS$OUTPUT"); static char buffer[80]; static $DESCRIPTOR(result, buffer); static $DESCRIPTOR(prompt, "Hit return to continue"); if(action == 2) { initialized = 0; return 1; } else if (action == 1) curline = 0; else if (action == 0) { if (initialized == 0) { initialized = 1; ckstat(LIB$GETDVI(&DVI$_TRM, 0, &devnam, &istty)); ckstat(LIB$GETDVI(&DVI$_TT_PAGE, 0, &devnam, &paglen)); curline = 0; } if (istty && (curline >= paglen - 1)) { ckstat(LIB$GET_INPUT(&result, &prompt)); curline = 0; } curline++; return LIB$PUT_OUTPUT(string); } } -------------------------------------------------------------------------------- Carl J Lydick | INTERnet: CARL@SOL1.GPS.CALTECH.EDU | NSI/HEPnet: SOL1::CARL Disclaimer: Hey, I understand VAXen and VMS. That's what I get paid for. My understanding of astronomy is purely at the amateur level (or below). So unless what I'm saying is directly related to VAX/VMS, don't hold me or my organization responsible for it. If it IS related to VAX/VMS, you can try to hold me responsible for it, but my organization had nothing to do with it.