Error


Closed Thread
Results 1 to 7 of 7

Thread: Error

Hybrid View

  1. #1
    tekdavid's Avatar
    tekdavid Guest

    Question Error

    i am using picbasic and this should work but it dont can any one tell me were my error is in program fornext

    error fornext.bas,12: ':' or '=" expected (token 'var')
    error fornext.bas,13: variable expected (token 'i')
    error fornext.bas,17: next without maching for




    12: i VAR byte
    13: for i = 1 to 4
    14: high 0
    15: pause 1000
    16: low 0
    17: next i

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    The clue is the common denominator for lines 12, 13 and 17... it doesn't like your variable.

    I don't have PICBasic, only PICBasic Pro, however, whilst your code would be valid in PBP, in PBC I believe the variables are predefined... you must use them, although (and I stand to be corrected) you might be able to alias them... try this as a starter...

    for B0 = 1 to 4
    high 0
    pause 1000
    low 0
    next B0

    Consult the PBC manual for variables.

  3. #3
    Join Date
    Nov 2004
    Location
    Saskatchewan Canada
    Posts
    189


    Did you find this post helpful? Yes | No

    Default

    You do have to use the pre-assigned variables as mentioned here or use this at the beginning:

    i symbol B0

    to assign your own name to the variable.

    Bart

  4. #4
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello tekdavid,

    TD>>12: i VAR byte
    13: for i = 1 to 4
    14: high 0
    15: pause 1000
    16: low 0
    17: next i<<

    I also question lines 14 and 16...

    Usually it is a High Porta.0 or Low Porta.0 or
    it may be High Portb.0 or Low portb.0

    Either way, It might be good to assign a port to it.

    Another problem... What do your lines BEFORE line 12 look like?
    Sometimes the compiler may flag line 12, but the problem is actually
    in line 10 or 11....

    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  5. #5
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    I think it's the illegal (undeclared) variable 'i' in this case Dwayne...

    High 0 and Low 0 are valid for addressing pin 0 of your PIC (note that which physical pin that pin 0 refers to is dependant of the PIC family - refer to the PICBasic manual for that).

  6. #6
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Melanie,

    Melanie>>High 0 and Low 0 are valid for addressing pin 0 of your PIC (note that which physical pin that pin 0 refers to is dependant of the PIC family - refer to the PICBasic manual for that).<<

    Gotcha...I wasn't sure which pic they were using...

    I always seem to get myself into trouble if I don't spell it out <smile>.. Thus I kinda do things the "long Hand" way...GPIO.0, Porta.0, or whatever. Its kinda like those headers at the beginning of your file, If it is already defined for your chip, it can save *ME* a lot of time trying to figure out why my compiler is burping at me.
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

Similar Threads

  1. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  2. Optimizing DIV
    By skimask in forum mel PIC BASIC Pro
    Replies: 41
    Last Post: - 22nd September 2008, 04:58
  3. pbp245 compliation error
    By Woodzy in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 25th July 2006, 05:59
  4. 16F88 Compile error
    By Toley00 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 2nd November 2005, 00:22
  5. Compiler/Assembler Error
    By LT_Pic in forum General
    Replies: 7
    Last Post: - 21st July 2005, 09:47

Members who have read this thread : 0

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