News:

Let's find out together what makes a PIC Tick!

Main Menu

IF statement inside CASE

Started by Dave-S, Mar 18, 2022, 11:55 AM

Previous topic - Next topic

Dave-S

Can I not use a IF statement inside a CASE?
The "If year//4 = 0 Then LeapYear = 1" brings up a error "if without endif"

Tried
If year//4 = 0 Then
LeapYear = 1
Endif

brings up a error "if without endif"


Select month       'get DayCounter for the Day
                   Case 01
                        DayCounter = 0
                        DayCounter = DayCounter + date     '0 - 31
                   Case 02
                        DayCounter = 31  'jan 31
                        DayCounter = DayCounter + date     '32 - 59
                   Case 03
                        If year//4 = 0 Then LeapYear = 1
                        DayCounter = 59  'feb 28       '60 - 90
                        DayCounter = (DayCounter + date) + LeapYear
                   Case 04
                        DayCounter = 90  'mar  31           '91 - 120
                        DayCounter = (DayCounter + date) + LeapYear
               

Pepe

yes it can, the error must be somewhere else

RGV250

#2
Hi,
I copied your code (both ways for the If) and added a few variables and it compiled, I would look for an earlier "If" statement in the program.

Bob

Dompie

Quote from: RGV250 on Mar 18, 2022, 12:24 PMHi,
..... I would look for an earlier "If" statement in the program.

Bob
....yes or an include file that now fires an error. My last such error: "print var," yes with comma and that is not allowed anymore.

Johan

joesaliba

Dave,

Do you have EndSelect? Might cause the error.

RGV250

Just a though, is it possible to post the code as there is not a lot else we can do without it.

Bob