SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 10 of 10
  1. #1
    Junior Member
    Join Date
    Jul 2003
    Location
    Scottsdale, AZ
    Posts
    12
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    What is the SilkTest equivalent of a C/C++ do... while loop??

    An extremely simplistic example/concept below;

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">integer i

    do
    i = RandomInt(1, 100)
    while i != 50</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">Since Silk Test doesn't have do... while, only, do... except what is the equivalent code?

    You CAN NOT use;
    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">

    i = 1
    while i != 50
    i = RandomInt(1, 100)</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">This is not what I want. It is not a do... while type loop. I do not want to set the variable "i" outside of the loop.

  2. #2
    Senior Member
    Join Date
    Dec 2000
    Location
    Phoenix, AZ
    Posts
    371
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: What is the SilkTest equivalent of a C/C++ do... while loop??

    Why would you not want to set an initial value for i?

  3. #3
    Junior Member
    Join Date
    Jul 2003
    Location
    Scottsdale, AZ
    Posts
    12
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: What is the SilkTest equivalent of a C/C++ do... while loop??

    ok I'll expand the Simple Example then;

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">
    integer i

    if IsSet(i)
    Do Something...
    else
    do
    i = RandomInt(1, 100)
    // while messing with i do other stuff here..
    // blah blah blah
    // blah blah blah
    while i != 50</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">Now I need to enter that loop, and the only way to enter the loop is if i is not set.

  4. #4
    Member
    Join Date
    Feb 2002
    Location
    Overland Park, KS
    Posts
    39
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: What is the SilkTest equivalent of a C/C++ do... while loop??

    My thought is you're going to have to work around it a little, and in working around it you may end up with a more elegant solution. As a not-so-elegant workaround to the above...

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">integer i
    if IsSet(i)
    Do Something...
    else
    i = -999
    while i != 50
    i = RandomInt(1, 100)
    // while messing with i do other stuff here..
    // blah blah blah
    // blah blah blah</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">This allows you to run through your while loop at least once (which to me is the main difference between a do-while and just a while loop).

    Does this help? Maybe taking a look at the problem from a different point of view will help.

    Rob

  5. #5
    Super Member
    Join Date
    Jul 2001
    Location
    Earth
    Posts
    1,882
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: What is the SilkTest equivalent of a C/C++ do... while loop??

    "4Test does not have a do while loop."-SilkTest Help file

    Need to get by with a while loop.

  6. #6
    Junior Member
    Join Date
    Jul 2003
    Location
    Scottsdale, AZ
    Posts
    12
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: What is the SilkTest equivalent of a C/C++ do... while loop??

    I had a feeling that was the case, oh well...

    Thanks.

  7. #7
    Member
    Join Date
    Apr 2004
    Location
    India
    Posts
    97
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: What is the SilkTest equivalent of a C/C++ do... while loop??

    I think for this you can do with some Workaround by using for loop

    Like

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">for(i=RandomInt(1, 100),i=Function(i);i!=50

    int Function(int i)
    //do your operations here
    return i</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">In the above code the exection stats from Left to Right.

    First it will execute
    i=RandomInt(1, 100)
    Than it will execute the statement in the function
    After that execution will go to verify condition.

    So this will work as do...while in C.
    But only thing is you have to use Function()

    Thanks,
    Sreekanth Varma

  8. #8
    Member
    Join Date
    Apr 2004
    Location
    India
    Posts
    97
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: What is the SilkTest equivalent of a C/C++ do... while loop??

    You can also try GOTO statement

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> [ ] integer i
    [ ] DOLoop : //Loop Starts Here
    [ ] i = RandomInt(1, 100)
    [ ] //blah blah blah
    [ ] //blah blah blah
    [-] if(i!=50) //Verify Condition to continue
    [ ] goto DOLoop
    [ ]
    [ ] //Statements outside Loop</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">This will work like do....While Statement in C/C++.
    But conform with your coding Standards before using GOTO statement.

    Thanks,
    Sreekanth Varma

  9. #9
    Senior Member
    Join Date
    Dec 2000
    Location
    Phoenix, AZ
    Posts
    371
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: What is the SilkTest equivalent of a C/C++ do... while loop??

    Couldn't you just do this?
    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">
    integer i = NULL
    if i == NULL
    Do Something...
    else
    do
    i = RandomInt(1, 100)
    // while messing with i do other stuff here..
    // blah blah blah
    // blah blah blah
    while i != 50</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">

    [ 08-25-2004, 01:03 PM: Message edited by: kkoski ]

  10. #10
    Senior Member
    Join Date
    Feb 2004
    Location
    Canada
    Posts
    291
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: What is the SilkTest equivalent of a C/C++ do... while loop??

    How about this...

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> [ ] integer x = 1
    [ ]
    [-] while(1)
    [ ]
    [ ] print(&quot;at least it ran once&quot
    [ ]
    [-] if(x == 1)
    [ ] break
    [ ]
    [ ] </pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">This works the same as

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">do
    print(&quot;blah&quot
    while(x != 1)</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">Brendan

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.40 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 9.38%
vBulletin Optimisation provided by vB Optimise v2.7.1 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.3.0 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 04:14 PM.

Copyright BetaSoft Inc.