' don't start animation on devices that don't support it
m.model = createObject("roDeviceInfo").getModel()
'Get the first character of the model number. Anything less than a 4 corresponds to a device not suited to animations.
first = Left(m.model, 1).trim()
if first <> invalid and first.Len() = 1
firstAsInt = val(first, 10)
if (firstAsInt) > 3
...
This code is so bad! Where do i start, even! Hey you - anonymous bad coder @ RokuCo:
- Why are you using member variable m.model when only local var is ever needed?
- Why are you doing .trim() when left(,1) is already returns string of length 1? How could trim() possibly improve on that?
- Why are you checking "first <> invalid" when right above that you have readily trusted the result will never be invalid? (cue: .trim() call would never fly with invalid)
- There are string functions len(s), left(s, ..). And there are string methods s.len(), s.left(..) that do (about) the same. You can use either - but why can't you make up your mind using the same group in the same code segment?
- Why are you using val(, 10) instead of val()? (What, in case BrightScript suddenly stops using decimal system? ... yet .getModel() keeps using it?)
- Why are you using parenthesis around variable name in "if (firstAsInt) > 3"?
- Why all this gallimaufry when you could have just done it in 1 line: `if createObject("roDeviceInfo").getModel()
> "3" then` ? Have you never heard that strings compare lexicographically?!
- Why are you even doing this??? What makes you think models >4000 are better at animation? Hint: try 5000 (roku tv) vs 3600 (new stick)
Such code penmanship is so inept, that you Sir are doing disservice to humanity by writing code that other developers will read. Find something else to do with your life.
Come to think of it... all i got curious was why would somebody check the first digit of model number re animation. But the more i read, closer i get to contemplating which is less painful - continue analyzing it or gouge my eyes?