home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / busi / arrays2.zip / ARRAYS.PF3
Text File  |  1990-02-08  |  3KB  |  117 lines

  1. 'ARRAYS.PF3 Copyright (c) 1990 by Mark Stingley (02/08/90)
  2. '                                 Applied Resource Technologies, Inc.
  3. '                                 ARTIST BBS (214) 855-1347
  4. '                                 P.O. Box 64381, Dallas, TX 75206
  5.  
  6. 'This project provides a useful, visual representation of the use and
  7. 'coding of a multidimensional array in SmartWare II.  It can be compiled
  8. 'in any module.
  9.  
  10. 'Permission is granted to distribute this code for educational purposes
  11. 'only PROVIDED that full credit is given the author and owner, AND
  12. 'no charge is made for distributing other than nominal copying fees.
  13. 'In addition, the code must be distributed in its entirety, unchanged.
  14. 'This code may be posted electronically.
  15.  
  16. '**********************************************************************
  17.  
  18. GLOBAL init() show() move() enter() menu() array[4,5]
  19. GLOBAL $c $r $fgp $bgp $k $string $oldc $oldr
  20.  
  21. $fgp = fgpleasing
  22. $bgp = bgpleasing
  23. screen print 4 20 $fgp $bgp "Array:  array[4,5]"
  24. screen print 25 1 $fgp $bgp "Array demo by Mark Stingley" \
  25.                             |". ART Inc. (c)1990"
  26. init()
  27. show()
  28. menu()
  29. move()
  30.  
  31. FUNCTION show()
  32. screen print 8 20 $fgp $bgp "Row1  Row2  Row3  Row4  Row5"
  33. FOR $c = 1 to 4 step 1
  34.      screen print 10+$c 5 $fgp $bgp "Column "|str($c)
  35.      FOR $r = 1 to 5 step 1
  36.      screen print 10+$c 13+($r*6) $fgp $bgp \
  37.                   str(format(array[$c,$r],"R5"))
  38.      END FOR
  39. END FOR
  40. END FUNCTION
  41.  
  42. FUNCTION move()
  43. $k = 0
  44. $c = 1
  45. $r = 1
  46. WHILE $k <> {Esc}
  47.      screen print 5 20 $fgp $bgp "(now at index["|str($c)|","| \
  48.                                  str($r)|"])"
  49.      screen print 10+$c 13+($r*6) $bgp $fgp \
  50.                   str(format(array[$c,$r],"R5"))
  51.      $k = inchar
  52.      $oldc = $c
  53.      $oldr = $r
  54.      if $k = {Enter}
  55.           enter()
  56.      elseif $k = {Down}
  57.           if $c = 4
  58.              $c = 1
  59.           else
  60.              $c = $c+1
  61.           end if
  62.      elseif $k = {Up}
  63.           if $c = 1
  64.              $c = 4
  65.           else
  66.              $c = $c-1
  67.           end if
  68.      elseif $k = {Right}
  69.           if $r = 5
  70.              $r = 1
  71.           else
  72.              $r = $r+1
  73.           end if
  74.      elseif $k = {Left}
  75.           if $r = 1
  76.              $r = 5
  77.           else
  78.              $r = $r-1
  79.           end if
  80.      elseif $k = {Esc}
  81.           return
  82.      end if
  83.      screen print 10+$oldc 13+($oldr*6) $fgp $bgp \
  84.                   str(format(array[$oldc,$oldr],"R5"))
  85. END WHILE
  86. END FUNCTION
  87.  
  88. FUNCTION enter()
  89. local #scn
  90. screen save 16 1 16 80 #scn
  91. screen print 16 5 $fgp $bgp "Enter a new string for "| \
  92.                               "array["|str($c)|","|str($r)|"]:"
  93. screen input 16 40 $fgp $bgp 5 $string
  94. array[$c,$r] = $string
  95. screen shortrestore #scn
  96. END FUNCTION
  97.  
  98. FUNCTION init()
  99. FOR $c = 1 to 4 step 1
  100.      FOR $r = 1 to 5 step 1
  101.           array[$c,$r] = "xxxxx"
  102.      END FOR
  103. END FOR
  104. END FUNCTION
  105.  
  106. FUNCTION menu()
  107. screen clear box 4 52 14 76 $fgp $bgp
  108. screen draw box 5 53 7 75 $fgp $bgp
  109. screen print 6 54 $fgp $bgp str(format("Menu","M21"))
  110. screen print 8 54 $fgp $bgp str(format("Movement:","M22"))
  111. screen print 9 54 $fgp $bgp "Up, Down, Left, Right"
  112. screen print 11 54 $fgp $bgp str(format("Press Enter to Edit","M22"))
  113. screen print 12 54 $fgp $bgp str(format("Press Esc to Exit","M22"))
  114. END FUNCTION
  115.  
  116. '**********************************************************************
  117.