I'm going to try this out but first predict what it does. In this activity, a student will be prompted to enter a number in an input component (labelled input1), and once they do, a note will display the message "Your number was" followed by whatever number they input. These two lines of script go together as sink and source, which is one thing that's been sort of confusing me. I thought there always had to be two lines of script, one about each, but up till now, that hasn't always been the case.

Tried it, didn't work at first because I forgot to check the f(x) Math option in the input, now it works on screen 5 of this puppy.

So we needed a variable here because not every student will type in the same thing, but we want whatever they do type to be immediately displayed.

**But why didn't we need one for, say, the guess-the-slope-of-the-line activity?**Was it because the slope was being sent to a graph as opposed to a note, and the graph sort of takes care of the variable part of it with the y = ax thing? And also this part of the script

**number("a"):**which seems to be defining the variable AND the sink at the same time?

I notice that in the variable assignment, the structure is similar to a sink assignment, in that, after the equals sign, it names the component that will be the source, and its data type.

I'll continue looking at Jocelyn's collection now. I've already looked at and blogged about the first 3-4 so far but I'll look again with new eyes. I'll also try a new strategy of looking at the preview first, then figuring out all I can about what the script must have been. Eg 1 preview:

3 components, a graph, a note, and an input. Whatever is typed into the input immediately shows up on the graph. So the source is the input and the sink is the graph. There must be script in the graph's gearbox. The script must include sinktype: note1.sourcetype. Also since the equation I typed is being displayed properly and not as y = x^2, which is what I actually typed, it must be that what I type is being interpreted as latex, so the f(x)math option must have been selected in the input, and the sourcetype must have been latex. I'm not sure what the sinktype would be. Also in the actual graph there must be something about a variable that is the name of the function being graphed?

And after checking: In the graph the function has been called f(x), so that's the variable definition. The input has been labelled input1. The script is where I expected it to be, in the graph's gearbox. The script is one line:

function("f"):simpleFunction(input1.latex)

So the sinktype was function, it includes the variable f in brackets and quotes so that it references which variable we want going into the sink, and the source type is latex. The only part that surprised me was the simpleFunction part. Why does that have to be there? And since it's after the colon, does that mean it's a sink or a source type? I expected a label to follow the colon, which there is one but not immediately after.

Back to the CL doc, where I'll look up simpleFunction (again) in the table under Graph.

I found it but only under function, and under the Sinks part. It says:

function(identifier: string)Sets the output of simpleFunction() to a variable defined in the graph.

The accompanying example is:

# Get the latex string from "equationInput" and assign# it to f in the calculator.

function("f"): simpleFunction(equationInput.latex, "x")

which is virtually identical to the one in Joce's eg except for the "x" part, which I seem to recall is something that if it's not there, is assumed.

I also looked under "Functions" and found simpleFunction. It says:

simpleFunctionTakes a latex string and returns a function which can, for example, be passed into the function sink of a calculator.The first argument is the latex string, and additional arguments are The names of the variables to treat as input variables (defaults to)one-variable function in terms of x if not specified

I really need to come up with some kind of a diagram to help me order things in the script, and I suspect others who are struggling with CL might too.

## No comments:

## Post a Comment