# Setting range values from random numbers

This is what I tried:

r=randomGenerator(button7.pressCount)

a=r.int(-7,7)
number(`a`):a
b=r.int(-8,a)

What I want to occur is to create two points whose locations are randomly generated along the x-axis. One point (A) will stay within -7 and 7. I want the other point (B) to have a minimum value of -8 and a max value set by the location of the first point so that its always to the left of A.

Does something like this help?

I think you solutions works just fine (maybe there a typo related to quotation marks)
Let me know if I misunderstood you question.

That solution worked great! apparently adding the number(‘b’)=b is the thing that needed to happen. Thank you very much.

So, maybe we can take this a step further: I am working on an activity for segment addition. So, A and C need to be at the end and B in the middle. This is what I start with:

a=r.int(-7,7)
b=r.int(-8,a)
c=r.int(a,7)
number(`a`):a
number(`b`):b
number(`c`):c

This is what I tried and it did not work:
a=r.int(-7,7)
b=r.int(-8,a-1)
c=r.int(a+1,7)
number(`a`):a
number(`b`):b
number(`c`):c

I am fairly certain there is something I need to do but I cannot figure out what. By the way, this is my first week learning CL language so I thank you for your assistance.

You can’t do operations in CL without using `numericValue`, so replace “a-1” with `numericValue("\${a}-1")`. Similar for your “a+1”.

That works amazingly! Thank you. Is there somewhere in the CL documentation that talks about the use of \${ } that I could read more on? The last couple questions I have had have been answered with this notation.

Not sure. Use it to call variables into strings, otherwise it will just put the text in. Generally, I think if the variable’s output doesn’t match the input needed, you need to use `\${ }`.

For example, in the above, `numericValue` takes a string (indicated by the quotes), but “`a`” is a number, so you need to use `\${ }`. Without it, it would be undefined because “`a`” is just text. It doesn’t know where to look for the variable without the `\${ }`.