# Test for Undefined OR empty/unanswered Table Value (Linear Combo Systems)

tl;dr Students enter 2 values into a table. How do I test to see if the tablevalue is empty/undefined?

I still have a way to go, fixing spacing, directions, etc.

Students will be given a system of 2 equations. Their goal is to select the value that needs to be multiplied by the 1st and 2nd equations so that when we add the equations, one of the variables is canceled out.

In the graph area, you’ll see that I am using labels of points to show the equations. I have the 2 original equations. Then I repeat the 2 equations with (m_a) and (m_b) to show the multiplication.
m_a & m_b are defined by the values students type into the table.

But if they haven’t typed into the table, the equations are showing m_a & m_b as “undefined”. In the CL area for the graph, I’m trying to check for undefined. If m_a is undefined, I want a variable d_a to equal 0. If m_a is defined, I want d_a to be 1. But d_a is equalling 1 even when m_a is not defined.

I’d prefer the value of d_a to update even if students haven’t yet clicked submit.

Maybe there’s a better way to accomplish this instead of using d_a? My thoughts were that I’d create two equations:
**if m_a is undefined, put (?) at the front and end.
**if m_a is defined, put the value of m_a at the front and end.

Linear Systems CL

(EDIT: Moved to Questions instead of discussion)

1 Like

You can test any input to see if it is blank using isBlank(input goes here) or if it has been filled using not(isBlank(input goes here))

You can also use firstDefinedValue in some of these situations to give a value of 0 (or whatever you want) when another is undefined

1 Like

Thanks Jay,
I’ve tried the codes below, but I’m still getting 1 even if nothing has been entered into the table.

bounds:
makeBounds(-7,7,-7,7).setStrategy(top())
number(“m_a”): table1.cellNumericValue(1,2)
number(“m_b”): table1.cellNumericValue(2,2)

number(“d_a”):
when isUndefined(“m_a”) 0
otherwise 1

number(“d_b”):
when isBlank(“m_b”) 0
otherwise 1

Note in the first line of the graph, ma=undefined but da=1 and db=1.

1 Like

Ahh got it. You want isUndefined(number(“m_a”))

1 Like

Now I get an error warning: Unknown function “number”

1 Like

Sorry, should’ve been clearer. If you’re gonna use number as a source you need a source component. So all together you’d have isUndefined(this.number(“m_a”)). “this” assuming everything is in the same component. If you’re looking up a number in a different component you’ll need to reference that component.

Thank you that worked!
Lesson learned. Even for local variables in the CL, I can’t call “m_a” I need to call this.number(“m_a”) whenever i want to do anything with that.
Now it’s working!

If you don’t actually need it to be a number in the calculator you can just make it m_a = … and then you won’t need to define it as a number in the next section. But yes, if you are defining it as a number in the calculator you need to call on it as such.