Syntax Error userpy

I downloaded code onto our V5 brain and I keep getting the error on the brain and in our console log: File “userpy” line 27 SyntaxError: Invalid system

I’ve atached a screenshot of the code below. Any ideas? I cannot figure out how Line 27 is any different. Thank you!!!

// Beginning of Andrew's code

Python comments start with # not //

7 Likes

Is there a way for the line number generated by the brain at runtime for errors to be made to match the line number is user code?

1 Like

Yes, we improved this for IQ 2nd Gen’s implementation for Python and in the process of rolling it across all other platforms.

The issue lies from initialization code that is tucked outside of view from the editor. We now expose this code via an expandable region to make sure the line numbers match up.

6 Likes

Thank you - changing from // to # for the comments worked! But now I have a Syntax Error on line 48.

I agree with what @sazrocks said…is there a way to sync up the lines of code with whatever the brain is reading? I read @trfriez’s comment, but I think that only applies to working in VEX IQ? I don’t see that handy + on VEX V5 code.

Here’s the rest of the code…anything stick out?? Thank you so much for any help!!!

------------------------------------------

Project: VEXcode Project

Author: VEX

Created:

Description: VEXcode V5 Python Project

------------------------------------------

Library imports

from vex import *

Begin project code

Beginning of Andrew’s code

import vex

#region config

brain = vex.Brain()

M_Fr = vex.Motor(vex.Ports.PORT1, vex.GearSetting.RATIO18_1, True)

M_Bl = vex.Motor(vex.Ports.PORT2, vex.GearSetting.RATIO18_1, True)

M_Br = vex.Motor(vex.Ports.PORT3, vex.GearSetting.RATIO18_1, False)

M_Fl = vex.Motor(vex.Ports.PORT4, vex.GearSetting.RATIO18_1, False)

A_FR = vex.Motor(vex.Ports.PORT8, vex.GearSetting.RATIO18_1, False)

A_BR = vex.Motor(vex.Ports.PORT10, vex.GearSetting.RATIO18_1, True)

A_BL = vex.Motor(vex.Ports.PORT11, vex.GearSetting.RATIO18_1, False)

A_FL = vex.Motor(vex.Ports.PORT12, vex.GearSetting.RATIO18_1, True)

con = vex.Controller(vex.ControllerType.PRIMARY)

#endregion config

con.set_deadband(5)

#region actions

while True:

A_FR_power = 0

A_FL_power = 0

A_BR_power = 0

A_BL_power = 0

M_Fr_power = 0

M_Fl_power = 0

M_Br_power = 0

M_Bl_power = 0

BXactive = 0

BBactive = 0

frontright = 70

frontleft = 70

backright = 70

backleft = 70

buttonL1: Forward

if con.buttonL1.pressing():

A_FR_power = 100

A_FL_power = 100

buttonL2: Reverse

elif con.buttonL2.pressing():

A_FR_power = -100

A_FL_power = -100

else:

A_FR.stop(vex.BrakeType.HOLD)

A_FL.stop(vex.BrakeType.HOLD)

buttonR1: Forward

if con.buttonR1.pressing():

A_BR_power = 100

A_BL_power = 100

buttonR2: Reverse

elif con.buttonR2.pressing():

A_BR_power = -100

A_BL_power = -100

else:

A_BR.stop(vex.BrakeType.HOLD)

A_BL.stop(vex.BrakeType.HOLD)

buttonUp: Forward

if con.buttonUp.pressing():

M_Fr_power = frontright

M_Fl_power = frontleft

M_Br_power = -backright

M_Bl_power = -backleft

buttonDown: Reverse

if con.buttonDown.pressing():

M_Fr_power = -frontright

M_Fl_power = -frontleft

M_Br_power = backright

M_Bl_power = backleft

buttonLeft: go left

if con.buttonLeft.pressing():

M_Fr_power = frontright

M_Fl_power = -frontleft

M_Br_power = backright

M_Bl_power = -backright

buttonRight: go right

if con.buttonRight.pressing():

M_Fr_power = -frontright

M_Fl_power = frontleft

M_Br_power = -backright

M_Bl_power = backleft

buttonY: turn right

if con.buttonY.pressing():

M_Fr_power = frontright

M_Fl_power = -frontleft

M_Br_power = -backright

M_Bl_power = backright

buttonA: turn left

if con.buttonA.pressing():

M_Fr_power = -frontright

M_Fl_power = frontleft

M_Br_power = backright

M_Bl_power = -backleft

A_FR.spin(vex.DirectionType.FWD, A_FR_power)

A_FL.spin(vex.DirectionType.FWD, A_FL_power)

A_BR.spin(vex.DirectionType.FWD, A_BR_power)

A_BL.spin(vex.DirectionType.FWD, A_BL_power)

M_Fr.spin(vex.DirectionType.FWD, M_Fr_power)

M_Fl.spin(vex.DirectionType.FWD, M_Fl_power)

M_Br.spin(vex.DirectionType.FWD, M_Br_power)

M_Bl.spin(vex.DirectionType.FWD, M_Bl_power)

Without correct formatting it’s hard to tell.

Always post code between [code] tags (or ``` tags) and keep indentation as that’s critical for Python code.

1 Like

Thanks for that tip…I figured out that it was indentation, so I fixed that. Thank you SO MUCH for all of your help!!

1 Like