i am rather new to dark basic and i am trying to create a 3d version of pacman so far without success. at the moment i am having a lot of trouble with a function i have in there. error message ' program ran into a function declaration '. i am unsure how to fix it. my code is bellow if any one has any suggestions then please post.
`**************************
`* Pacman 3D *
`* Adam Lockwood *
`**************************
Dim Mz(30, 30)
Dim VertsX(30, 30)
Dim VertsY(30, 30)
Dim Bump(30,30,1)
Sync On
Hide Mouse
Randomize Timer()
`Clear everything previously
For a = 1 To 29
For b = 1 To 29
mz(a, b) = 0
Next b
Next a
`Make the borders
For a = 0 To 30
Mz(a, 0) = 1
Mz(a, 30) = 1
Mz(0, a) = 1
Mz(30, a) = 1
Next A
`Generate the vertices
For X = 2 To 28 Step 2
For Y = 2 To 28 Step 2
VertsX(X, Y) = X
VertsY(X, Y) = Y
Next Y
Next X
`Mix up the order to draw verticies
For X1 = 2 To 28 Step 2
For Y1 = 2 To 28 Step 2
X2 = (Int(Rnn() * 13) + 1) * 2
Y2 = (Int(Rnn() * 13) + 1) * 2
tmpX = VertsX(X1, Y1)
tmpY = VertsY(X1, Y1)
VertsX(X1, Y1) = VertsX(X2, Y2)
VertsY(X1, Y1) = VertsY(X2, Y2)
VertsX(X2, Y2) = tmpX
VertsY(X2, Y2) = tmpY
Next Y1
Next X1
`Now here is the confusing part. Using a method I found
`on the internet

We are simply going to draw
`a wall from each verticies in a random direction
`Until another wall is reached
For X = 2 To 28 Step 2
For Y = 2 To 28 Step 2
XX = VertsX(X, Y)
YY = VertsY(X, Y)
If Mz(XX, YY) = 0
Repeat
Cnt = 0
XX = VertsX(X, Y)
YY = VertsY(X, Y)
Dirn = Int(Rnd(3))
Repeat
Cnt = Cnt + 1
T=0
If Dirn=0 then XX = XX - 1 : T=1
If Dirn=1 then XX = XX + 1 : T=1
If Dirn=2 then YY = YY + 1 : T=1
If T=0 then YY = YY - 1
Until Mz(XX, YY) = 1
Until Cnt < 26
XX = VertsX(X, Y)
YY = VertsY(X, Y)
Repeat
Mz(XX, YY) = 1
T=0
If Dirn=0 then XX = XX - 1 : T=1
If Dirn=1 then XX = XX + 1 : T=1
If Dirn=2 then YY = YY + 1 : T=1
If T=0 then YY = YY - 1
Until Mz(XX, YY) = 1
EndIf
Next Y
Next X
Cls
`Now just display the maze on the screen
For X = 0 To 30
For Y = 0 To 30
If Mz(X, Y) = 1
Make Object Box X+1+Y*31,100,100,100
Position Object X+1+Y*31,X*100,50,Y*100
Endif
Next Y
Next X
Color Backdrop 0
Do
This is the part i am having trouble with 
Function Create_Chars(Tex)
`PacMan
rem make object sphere 8,30
load object "obj/pacman.x", 8
make object collision box 8, -14, -14, -14, 14, 14, 14, 1
fix object pivot 8
rem rotate object 8, 0, 180, 0
make object sphere 13,40
if Tex=0
color object 13,rgb(0,0,255)
else
texture object 13, 7
endif
position object 13,-50,-50,-50
ghost object on 13
make object collision box 13,-20, -20, -20, 20, 20, 20, 1
`Ghosts
For i = 9 To 12
rem make object sphere i,60
load object "obj/ghost.x", i
fix object pivot i
remstart
if Tex=0
color object i,rgb(200,200,200)
else
color object i,rgb(200,200,200)
endif
remend
ghost object on i
make object collision box i,-25, -25, -25, 25, 25, 25, 1
Next i
endfunction
to this part here
x#=250
z#=380
a#=0
color backdrop 0
if upkey()=1 then x#=newxvalue(x#,angle#,-2.0) : z#=newzvalue(z#,angle#,-2.0)
if downkey()=1 then x#=newxvalue(x#,angle#,0.3) : z#=newzvalue(z#,angle#,0.3)
if leftkey()=1 then angle#=wrapvalue(angle#-4.5)
if rightkey()=1 then angle#=wrapvalue(angle#+4.5)
position object 99,x#,y#,z#
cx#=newxvalue(x#,wrapvalue(angle#),12)
cz#=newzvalue(z#,wrapvalue(angle#),12)
position camera cx#,y#+10,cz#
point camera x#,y#+5,z#
yrotate object 99,angle#
sync
loop
Function Map()
Ink RGB(255,255,255),0
For X = 0 To 30
For Y = 0 To 30
If Mz(X, Y) = 1
For E=1 to 5
For E1=1 to 5
Dot (X*5)+E,(Y*5)+E1
Next E1
Next E
Endif
Next Y
Next X
Endfunction
Function Rnn()
I#=Rnd(10)/10.0
While I#=0 or I#=1
I#=Rnd(10)/10.0
Endwhile
Endfunction I#