Newbe problem on first try

General discussion on mikroBasic PRO for PIC.
Post Reply
Author
Message
RFKoenig
Posts: 2
Joined: 08 Dec 2018 01:57

Newbe problem on first try

#1 Post by RFKoenig » 17 Feb 2020 02:18

Hello,
I'm finally starting to use all this fine equipment I've purchased. I have a EasyPIC V7 and I'm using MikroeBasic Pro for PIC.
I've typed the program on page 309 of Programming in BASIC and I've gotten several errors

while 'endless loop
if cnt = 50 then 'increment PORTB after 50 interrupts
PORTB = PORTB + 1 'Increment PORTB by 1
cnt = 0 'reset variable cnt
end if

wend
Messages 304 1) if is not a valid identifier
2)expected "end" but found "if"
3)expected "." but found "cnt"

I've typed in the program and triple checked my typing. What's wrong here, please help.

Bob Koenig

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: Newbe problem on first try

#2 Post by jovana.medakovic » 18 Feb 2020 14:25

Hello,

Your while loop is not correctly written. The correct way to use while statement is:

Code: Select all

while expression  
   statements
wend
and in your case, you don't have expression.

Try this:

Code: Select all

while TRUE 'endless loop
   if cnt = 50 then 'increment PORTB after 50 interrupts
      PORTB = PORTB + 1 'Increment PORTB by 1
      cnt = 0 'reset variable cnt
   end if
wend
Kind regards,
Jovana

RFKoenig
Posts: 2
Joined: 08 Dec 2018 01:57

Re: Newbe problem on first try

#3 Post by RFKoenig » 23 Feb 2020 18:27

Thank you very much,
The expression, TRUE, wasn't in the book but it's now
A lesson learned. Thank you again, Jovana.

Post Reply

Return to “mikroBasic PRO for PIC General”