|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
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
|
|||
|
|||
|
BTW I have tried this in v1.33 and PBASIC 2.5 the same thing seems to be happening in both.
|
|
#3
|
|||||
|
|||||
|
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. Last edited by ChrisA : 19-01-2003 at 11:18. |
|
#4
|
|||||
|
|||||
|
Quote:
if (p1_y > 135) then skip: relay1_fwd = 0 &n bsp; 'the "else" case goto endif: &n bsp;'without this, execution would just continue at the next line, "skip" skip: relay1_fwd = 1 &n bsp; 'the "then" case endif: |
|
#5
|
|||
|
|||
|
Thankyou a lot!!!! I did a little changing around and I got it working.
![]() |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |