Settings

The page will reload to apply your changes.
Theme

ASCII Art Font

ASCII Art Menu

Original Usenet message from alt.ascii-art, 11 Oct 1999.
Re: DRAW square box

Re: DRAW square box

Pete <hdp...@sympatico.ca> writes:

> an anyone please! tell me how to draw a square box with ascii charaters
> using while loops   , echoing ascii characters from octal values....In
> unix bash shell

Cool idea!

first parameter is width (default 5), second is length (default width)


===========8<===================================
#!/bin/bash

WIDTH=$1
WIDTH=${WIDTH:-5}

LENGTH=$2
LENGTH=${LENGTH:-${WIDTH}}

i=0

echo -n ' '
while [ $i -lt `expr ${WIDTH} - 2` ]; do
    i=`expr $i + 1`
    echo -n "_"
done
echo

i=0

while [ $i -lt `expr ${LENGTH} - 1` ]; do
    i=`expr $i + 1`
    echo -n "|"
    j=0
    while [ $j -lt `expr ${WIDTH} - 2` ]; do
	j=`expr $j + 1`
	echo -n ' '
    done
    echo "|"
done

i=0

echo -n "|"
j=0
while [ $j -lt `expr ${WIDTH} - 2` ]; do
    j=`expr $j + 1`
    echo -n "_"
done
echo "|"

echo
=============8<===============================

HTH :-)

-- 
David Riley 		dav...@dmriley.demon.co.uk
ObAscii: No such file or directory
core dumped

Original message headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f996b,a43fec20b2a6bebb
X-Google-Attributes: gidf996b,public
From: David Riley <dav...@dmriley.demon.co.uk>
Subject: Re: DRAW square box
Date: 1999/10/11
Message-ID: <m39...@dmriley.demon.co.uk>#1/1
X-Deja-AN: 535182503
X-NNTP-Posting-Host: dmriley.demon.co.uk:194.222.183.234
References: <380...@sympatico.ca>
X-Trace: news.demon.co.uk 939600173 nnrp-02:25708 NO-IDENT dmriley.demon.co.uk:194.222.183.234
Organization: none
Newsgroups: alt.ascii-art
X-Complaints-To: abu...@demon.net
About this message. This message was posted publicly to the newsgroup alt.ascii-art in 1999 and is mirrored here unchanged as part of the Historic Archives – only email addresses are masked. The artwork and text belong to their original authors: if you copy a piece, keep the artist's initials or signature intact and credit them where you can. Are you the author? Contact us to get your posts attributed, connected to your artist profile, or removed.

Report this message

Help us keep the archive clean and accurate. Reports are reviewed by a person – nothing is changed automatically.

Help classify this post