if ... then loop


Closed Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Sep 2006
    Posts
    747

    Default if ... then loop

    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

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    The ENDIF is only used if there are multiple line to to IF
    Code:
    IF x = 5 THEN
      DO THIS
      DO THAT
    ENDIF
    You can have multiple IF statements like you have it.
    Code:
    IF x = 5 THEN LABEL_B
    IF x = 15 THEN LABEL_A
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default

    My opinion :
    If (voltage_selector >=0) AND (voltage_selector < 205) Then
    Gosub SixVolt
    Endif
    Sorry Mr.Mackrackit, post in the same time...

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Sorry Mr.Mackrackit, post in the same time...
    The more the merrier
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default humm compiler problem after all

    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>

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    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?
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    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

  8. #8
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    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

  9. #9
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    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>
    http://www.scalerobotics.com

  10. #10
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default Grrrr

    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

  11. #11
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    somebody want to spank me ?
    Not me!!! I will pass on that!!!
    Dave
    Always wear safety glasses while programming.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts