Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Do ... Until ... Loop (http://www.chiefdelphi.com/forums/showthread.php?t=16598)

Goya 16-01-2003 16:27

Do ... Until ... Loop
 
The syntax I used for a Do .. until ... loop -

Do Until (sFront = 0)

'code

Loop

This creates an infinite loop that I cant get out of, even if sFront = 0. What gives?

In fact, I also tested to see if the value of sFront isn't changing with -

Do Until (sFront = 0)

If sFront = 0 then DEBUG "Im Trapped, Help Me!",CR

Loop

This debugs "Im Trapped, Help Me!"

Thanks in advance,

Goya 16-01-2003 16:48

Actually, I have a more specific question. As I was reading the documentation that came with PBASIC 2.5 I noticed that the Do ... While ... Loop needs a condition with the WHILE and UNTIL, whereas statements are used where the code is inserted.

Do While|Until conditions

'code
statements

Loop While|Until conditions

Question - What is the difference between a condition and a statement ? Can I use sFront = 0 as a condition?

Thanks again,

Goya 16-01-2003 16:56

Hey, I figured out why the code was not working to my liking. In my code, I used a SEROUT, but no SERIN. Remember, you need to use a SERIN to get input from the sensors! This goes to show what sleep deprivation does to people!

maDGag 19-01-2003 01:16

perhaps, ur reassigning

sFont = 0 everytime u loop

mayb im wrong, how about some logical operators instead /

sFont == 0

meh ... forget me ... im still stuck in C++

rbayer 19-01-2003 02:46

No, == is not a valid operator in PBASIC.

Goya's third post hit the nail on the head: if you don't SERIN, you don't get any new data.

As for what makes an expression a condition is the presence of any of the following operators:

=
>(=)
<(=)
<>

Note that = can also be used for assignment. It's function is determined by the context in which it is used. For example:

if rc_sw1=1 then ...

uses = as a comparison operator, whereas

rc_sw1=1

uses = as the assignment operator.

Hendrix 19-01-2003 09:52

(sFront = 0)

that should just be sFront = 0

also before the main programming loop you should put sFront = 0 or something like that to tell pbasic what the value for it is...


All times are GMT -5. The time now is 04:27.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi