Go to Post We want you here, and we want you back. Welcome. - Gary Dillard [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

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 19-01-2003, 10:47
Morgoth Morgoth is offline
Registered User
#0471 (Cybertigers)
 
Join Date: Oct 2002
Location: Michigan
Posts: 35
Morgoth is an unknown quantity at this point
Whats wrong with this code?

This is my first year doing the programming and I am having trouble with if statements. I know C++, Javascript, regular BASIC but i can't figure out whats wrong with this.

if (p1_y > 135) then skip:
skip:
relay1_fwd = 1

I used "skip:" because if I just put relay1_fwd = 1 under then, it tells me that it expects a label or something directlyafter then. I have tried it with 135 < p1_y and that doesn't work either. I have verified that something is hooked up to relay1, so that isn't the problem. It compiles fine but when I put the y axis on port 1 to greater than 135 nothing happens. I know the joystick works because I have checked it using dashboard.

Also, does white space matter in PBASIC?

Thanks a lot
  #2   Spotlight this post!  
Unread 19-01-2003, 10:52
Morgoth Morgoth is offline
Registered User
#0471 (Cybertigers)
 
Join Date: Oct 2002
Location: Michigan
Posts: 35
Morgoth is an unknown quantity at this point
BTW I have tried this in v1.33 and PBASIC 2.5 the same thing seems to be happening in both.
__________________
"Lock the Doors"

NASA chief flight director Leroy Cain on the loss of Columbia's signal.
  #3   Spotlight this post!  
Unread 19-01-2003, 11:07
ChrisA's Avatar
ChrisA ChrisA is offline
Registered User
#0857 (Superior Roboworks)
Team Role: College Student
 
Join Date: Feb 2002
Location: Michigan Tech
Posts: 157
ChrisA is on a distinguished road
Send a message via AIM to ChrisA
Relays have 2 variables to control them. So if your other variable (relay1_rev) isnt set to 0 then nothing will happen. If you switch directions elsewhere in the code and you don't change relay1_fwd to 1 there, then you will have both of the 2 relay variables set to 1 which is an error.

Also, the : after skip in the if then statement line is not necessary.

Why don't you try a different word than skip. There are some words that you cannot use for labels. Apparently this is one of them. I'm sure you could go look in the manual and find that skip is a different command. I took your code and loaded it into the editor and changed skip and added a random letter after it and the code tokenized.

If the code does not tokenize then I would not run it on the Robot Controller.
__________________
Programmer
----------------
Team#857
Superior Roboworks

WildStang Alum

Last edited by ChrisA : 19-01-2003 at 11:18.
  #4   Spotlight this post!  
Unread 19-01-2003, 11:09
Ameya's Avatar
Ameya Ameya is offline
Freelance Goon
FRC #0293 (SPIKE Robotics)
Team Role: Alumni
 
Join Date: May 2001
Rookie Year: 2000
Location: Pennington, NJ
Posts: 67
Ameya is on a distinguished road
Send a message via ICQ to Ameya Send a message via AIM to Ameya
Quote:
if (p1_y > 135) then skip:
skip:
relay1_fwd = 1
In PBasic 1.33 and earlier, if-then branching works like this: if the condition is true, then execution continues at the label following "then"; if it is false, then execution continues at the next statement. In your statement, the label "skip:" comes immediately after the if statement, so it is executed in both cases. Here's what it should look like:

if (p1_y > 135) then skip:
relay1_fwd = 0 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;'the "else" case
goto endif:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;'without this, execution would just continue at the next line, "skip"

skip:
relay1_fwd = 1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp; 'the "then" case

endif:
__________________
Ameya Agaskar
Team 293 alumnus
  #5   Spotlight this post!  
Unread 19-01-2003, 11:45
Morgoth Morgoth is offline
Registered User
#0471 (Cybertigers)
 
Join Date: Oct 2002
Location: Michigan
Posts: 35
Morgoth is an unknown quantity at this point
Thankyou a lot!!!! I did a little changing around and I got it working.
__________________
"Lock the Doors"

NASA chief flight director Leroy Cain on the loss of Columbia's signal.
Closed Thread


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
What is your most prefered programming language? Hailfire Programming 156 19-01-2005 21:42
Autonomous code PBoss Programming 7 14-01-2003 15:29
Does your team use the Default code. Jeff McCune General Forum 2 09-01-2003 14:46
How much code can an IFI controller handle? Larry Barello Programming 7 10-02-2002 19:06
Patent source code? Kyle Fenton Chit-Chat 3 20-10-2001 17:53


All times are GMT -5. The time now is 13:47.

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