Go to Post The game starts, we learn, the game changes, we learn some more, the game changes again, we learn even more . . . - Bill Moore [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Spotlight this post!  
Unread 08-11-2002, 18:40
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
Quote:
Originally posted by Marc P.
if var=127 then pwm1=127, if var=254 then pwm1=254
Unfortunately, this type of syntax does not work. The only thing after the "then" can be a label to go to if the condition is true. For example:

if (sensor1<127) then dontZeroPWM1
PWM1=127
dontZeroPWM1:

With this code, anytime sensor1 is greater than or equal to 127, PWM1 will be set to 127. When sensor1 is less than 127, the condition is true and the code skips the line that would normally set PWM1.

This is by far one of the most confusing parts of PBASIC and is the reason why many times you will find yourself writing "if not" instead of just plain "if." Once you are able to think of "if" statements as being used to skip portions of code, everything becomes much easier.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to access other Digital inputs on OI? DougHogg Electrical 2 12-03-2003 13:57
Pre-Autonomous OI Communication Ryan Meador Programming 19 23-01-2003 20:38
Competition Sequence for PBasic ttedrow Programming 12 23-01-2003 08:49
Digital inputs, bandwith, errors? Micah Brodsky Programming 7 20-01-2003 16:08
Serious Controller Ideas archiver 1999 28 23-06-2002 23:01


All times are GMT -5. The time now is 19:02.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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