Menu

Passing variables to Word Functions

Help
Mauried
2010-11-02
2013-05-30
  • Mauried

    Mauried - 2010-11-02

    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

     
  • Hugh Considine

    Hugh Considine - 2010-11-02

    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.

     
  • Nobody/Anonymous

    Thanks Hugh.
    That worked fine.
    Should have tried more variations,but its sometimes hard to guess them all.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.