well a function like that doesn't add anything usefull. you just change the name. if you want to change the name you can use #constant
well you could use functions to read the values out of a file or some data section or calculate with the values:
function drawBoxesFromFile(fileName$,freeFileNr)
open to read fileName$,freeFileNr
while file end(freeFileNr)=0
read string freeFileNr,s$
x1=val(s$)
read string freeFileNr,s$
y1=val(s$)
read string freeFileNr,s$
x2=val(s$)
read string freeFileNr,s$
y2=val(s$)
endwhile
endfunction
function drawBoxFromData()
restore _box_data
read v
count=v
for i=0 to count-1 step 4
read v
x1=v
read v
y1=v
read v
x2=v
read v
y2=v
next i
endfunction
if you want your boxes to use some kind of offset, you could do:
function boxWithOffset(x1,y1,x2,y2,color1,color2,color3,color4)
xoff=100
yoff=100
box x1+xoff,y1+yoff,x2+xoff,y2+yoff,color1,color2,color3,color4
endfunction
you could also make xoff and yoff a global and change them somewhere else. i use something similar to simulate a window inside of my app, and use the x and y values of that window as an offset for all the window elements.
you could use a function to change the behaviour of a function to match your taste:
function drawBox(x,y,width,height,color)
box x,y,x+width,y+height,color,color,color,color
endfunction
maybe you want to make a function to draw a checkerboard pattern:
x=20
y=20
width=8
height=8
sizeOfOneElement=20
drawBoard(x,y,width,height,sizeOfOneElement)
wait key
end
function drawBoard(x,y,width,height,sizeOfOneElement)
box x,y,x+width*sizeOfOneElement+2,y+height*sizeOfOneElement+2
for fy=0 to height-1
for fx=0 to width-1
drawChecker(x+1,y+1,fx,fy,sizeOfOneElement)
next fx
NEXT fy
ENDFUNCTION
function drawChecker(xoff,yoff,x,y,size)
x1=xoff+x*size
y1=yoff+y*size
x2=x1+size
y2=y1+size
color=0xffffffff
if y%%2=1
if x%%2=0
color=0xff000000
endif
else
if x%%2=1
color=0xff000000
endif
ENDIF
box x1,y1,x2,y2,color
endfunction
if your function does not do anything than pass the same values to another dbpro function then a function is not what you want.
an exception to that "rule" could be dll calls.
"It is only slightly easier than changing all sugar in a cake into stevia after it has already been baked" -Bisqwit