Category : Miscellaneous Language Source Code
Archive   : QTAWKU42.ZIP
Filename : SCREEN.EXP

 
Output of file : SCREEN.EXP contained in archive : QTAWKU42.ZIP
# QTAwk functions to manipulate display and cursor
# adapted from Article in Computer Language, Vol. 7, No. 1, Jan. 1990
# "Awk of Ages, Best for Me" by MIchael J. Gilchrist
#
# ANSI.SYS device driver for display must be installed for PC/MS-DOS
#
# functions defined:
# cls() -- function to clear screen and home cursor
# cls_sv() -- function to clear screen and leave cursor in current position
# crsr_pos(row,col) -- function to move cursor to specified position
# crsr_up(n) -- function to move cursor up n row(s)
# will not go above top line
# crsr_dn(n) -- function to move cursor down n row(s)
# will not go below bottom line
# crsr_left(n) -- function to move cursor left n column(s)
# will not go beyond left edge
# crsr_right(n) -- function to move cursor right n column(s)
# will not go beyond right edge
# erase_end() -- function to erase to end of current line
# including cursor position
# set_color(attr,fore,back) -- function to set display colors
#
# define some command variables here
BEGIN {
# define standard error file == screen
stderr = "stderr";
stdin = "stdin";
stdout = "stdout";
srand();
fprintf(stderr,"\x01b[s");
fprintf(stderr,"\x01b[=7l");
for ( i = 1 ; i <= 100 ; i++ ) {
crsr_pos(randint(24),randint(79));
set_color(0,randint(7),randint(7));
fprintf(stderr,"\001");
}
fprintf(stderr,"\x01b[=7h");
fprintf(stderr,"\x01b[u");
fprintf(stderr,"<-------------- Exiting QTAwk ------------->");
crsr_pos(24,1);
set_color(1,1,4);
}

# function to clear screen and home cursor
function cls() {
# clear screen and home cursor string
local _cls_ = "\x01b[2J";

fprintf(stderr,_cls_);
}

# function to clear screen and leave cursor in current position
function cls_sv() {
# clear screen and home cursor string
local _cls_ = "\x01b[2J";
# save cursor position
local _crsr_sv_ = "\x01b[s";
# restore cursor position
local _crsr_rs_ = "\x01b[u";

fprintf(stderr,_crsr_sv_ ï _cls_ ï crsr_rs_);
}

# function to move cursor to specified position
function crsr_pos(row,col) {
# sets cursor position
local _crsr_pos_ = "\x01b[{irow};{icol}f";
local irow = int(row); # insure integer value
local icol = int(col); # insure integer value

fprintf(stderr,replace(_crsr_pos_));
}

# function to move cursor up n row(s) - will not go above top line
function crsr_up(n) {
# move cursor up one row
local _crsr_up_ = "\x01b[{nn}A";
local nn = int(n);

fprintf(stderr,replace(_crsr_up_));
}

# function to move cursor down n row(s) - will not go below bottom line
function crsr_dn(n) {
# move cursor down one row
local _crsr_dn_ = "\x01b[{nn}B";
local nn = int(n);

fprintf(stderr,replace(_crsr_dn_));
}

# function to move cursor left n column(s) - will not go beyond left edge
function crsr_left(n) {
# cursor left n column(s)
local _crsr_left_ = "\x01b[{nn}C";
local nn = int(n);

fprintf(stderr,replace(_crsr_left_));
}

# function to move cursor right n column(s) - will not go beyond right edge
function crsr_right(n) {
# cursor left n column(s)
local _crsr_right_ = "\x01b[{nn}D";
local nn = int(n);

fprintf(stderr,replace(_crsr_right_));
}

# function to erase to end of current line - including cursor position
function erase_end() {
# erase to end of line, including cursor position
local _erase_end_line_ = "\x01b[K";

fprintf(stderr,_erase_end_line_);
}

# function to set display colors
# attr --> sets display attribute
# 0 --> leave attribute as is
# 1 --> high intensity
# 5 --> blink
# fore --> sets foreground color
# back --> sets background color
# colors for both foreground and background are:
# 0 --> Black
# 1 --> Red
# 2 --> Green
# 3 --> Yellow
# 4 --> Blue
# 5 --> Magenta
# 6 --> Cyan
# 7 --> White
function set_color(attr,fore,back) {
local _attr = int(attr) % 10;
local _fore = int(fore) % 8 + 30;
local _back = int(back) % 8 + 40;
# set display color string
local _set_display_color_ = _attr ? "\x01b[{_attr};{_fore};{_back}m" : "\x01b[{_fore};{_back}m";

fprintf(stderr,replace(_set_display_color_));
}

function randint(n) {
return int(n * rand()) + 1;
}


  3 Responses to “Category : Miscellaneous Language Source Code
Archive   : QTAWKU42.ZIP
Filename : SCREEN.EXP

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/