Why do people not know how to use functions?

Literally reducing the size of this robot program by like... 75% by making a function to pack two bytes into a 16-bit register, rather than doing it online every single time.

Also...Universal Robots, why does UR Script not have bitshift or bitwise operators? Seriously. My function literally has to use the builtin `integer_to_booleans(...)` function, assign individual bools to the right spots in a temporary array, and then `booleans_to_integer(...)` back.

This *could* have just been python. You clearly tried to use similar syntax. And yet...

Also yes I know I can make my own bit-twiddling functions using arithmetic. Guess what gets easier to do once there are not like three hundred copies of the same commands scattered throughout the robot program?


I have thus far trimmed 12078 lines from the program and replaced them with 13 functions totalling around 56 lines.

Included in the lines that did not get replaced were 151 copies of time-based wait commands used in the pattern "Send command signal to external device; Wait 0.5s; Wait on reply signal from the device; do stuff" because why do we need time waits when we have hardware signal interlocks?

Sign in to participate in the conversation

cybrespace: the social hub of the information superhighway jack in to the mastodon fediverse today and surf the dataflow through our cybrepunk, slightly glitchy web portal support us on patreon or liberapay!