|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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, |
|
#2
|
|||
|
|||
|
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, |
|
#3
|
|||
|
|||
|
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!
|
|
#4
|
|||
|
|||
|
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++ |
|
#5
|
||||||
|
||||||
|
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. |
|
#6
|
|||
|
|||
|
(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... |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Actual execution time measurement | Dan | Technical Discussion | 5 | 24-03-2003 11:36 |
| How long is one stamp loop | yangotang | Programming | 3 | 23-01-2003 20:36 |
| NEED HELP with Delay loop for compressor relay switch | archiver | 2001 | 10 | 24-06-2002 02:11 |
| Counter loop | archiver | 2001 | 3 | 24-06-2002 00:44 |
| OK...so I'm totally out of the loop... | Markfuscius | 3D Animation and Competition | 8 | 03-02-2002 02:39 |