Search code examples
pythonpepperchoregraphe

Operate with a variable passed by a box


I'm working with a real pepper and Choregraphe. I have a dialog that grab the input of a string (numbers 1 to 6) and inserts them into a specific output string. Then i created a custom box in python to convert that string into number and do operations (put a counter or add the variables it receives in input). To test the operation of "taking the variable" I created this if, but it does not work. Can you tell me the correct syntax to use to take the input parameter?

click here for the photo of code


Solution

  • Several problems with your code:

    • The parameter you're getting is the "value" parameter of your function, you don't need the value = self.getParameter(word) line. self.getParameter is for getting box parameters (edited with the wrench at the bottom left corner of a box), which you don't seem to have on that box.
    • You're getting a second parameter, "word", which seems useless and may even cause problems (did you add it? Normally there should only be one parameter)
    • You shouldn't put the self.onStopped() on the same line as the if
    • the second branch of your "if" is missing a dot: selfonStopped1.
    • You should give meaningful names to your outputs

    (it might be worth spending some time doing Python and Choregraphe tutorials, like these)