Function ReadSolar as word (optional smoothing as byte=10)
var0=0
For x1=1 to smoothing
var0=var0+ Readad10(an0)
wait 10 ms
next x1
Readsolar=var0/smoothing
end function
The idea is to be able to take a number of readings from the AD converter
and average them a number of times, with 10 being the default.
The Compiler complains about the line with the function declaration in it.
If I leave out the as word define , it then compiles ok, but I then cant use the AD in 10 bit mode.
If I leave out the (optional smoothing as byte=10) and include the as word define it compiles OK also.
Anyone see what Im doing wrong.
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Im trying to do something like this.
Function ReadSolar as word (optional smoothing as byte=10)
var0=0
For x1=1 to smoothing
var0=var0+ Readad10(an0)
wait 10 ms
next x1
Readsolar=var0/smoothing
end function
The idea is to be able to take a number of readings from the AD converter
and average them a number of times, with 10 being the default.
The Compiler complains about the line with the function declaration in it.
If I leave out the as word define , it then compiles ok, but I then cant use the AD in 10 bit mode.
If I leave out the (optional smoothing as byte=10) and include the as word define it compiles OK also.
Anyone see what Im doing wrong.
Thanks
Try changing
Function ReadSolar as word (optional smoothing as byte=10)
to
Function ReadSolar (optional smoothing as byte=10) as word
From memory GCBASIC always requires the type to be after the parameters.
Thanks Hugh.
That worked fine.
Should have tried more variations,but its sometimes hard to guess them all.