i have a client who i'm trying to convince to use perl for general programming tasks inside their office. they are stranded in the world of MSDOS so i've had to be creative about making perl visually attractive. this code should work on any VT-100 or similar terminal for UNIX boxes, or with ANSI.SYS loaded on MSDOS. <-- snip snip ---- cur.pl ------------------------------------------------> # curses-style cusror control for ANSI screens # window-like primatives # april 1993, vic spicer (vspicer@ccu.umanitoba.ca) # clear screen sub CLS { print "\e[;H\e[2J"; } # inverse screen sub INVERSE { print "\e[7m"; } # normal screen sub NORMAL { print "\e[0m"; } # erase line sub EL { print "\e[K"; } # position cursor (y,x) sub CPOS { local($y,$x)=@_; print "\e[$y;$x"; print "H"; } # make box (upper left y, upper left x, lower right y, lower right x, # title) sub BOX { local($y1,$x1,$y2,$x2,$title)=@_; local($lines)=$x2-$x1; local($j); &CPOS($y1,$x1); &INVERSE; print "["; print "-" x ($lines-1); print "]"; for ($j=$y1+1;$j<$y2;$j++) { &CPOS($j,$x1); print "|"; &NORMAL; print " " x ($lines-1) ; &INVERSE; print "|"; } &CPOS($y2,$x1); print "["; print "-" x ($lines-1); print "]"; &NORMAL; &CPOS($y1,$x1+5); print $title; } # erase box (upper left y, upper left x, lower right y, lower right x) sub UNBOX { local($y1,$x1,$y2,$x2)=@_; local($j); for ($j=$y1;$j<=$y2;$j++) { &CPOS($j,$x1); print " " x ($x2-$x1); } } # put message (upper left y, upper left x, message); sub MSG { local($y1,$x1,$mess)=@_; &BOX($y1,$x1,$y1+2,$x1+length($mess)+1); &CPOS($y1+1,$x1+1); print $mess; } # put many lines to window (upper left y, upper left x, x-width, # array of lines) sub TEXT { local($y1,$x1,$wide,@mess)=@_; local($j); &BOX($y1,$x1,$y1+2+$#mess,$x1+$wide); for ($j=0;$j<=$#mess;$j++) { &CPOS($y1+1+$j,$x1+1); print $mess[$j]; } } # get many lines from window (upper left y, upper left x, x-width, lines) sub MLINES { local($y1,$x1,$wide,$lin,$title)=@_; local($j,@line); &BOX($y1,$x1,$y1+2+$lin,$x1+$wide,$title); for ($j=0;$j<=$lin;$j++) { &CPOS($j+$y1+1,$x1+1); print ">"; $moo=<>; chop($moo); $line[$j]=$moo; } return @line; } # get input in window (upper left y, upper left x, prompt, length of input, # default input) sub INPUT { local($y1,$x1,$mess,$length,$default)=@_; local($mess2)=$mess . $default . (" " x ($length-length($default))); &MSG($y1,$x1,$mess2); &CPOS($y1+1,$x1+length($mess)+1); local($d); $d=<>; chop($d); if ($d eq "") { $d=$default; } return $d; } # select from options in window (upper left y, upper left x, width-x, title, # array of options) # returns number for selected option, -1 for abort sub SELECT { local($y1,$x1,$wide,$title,@prompts)=@_; local($lls)=$#prompts; &BOX($y1,$x1,$y1+$lls+3,$x1+$wide,$title); local($j,$letter); $letter="1"; local($option); for ($j=0;$j<=$lls;$j++) { &CPOS($y1+$j+1,$x1+1); print "$letter: $prompts[$j]"; $letter++; } $option=0; while (($option<1 | $option>$lls+1) & $option ne "q") { &CPOS($y1+$lls+2,$x1+1); print "SELECT: "; &CPOS($y1+$lls+2,$x1+8); $option=<>; chop($option); } if ($option eq "q") { $option=-1; } return $option; } 1; <---- snip snip... demo.pl -----------------------------------------------> require "cur.pl"; &CLS; &MSG(1,1,"hello world"); &INPUT(5,1,"Enter File: ",25,""); $what=&SELECT(10,12,20,"select animal","cat","dogs","iguanna"); if ($what==1) { $msg="you picked a cat"; } elsif ($what==2) { $msg="you picked a dog"; } elsif ($what==3) { $msg="you picked an igunna"; } elsif ($what==-1) { $msg="entry aborted"; } &MSG(20,30,$msg); &TEXT(6,45,30,"this is a demo","of multiple line","text output"); &UNBOX(1,1,3,20); @text=&MLINES(1,1,30,5,"enter captain's log"); &MSG(20,1,"end of demo"); &CPOS(23,1); ------ vic spicer, recent PERL convert/ data systems,instrument electronics and software person with the Time of Flight Mass Spec. Lab at the University of Manitoba Dept. of Physics