SPONSORS:






User Tag List

Page 1 of 2 12 LastLast
Results 1 to 10 of 17
  1. #1
    Senior Member
    Join Date
    Jan 2001
    Posts
    750
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    keyword \'optional\' is buggus

    myFunc(string s optional, int a)
    myFunc(int a, string s optional)

    calls:
    myFunc(1)

    Guess which version will rull correctly???

    Well the second one is the correct answer.
    For the first function to work you have to pass 'null' for argument #1 or set your variable to null, before hand(which is D#$B)



    ------------------

  2. #2
    Member
    Join Date
    Jan 2001
    Location
    Westborough, mA, USa
    Posts
    91
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: keyword \'optional\' is buggus

    FYI:It is documented that when declaring an optional variable, the variables following that may be omitted. So it doesnt make sense to declare the first variable as an optional one.

    From Segue online help:

    optional Optional. Indicates that the argument is optional. If an optional argument has not been passed in, its value will be null on entry to the function. If you omit an optional argument, you may also omit any arguments that follow the optional argument.


    Hope this helps

    ------------------

  3. #3
    Senior Member
    Join Date
    Oct 1999
    Location
    Tyngsborough, MA
    Posts
    211
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: keyword \'optional\' is buggus

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by GodKnows:
    (which is D#$B)
    <HR></BLOCKQUOTE>

    What's D#$B is declaring an optional parameter at the beginning of your parameter list. What is the point of this thread anyway?


    ------------------

  4. #4
    Senior Member
    Join Date
    Jan 2001
    Posts
    750
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: keyword \'optional\' is buggus

    In 4test, some functions have all parameters as optional(Click()). I want to take advantage of that but it seems that it is not possible.

    If I have to put the value null in the parameter to indicate that this parameter is not used then it is the same as not put the parameter as optional.



    ------------------

  5. #5
    Member
    Join Date
    Nov 2000
    Location
    Tampa, FL USA
    Posts
    90
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: keyword \'optional\' is buggus

    Sandeep is right :
    All parameters that follow an optional parameter MUST also be optional

    ------------------

  6. #6
    Senior Member
    Join Date
    Oct 1999
    Location
    Tyngsborough, MA
    Posts
    211
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: keyword \'optional\' is buggus

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by GodKnows:
    In 4test, some functions have all parameters as optional(Click()). I want to take advantage of that but it seems that it is not possible.<HR></BLOCKQUOTE>

    You can. Try it.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by GodKnows:
    If I have to put the value null in the parameter to indicate that this parameter is not used then it is the same as not put the parameter as optional.
    <HR></BLOCKQUOTE>

    The same rules apply to Silk provided functions. If you want to specify the fourth optional parameter to Click(), you NEED to specify the first three, NULL or otherwise.

    You should play around with this a bit more.



    ------------------

  7. #7
    Senior Member
    Join Date
    Sep 2000
    Location
    Twin Cities, MN, USA
    Posts
    653
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: keyword \'optional\' is buggus

    This makes sense, too. If you have (function(opt, opt, opt, opt)) and want to call (function(1)) with the 1 going to the 3rd opt, how is SilkTest supposed to know where you want it without using (function(null, null, 1))?

    ------------------

  8. #8
    Senior Member
    Join Date
    Jul 1999
    Location
    Burlingame CA 94010
    Posts
    502
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: keyword \'optional\' is buggus

    Maybe I can clarify a little bit

    If you have an optional parameter, followed by a non-optional parameter, you must pass both parameters, or none. The Click method works that way for two of its parameters.

    Click (INTEGER iButton optional, INTEGER x optional, INTEGER y, BOOLEAN bRawEvent optional)

    The following are valid uses:

    Click ()
    Click (1)
    Click (1, 5, 5)
    Click (1, 5, 5, TRUE)

    The following are invalid:

    Click (1, 5)

    Because the optional x parameter was followed by the non-optional y parameter, these parameters become a pair, which must both be passed if one is passed.

    Hope this helps



    ------------------
    John W Green
    jwgreen@automationexpertise.com
    http://www.automationexpertise.com

  9. #9
    Senior Member
    Join Date
    Oct 1999
    Location
    Tyngsborough, MA
    Posts
    211
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: keyword \'optional\' is buggus

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by John Green:
    Maybe I can clarify a little bit

    If you have an optional parameter, followed by a non-optional parameter, you must pass both parameters, or none. The Click method works that way for two of its parameters.

    Click (INTEGER iButton optional, INTEGER x optional, INTEGER y, BOOLEAN bRawEvent optional)

    The following are valid uses:

    Click ()
    Click (1)
    Click (1, 5, 5)
    Click (1, 5, 5, TRUE)

    The following are invalid:

    Click (1, 5)

    Because the optional x parameter was followed by the non-optional y parameter, these parameters become a pair, which must both be passed if one is passed.

    Hope this helps

    <HR></BLOCKQUOTE>


    John,

    You missed an important point. You cannot pass argument 2 if you haven't passed argument 1. This logic follows for all parameters in the list, optional or not. Your valid examples all reflect this. An invalid example that reflects my point is Click(TRUE). even though there is only 1 boolean, this is still not allowed.


    ------------------

  10. #10
    Senior Member
    Join Date
    Jan 2001
    Posts
    750
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: keyword \'optional\' is buggus

    This is a rant!

    Anyhow with only 2 arguments, I don't see why
    silk can't tell which one is optional or not independent how the arguments are ordered.
    That's refering to my initial message.

    Optional argument become relatively useless when you start to put values for them to implicitly tell that it is not used.



    ------------------

 

 
Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 09:03 PM.

Copyright BetaSoft Inc.