Edward Krug
Edward Krug

Reputation: 11

How to use input box to enter formula?

I am using NetLog to test learning curve formula. I would like to use the input box to interactively enter something as simple as
current-tick * 23
No joy. I can capture a current ticks value in a set command, but I cannot get the input box to accept a formula. Once I learn how to do it, I can work out how to do larger formula.

  set knowledge-increment []
  set knowledge-increment + learning-equation * 25

learning-equation is the label for the input box.

Any suggestions?

Upvotes: 1

Views: 371

Answers (2)

Edward Krug
Edward Krug

Reputation: 11

I got it working in basic form. Now to apply it. The input box called increment, uses a no quotes equation.

I used stuff as a global.

The code line contains the set command within the quotes. Now I can use stuff as a constant as in:

run (word “set stuff ” increment)

show stuff * ticks

I just have to avoid using global variables such as ticks in a turtle setting. Thank you Lon and Andrew

Upvotes: 0

Lon Thomas
Lon Thomas

Reputation: 96

The input box sets the value of the global variable specified. It is a string. To use that string in code, something like this will work

run (word "show " learning-equation)

or more to your point of setting a value

globals [new-equ]
to go
  run (word "set new-equ " learning-equation)
  show (word "new-equ is " new-equ)
  end

Upvotes: 1

Related Questions