Posted: 13th Feb 2003 21:23
I did this example of the type command to illustrate its use. It is the best way to programming and it means that you can assign many types of vars to one part of an array, a feature that did no feature in DB one.


Rem Project: temp
Rem Created: 10/02/2003 19:09:29

Rem ***** Main Source File *****
sync on
sync rate 35

chars = 100

x= 0
cls
type stuff
name as string
x as integer
y as integer
inposx as integer
inposy as integer
colr as integer
colg as integer
colb as integer
endtype
dim bugs(chars) as stuff

for x = 1 to chars
rc = int(rnd(50)+60)
bugs(x).name = chr$(rc)
bugs(x).x = Int(rnd(600))
bugs(x).y = int(rnd(400))
bugs(x).colr = int(rnd(255))
bugs(x).colg = int(rnd(255))
bugs(x).colb = int(rnd(255))
bugs(x).inposx = 0
bugs(x).inposy = 0
next x
x= 0

print "Ready Press a Start"
wait key
wait 200

Do
x = x + 1
if x = chars then exit

set cursor bugs(x).x, bugs(x).y
ink rgb(bugs(x).colr,bugs(x).colg,bugs(x).colb),0
print bugs(x).name
sync
Loop

fpx = 600 / 2
fpy = 400 / 2
cent = chars
x = 0
Do
x = x + 1
set cursor bugs(x).x, bugs(x).y
ink 0,0
print bugs(x).name
if bugs(x).x > fpx then bugs(x).x = bugs(x).x - 8
if bugs(x).x fpy then bugs(x).y = bugs(x).y - 8
if bugs(x).y
Posted: 13th Feb 2003 21:24
Sorry
+ Code Snippet
Rem Project: temp
Rem Created: 10/02/2003 19:09:29

Rem ***** Main Source File *****
sync on
sync rate 35

chars = 100

x= 0
cls
type stuff
   name as string
   x as integer
   y as integer
   inposx as integer
   inposy as integer
   colr as integer
   colg as integer
   colb as integer
endtype
dim bugs(chars) as stuff

for x = 1 to chars
   rc = int(rnd(50)+60)
   bugs(x).name = chr$(rc)
   bugs(x).x = Int(rnd(600))
   bugs(x).y = int(rnd(400))
   bugs(x).colr = int(rnd(255))
   bugs(x).colg = int(rnd(255))
   bugs(x).colb = int(rnd(255))
   bugs(x).inposx = 0
   bugs(x).inposy = 0
next x
x= 0

print "Ready Press a Start"
wait key
wait 200

Do
   x = x + 1
   if x = chars then exit

   set cursor bugs(x).x, bugs(x).y
   ink rgb(bugs(x).colr,bugs(x).colg,bugs(x).colb),0
   print bugs(x).name
sync
Loop

fpx = 600 / 2
fpy = 400 / 2
cent = chars
x = 0
Do
   x = x + 1
   set cursor bugs(x).x, bugs(x).y
   ink 0,0
   print bugs(x).name
   if bugs(x).x > fpx then bugs(x).x = bugs(x).x - 8
   if bugs(x).x < fpx then bugs(x).x = bugs(x).x + 8
   if bugs(x).x = fpx then bugs(x).inposx = 1

   if bugs(x).y > fpy then bugs(x).y = bugs(x).y - 8
   if bugs(x).y < fpy then bugs(x).y = bugs(x).y + 8
   if bugs(x).y = fpy then bugs(x).inposy = 1

   if bugs(x).y = fpy and bugs(x).x = fpx then cent = cent - 1

   set cursor bugs(x).x, bugs(x).y
   ink rgb(bugs(x).colr,bugs(x).colg,bugs(x).colb),0
   print bugs(x).name
   if x = chars
      if cent = 0
         exit
      else
         x = 0
      endif
   endif
sync
Loop