home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
busi
/
arrays2.zip
/
ARRAYS.PF3
Wrap
Text File
|
1990-02-08
|
3KB
|
117 lines
'ARRAYS.PF3 Copyright (c) 1990 by Mark Stingley (02/08/90)
' Applied Resource Technologies, Inc.
' ARTIST BBS (214) 855-1347
' P.O. Box 64381, Dallas, TX 75206
'This project provides a useful, visual representation of the use and
'coding of a multidimensional array in SmartWare II. It can be compiled
'in any module.
'Permission is granted to distribute this code for educational purposes
'only PROVIDED that full credit is given the author and owner, AND
'no charge is made for distributing other than nominal copying fees.
'In addition, the code must be distributed in its entirety, unchanged.
'This code may be posted electronically.
'**********************************************************************
GLOBAL init() show() move() enter() menu() array[4,5]
GLOBAL $c $r $fgp $bgp $k $string $oldc $oldr
$fgp = fgpleasing
$bgp = bgpleasing
screen print 4 20 $fgp $bgp "Array: array[4,5]"
screen print 25 1 $fgp $bgp "Array demo by Mark Stingley" \
|". ART Inc. (c)1990"
init()
show()
menu()
move()
FUNCTION show()
screen print 8 20 $fgp $bgp "Row1 Row2 Row3 Row4 Row5"
FOR $c = 1 to 4 step 1
screen print 10+$c 5 $fgp $bgp "Column "|str($c)
FOR $r = 1 to 5 step 1
screen print 10+$c 13+($r*6) $fgp $bgp \
str(format(array[$c,$r],"R5"))
END FOR
END FOR
END FUNCTION
FUNCTION move()
$k = 0
$c = 1
$r = 1
WHILE $k <> {Esc}
screen print 5 20 $fgp $bgp "(now at index["|str($c)|","| \
str($r)|"])"
screen print 10+$c 13+($r*6) $bgp $fgp \
str(format(array[$c,$r],"R5"))
$k = inchar
$oldc = $c
$oldr = $r
if $k = {Enter}
enter()
elseif $k = {Down}
if $c = 4
$c = 1
else
$c = $c+1
end if
elseif $k = {Up}
if $c = 1
$c = 4
else
$c = $c-1
end if
elseif $k = {Right}
if $r = 5
$r = 1
else
$r = $r+1
end if
elseif $k = {Left}
if $r = 1
$r = 5
else
$r = $r-1
end if
elseif $k = {Esc}
return
end if
screen print 10+$oldc 13+($oldr*6) $fgp $bgp \
str(format(array[$oldc,$oldr],"R5"))
END WHILE
END FUNCTION
FUNCTION enter()
local #scn
screen save 16 1 16 80 #scn
screen print 16 5 $fgp $bgp "Enter a new string for "| \
"array["|str($c)|","|str($r)|"]:"
screen input 16 40 $fgp $bgp 5 $string
array[$c,$r] = $string
screen shortrestore #scn
END FUNCTION
FUNCTION init()
FOR $c = 1 to 4 step 1
FOR $r = 1 to 5 step 1
array[$c,$r] = "xxxxx"
END FOR
END FOR
END FUNCTION
FUNCTION menu()
screen clear box 4 52 14 76 $fgp $bgp
screen draw box 5 53 7 75 $fgp $bgp
screen print 6 54 $fgp $bgp str(format("Menu","M21"))
screen print 8 54 $fgp $bgp str(format("Movement:","M22"))
screen print 9 54 $fgp $bgp "Up, Down, Left, Right"
screen print 11 54 $fgp $bgp str(format("Press Enter to Edit","M22"))
screen print 12 54 $fgp $bgp str(format("Press Esc to Exit","M22"))
END FUNCTION
'**********************************************************************