Probably a simple question


#1

I could probably spend time checking to see how this would work, but I figure this might be a simpler solution.

I’m trying to figure out if a certain matter of math in CS. Essentially, I want to write a line of code that looks something like this:

*if (${var1} + ${var2} > ${var3})
  *set ${var4} +${var1}
  *set ${var4} +${var2}
  *set ${var4} -${var3}

Assuming that “${var1}” and so forth would translate into a number rather than a word, is the above code going to properly group var1 and var2, or would I need to place the ) before the > ? Likewise, is there a way to condense the second and third lines- ie, *set var4 to increase by var1 and var2 at the same time, then reduce by var3? Not a big deal, just a matter of saving a bit of time.


#2

Yup, you’ll still need it.
Mathematical operations (+ - * / > < =) are single operations that can only be understand by CS in a single bracket.


As for the code compacting, you’ll need the brackets, just like what I mentioned above.
However, it’s not

Instead, it should be

*set var4


#3

Thank you. It’s actually also helpful for me to know that I can, for example,
*set var4 +(${var1} * ${var2})
and that it’s one mathematical operation per brackets.

Thank you.


#4

BTW, I just remembered.
I think *set var4 +var3 works fine, too. Not sure if using ${} will produce an error, tho.


#5

@Shawn_Patrick_Reed

*temp var1 10
*temp var2 20
*temp var3 25
*temp var4 0

starting variables:

var1 = ${var1}
*line_break
var2 = ${var2}
*line_break
var3 = ${var3}
*line_break
var4 = ${var4}


*page_break begin code segment


*if (var1 + var2) > var3
 *set var4 +var1
 *set var4 +var2
 *set var4 -var3

variables after code:

var1 = ${var1}
*line_break
var2 = ${var2}
*line_break
var3 = ${var3}
*line_break
var4 = ${var4}