Expected no more tokens found NAMED_OPERATOR, or Fun with Parentheses

Ok this is the line of code that’s giving me the error

*if ((week = "Monday") or (week = "Tuesday")) or ((week = "Wednesday") or (week = "Thursday")) or (week = "Friday")

My best guess is that there are to many things to keep track of and if that’s the case I need a new way to code this. Could any body help?

Just in case you need the section the help you solve it here you go

*label 1_week

*gosub minute
*gosub hour
*gosub day
*gosub week
*gosub month

You check your phone. 
*if (minute < 10)
 Today is ${week}, ${month} ${day}. The time is ${hour}:0${minute}${midday}.
*if (minute > 9)
 Today is ${week}, ${month} ${day}. The time is ${hour}:${minute}${midday}.

*if ((week = "Saturday") or (week = "Sunday"))
 *choice
   #Nothing yet
    *goto 1_week
*if ((week = "Monday") or (week = "Tuesday")) or ((week = "Wednesday") or (week = "Thursday")) or (week = "Friday")
 *choice
   *selectable_if ((hour <= 8) and (hour >= 7)) and (midday = am) #Go to school. (Would anybody care if i didn't go?)
    *set minute +30
    *goto school

   #Go to 24-mart (30 min)
    *set minute +30
    *goto 24

   #Sleep (passes 8 hours)
    *set hour +8
    *goto 1_week

   #Open bedside drawer (Inventory)
    *goto bed

Or can only compare two statements at once. So if you want two compare three or more statements, you need to put parenthesis around each or statement.

(A or B)

((A or B) or C)

(((A or B) or C) or D)

Etc.

So in your case you need 4 sets of parenthesis, not counting the parenthesis around each week = "something" statement:

*if (((((week = "Monday") or (week = "Tuesday")) or (week = "Wednesday")) or (week = "Thursday")) or (week = "Friday"))
2 Likes

It told me that out expected no more token but found a close parentheses.

You should make a variable to control whether it’s a weekend or not, and then set them accordingly (to false if it’s monday, tuesday, wednesday, thursday or friday, true if saturday or sunday) when a new day starts, then you just read the value of this variable.

*create is_weekend false
*if (is_weekend)
	*comment this is a weekend
*else
	*comment this is a workday

With this you can use a simple check to know if it’s a weekend or not.

1 Like

Okay that issues fixed but now this issue is

   *selectable_if ((hour <= 8) and (hour >= 7)) and (midday = am) #Go to school. (Would anybody care if i didn't go?

Character 28 was expected no more tokens found close parentheses.

Character 28 I believe is right behind the 8??

*selectable_if (((hour = 7) or (hour = 8)) and (midday = am)) #blah

If how I would do it. The code is much easier to read that way. If I understand correctly, you are trying to just make it 7 or 8. Anyhow, the parentheses should be right in my example above.

For me, the two key parentheses patterns to master are:

((a) and (b))

and

(((a) and (b)) and (x))

Those seem to come up the most.

Also, might be easier to use a 24 hour time for this, since you won’t need to check am or pm.

Thank You both I finally fix the issue. I use parentheses all the time and still run into issues like these😂

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.