Default params in procedure declarations

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by amberelectrics, Mar 30, 2008.

  1. amberelectrics

    amberelectrics

    Joined:
    Aug 29, 2007
    Messages:
    114
    Likes Received:
    0
    If I create a procedure or function, I can declare parameters to pass in. However, I dont seem to be able to give parameters a default setting.

    This would usually be used to negate the requirement of passing the variable.

    For example, I create a procedure to control a bathroom fan. The procedure will accept the following:

    Group integer - group for the fan to control
    func integer - Indicator if its an on(1) or off(0) control
    tdelay integer - delay to apply to control

    If I can apply a standard delay value, I wouldnt need to pass in the parameter. as follows:

    Full command:
    SetFan(1, 1, 2); {SetFan procedure call for groupid 1, function on, time 2 mins}

    Partial command:
    SetFan(1,1); {{SetFan procedure call for groupid 1, function on}

    In the partial, the default setting of 2 mins is used.

    In a language like Delphi, the declaration would be something along the lines of:

    procedure SetFan(gId, pFunc: integer; fDelay: integer = 2);

    Would have to seperate out the fDelay to apply a default from the other int declarations.

    Now I think this is a specific OOP structure so I am fairly certain a PAC wont handle it, just wondering if anyone else knows for sure?

    Im not even going to bother asking if we can have method overloading :p

    Cheers

    Simon
     
    amberelectrics, Mar 30, 2008
    #1
  2. amberelectrics

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,393
    Likes Received:
    25
    Location:
    Adelaide, South Australia
    The PAC and other devices support an enhanced version of standard Pascal.

    The language is not object oriented and does not support default parameters, nor does it support overloading.
     
    ashleigh, Mar 30, 2008
    #2
  3. amberelectrics

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    You definitely can't do it.

    Good ;)
     
    Darren, Mar 31, 2008
    #3
  4. amberelectrics

    amberelectrics

    Joined:
    Aug 29, 2007
    Messages:
    114
    Likes Received:
    0
    Hehehehe, fair enough, I thought that may be the answer.

    Cheers

    Simon
     
    amberelectrics, Mar 31, 2008
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.