Exit Loop issue

20 views
Skip to first unread message

flyway38

unread,
Jan 1, 2023, 1:36:46 PM1/1/23
to jallib
Hello to all,

Maybe something I don't understand, but here's my issue:

...
         if nTimeOut >= nTimeOutMax then
            exit loop
         end if

         bRtn = 1
      end loop

This code still runs bRtn = 1 when nTimeOut is >= nTimeOutMax.
Think it shouldn't do that, right?
Thank you.

Regards,
Filipe Santos

Rob CJ

unread,
Jan 1, 2023, 2:00:31 PM1/1/23
to jal...@googlegroups.com
Hi Filipe,

Happy New Year!

If I am right the exit loop will only exit the current loop. I see you are using two loops so it does not exit the second one.

Kind regards,

Rob


Van: jal...@googlegroups.com <jal...@googlegroups.com> namens flyway38 <fsfo...@gmail.com>
Verzonden: zondag 1 januari 2023 19:36
Aan: jallib <jal...@googlegroups.com>
Onderwerp: [jallib] Exit Loop issue
 
--
You received this message because you are subscribed to the Google Groups "jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallib+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/8b148810-86d8-49a7-9757-a8c21e391835n%40googlegroups.com.

flyway38

unread,
Jan 1, 2023, 3:39:13 PM1/1/23
to jallib
Hi Rob,

Happy New Year !!

Two Loops ??
Not sure if theres two loops here...
Check my code with more details, please.

      while !fReturn loop
         print_string(serial_hw_data,"Waiting for SIM to be Ready...")
         print_crlf(serial_hw_data)
         FlushRCVD
         delay_1ms(1_000)
         fReturn = CheckComms_SIMready()
         --
         nTimeOut = nTimeOut +1
         if nTimeOut >= nTimeOutMax then
            exit loop
         end if
         --
         bRtn = 1
      end loop

I need to exit this While Loop if nTimeOut >= nTimeOutMax without setting bRtn = 1...
Thank for your help.

Cheers,
FS

vasi vasi

unread,
Jan 1, 2023, 10:27:24 PM1/1/23
to jal...@googlegroups.com
Filipe, perhaps Rob thinks that the "exit loop" trows you between "while" and "loop" and to pass over "while" you need a second "exit loop"? :P



--
Vasi

Rob CJ

unread,
Jan 2, 2023, 3:41:45 AM1/2/23
to jal...@googlegroups.com
Hi Filipe,

If you do not want to change bRtn why not change it to:

         if nTimeOut >= nTimeOutMax then
            exit loop
         else 
              bRtn = 1
         end if
         --
 Kind regards,

Rob
       

Verzonden: zondag 1 januari 2023 21:39
Aan: jallib <jal...@googlegroups.com>
Onderwerp: Re: [jallib] Exit Loop issue
 

flyway38

unread,
Jan 2, 2023, 6:53:59 AM1/2/23
to jallib
Hi Rob,

That option will set bRtn to 1 from starting of the count of nTimeOut.
I need to bRtn to be set only depending on what happens inside while-loop... Check my second post for the complete while-loop code in use.
Thanks anyways.

Cheers,
FS

Rob CJ

unread,
Jan 2, 2023, 8:06:10 AM1/2/23
to jal...@googlegroups.com
Hi Filipe,

I do not yet understand the issue. In your code bRTn is always set to 1 but if  I understand you correctly you do not want that to happen when nTimOut reaches a certain level (exit loop in that case). With the code I suggested that is exactly what happens, bRTn is always set to on except when the timeout occurs and the exit loop occurs.

Am I missing something here?

Kind regards,

rob


Verzonden: maandag 2 januari 2023 12:53

flyway38

unread,
Jan 2, 2023, 12:38:54 PM1/2/23
to jallib
Hi Rob,

Yes, you are right.
That code doesn't work the way I need.
Have already codded it in a different way.
Thanks anyways for your time.
Cheers,

FS
Reply all
Reply to author
Forward
0 new messages