Ok, what you have to do is put the function out side of your main loop. Also, the way you have the function set up, it is wrong.
The example you gave above:
function print a
a$ = "hello world"
print a$
endfunction
In that, you cannot use
print a as teh function name, because, 1, it has a space, which is illegal, and 2, it doesn't have the "brackets" at the end which define it as a function.
Try changing it to this:
function print_a()
a$ = "hello world"
print a$
endfunction
Then stick that function out side of your main loop. If the command
Function gets read fromwithin your main code, it will produce the error you described.
Here is how you do it:
Do
print_a()
Loop
function print_a()
a$ = "hello world"
print a$
endfunction
If you made it:
Do
function print_a()
a$ = "hello world"
print a$
endfunction
Loop
It would produce that error, because you are tryign to declare the function on the loop, whcih you are not allowed to do.
You must always declare the function away from any other code that is to be executed, then
call the function from within the loop.
In this case, the function was declared after the loop withthe Function and EndFunction commands, and was called during the loop by simply putting in the function name
print_a()
The "brackets" at the end allow you to pass the functions values, ie:
Do
print_a("Hello World")
Loop
function print_a(a$)
print a$
endfunction
In that above example, the string "Hello World" would be passed to the function, and the function would store it in the variable a$ ( since that is the corresponding variable in the "brackets" )
Here is what the DBPro help files have to say about functions:
USER DEFINED FUNCTIONS
There will come a time when the ability to create your own functions will be priceless. Experienced programmers would not be able to write
effective code without them. Although GOSUB commands and subroutines have been provided for compatibility and learning, it is expected that
you will progress to use functions as soon as possible.
Functions are blocks of commands that usually perform a recursive or isolated task that is frequently used by your program. Variables and arrays
used within the function are isolated from the rest of the program. If you use a variable name of FRED in your function, it will not affect another
variable called FRED in your main program, nor any other function that happens to use a similar variable name. This may seem to be a restriction,
but forces you to think about cutting up your program into exclusive tasks which is a very important lesson.
You can pass up to 255 parameters into your function, and have the option of returning a value when the function returns. Functions that do not
return a value can also be used as normal commands in your main program.
Declaring a function couldn't be simpler. To use the FUNCTION command, simply provide it with a name and a list of parameters in brackets and
your declaration is half-complete. Enter the commands you want on the following lines and then end the function declaration with the command
ENDFUNCTION. The following example declares a function that returns half of a value passed in:
FUNCTION halfvalue(value)
value=value/2
ENDFUNCTION value
This declaration creates a function that can be used as a better print command:
REM Start of program
BetterPrint(10, 10, "Hello world")
END
FUNCTION BetterPrint(x, y, t$)
SET CURSOR x,y
PRINT t$
ENDFUNCTION
Hope I Helped...
PS I'm not too sure if i should have posted that help file, because it is from the DBPro help files, but i figured since it's from the trial version, hence, the free version, then it was ok.

Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy