PDA

View Full Version : if ... then loop



lerameur
- 9th November 2010, 15:49
Hi, here is a simple program, I do not see anything wrong with it, but the compiler gives the following error:
Line 86: Endif without a matching IF..THEN
.. If I remove the endif then I do not get an error message, but I need it there, I will have more if then loops.

thanks


Mainloop:

ADCON0.2 = 1 'Start Conversion
ADCIN 0, voltage_selector 'analog pin 1 get the 8 bit result Check the battery voltage
If (voltage_selector >=0) AND (voltage_selector < 205) Then gosub SixVolt
Endif


goto Mainloop
end

mackrackit
- 9th November 2010, 16:19
The ENDIF is only used if there are multiple line to to IF

IF x = 5 THEN
DO THIS
DO THAT
ENDIF
You can have multiple IF statements like you have it.

IF x = 5 THEN LABEL_B
IF x = 15 THEN LABEL_A

fratello
- 9th November 2010, 16:19
My opinion :
If (voltage_selector >=0) AND (voltage_selector < 205) Then
Gosub SixVolt
Endif
Sorry Mr.Mackrackit, post in the same time...

mackrackit
- 9th November 2010, 16:29
Sorry Mr.Mackrackit, post in the same time...
The more the merrier :)

lerameur
- 9th November 2010, 18:36
Hi now I am getting these error messages:
I even tried with some good working code and I still get these errors, any ideas ??



C:\PBP>pbp -p16f88 CHARGEUR2.bas
PICBASIC PRO(TM) Compiler 2.50c, (c) 1998, 2008 microEngineering Labs, Inc
All Rights Reserved.
PM Assembler 4.08, Copyright (c) 1995, 2006 microEngineering Labs, Inc.
Error C:\PBP\CHARGEUR.ASM 3 : [235] Opcode Expected Instead of ''
Error C:\PBP\CHARGEUR.ASM 5 : [235] Opcode Expected Instead of ''
Error C:\PBP\CHARGEUR.ASM 9 : [238] Preprocessor Directive Expected
Error C:\PBP\CHARGEUR.ASM 9 : [235] Opcode Expected Instead of ' (( '
Error C:\PBP\CHARGEUR.ASM 10 : [238] Preprocessor Directive Expected
Error C:\PBP\CHARGEUR.ASM 10 : [235] Opcode Expected Instead of ' (( '
Error C:\PBP\CHARGEUR.ASM 11 : [238] Preprocessor Directive Expected
Error C:\PBP\CHARGEUR.ASM 11 : [235] Opcode Expected Instead of ' (( '
Error C:\PBP\CHARGEUR.ASM 12 : [238] Preprocessor Directive Expected
Error C:\PBP\CHARGEUR.ASM 12 : [235] Opcode Expected Instead of ' (( '
Error C:\PBP\CHARGEUR.ASM 13 : [238] Preprocessor Directive Expected
Error C:\PBP\CHARGEUR.ASM 13 : [235] Opcode Expected Instead of ' (( '
Error C:\PBP\CHARGEUR.ASM 14 : [238] Preprocessor Directive Expected
Error C:\PBP\CHARGEUR.ASM 14 : [235] Opcode Expected Instead of ' (( '
Error C:\PBP\CHARGEUR.ASM 15 : [238] Preprocessor Directive Expected
Fatal C:\PBP\CHARGEUR.ASM 15 : [300] Too Many Errors

C:\PBP>

mackrackit
- 9th November 2010, 18:52
From PM.txt

235 Opcode Expected Instead of 'Token'
Any text starting in column 2 or later which is not a commented is assumed
to either be an opcode, a pseudo-op or the name of a defined macro. All
other tokens will generate this error.

Can we see your code?

lerameur
- 9th November 2010, 19:01
its copied right off the net:

Include "modedefs.bas" ' Include serial modes

SO con 0 ' Define serial output pin
B0 Var byte
B1 Var byte

mainloop:
For B0 = 3 To 1 Step -1 ' Countdown step size
For B1 = 0 To 10 Step B0 ' Count to 10 (or so)
Serout SO,N2400,[#B1," "]
Next B1
Serout SO,N2400,[13,10] ' End of line
Pause 100 ' Delay
Next B0
Goto mainloop

End

lerameur
- 9th November 2010, 20:00
I just tried to compile some of my old working codes. Nothing is compiling...weird..

still get:

C:\PBP>pbp -p16f88 CHARG2.bas
PICBASIC PRO(TM) Compiler 2.50c, (c) 1998, 2008 microEngineering Labs, I
All Rights Reserved.
PM Assembler 4.08, Copyright (c) 1995, 2006 microEngineering Labs, Inc.
Error C:\PBP\CHARG2.ASM 3 : [235] Opcode Expected Instead of ''
Error C:\PBP\CHARG2.ASM 5 : [235] Opcode Expected Instead of ''
Error C:\PBP\CHARG2.ASM 9 : [238] Preprocessor Directive Expected
Error C:\PBP\CHARG2.ASM 9 : [235] Opcode Expected Instead of ' (( '
Error C:\PBP\CHARG2.ASM 10 : [238] Preprocessor Directive Expected
Error C:\PBP\CHARG2.ASM 10 : [235] Opcode Expected Instead of ' (( '
Error C:\PBP\CHARG2.ASM 11 : [238] Preprocessor Directive Expected
Error C:\PBP\CHARG2.ASM 11 : [235] Opcode Expected Instead of ' (( '
Error C:\PBP\CHARG2.ASM 12 : [238] Preprocessor Directive Expected
Error C:\PBP\CHARG2.ASM 12 : [235] Opcode Expected Instead of ' (( '
Error C:\PBP\CHARG2.ASM 13 : [238] Preprocessor Directive Expected
Error C:\PBP\CHARG2.ASM 13 : [235] Opcode Expected Instead of ' (( '
Error C:\PBP\CHARG2.ASM 14 : [238] Preprocessor Directive Expected
Error C:\PBP\CHARG2.ASM 14 : [235] Opcode Expected Instead of ' (( '
Error C:\PBP\CHARG2.ASM 15 : [238] Preprocessor Directive Expected
Fatal C:\PBP\CHARG2.ASM 15 : [300] Too Many Errors

ScaleRobotics
- 9th November 2010, 20:29
I get a good compile, with the same PM and the same PBP, using code from post 7. Don't know what to tell you.


C:\PBP>pbp -p16f88 CHARG2.bas
PICBASIC PRO(TM) Compiler 2.50c, (c) 1998, 2008 microEngineering Labs, Inc.
All Rights Reserved.
PM Assembler 4.08, Copyright (c) 1995, 2006 microEngineering Labs, Inc.
243 words used.
C:\PBP>

lerameur
- 9th November 2010, 21:33
you know what, I just installed the compiler, did not reboot since.
rebooted now and guess what... o Yes... somebody want to spank me ? ;)
sooo stupid

mackrackit
- 9th November 2010, 23:08
somebody want to spank me ?
Not me!!! I will pass on that!!!