2015년 1월 1일 목요일

Runtime error: call to 'gnu.expr.Closure' has too many arguments (1; must be 0)

Does anyone know what this runtime error means: call to 'gnu.expr.Closure' has too many arguments (1; must be 0)

I get this when I press a "0" or "1" button on a screen. There are seven buttons to press 0 thru 6 and 2 thru 6 work but for some reason 0 & 1 give this error when pressed.

It is just these two buttons that are giving me fits.

Thanks in advance for any help or suggestions.




Are you putting stuff in a list? If so, note that app inventor lusts start in 1. If not, a screenshot of your blocks would be helpful.



Ooops sorry, didn't see the screenshot on my phone...



I just built the app and tried it from the APK instead of AI Companion and now I get the following error:

Runtime Error

call to 'gnu.expr.ModuleMethod' has too many arguments (1; must be 0)

I don't know if that slight difference is significant or not.



Still getting the error but here is a screen shot that show more of the block after I did a little arranging.

I changed the nextQuestion procedure but nothing has changed, still got error and I guess those blocks were not required.




I figured out a workaround but I don't know why this is happening.

I copied the blocks from the procedure button and instead of having the text read from the button like it is for button 2 thru 6 I hard coded the numeric value of 0 and 1 for the Button0 and Button1 click functions.

I cleaned up some more code to reduce the block count too but that isn't related to this error.

I've attached the block screen if anyone has anymore ideas.




May I suggest some things to make life easier?

Rename 'procedure' to 'log_response' or something equivalently functional.
The new name will propagate to all its invocations.

Rename 'index' to 'QuestionListIndex' to avoid confusion.

Explain why listA has to be a list of lists with only one element, the list 0,1,2,3,4,5,6.

Replace the ifelse ladder in displayscores with a single test using the text block 'contains' '123456'  yourAnswers



ListA isn't a single element from what I can tell but maybe it is.  Turns out after I reviewed the blocks some more I didn't even need this - it was in an example that I used to create my version but as you can tell I don't know exactly why.
I think in the example the author used this to set the values for the buttons but I just set the values on the buttons in the Designer and that worked just fine for me.

I don't understand what you mean by the ifelse ladder.  I need to check for which button is pressed to 1. count that it is a symptom and 2. the severity of the symptom.  How can I do this with single test and increase the severity score by the button value?

Thank you for the suggestions, It has been a very, very long time since I developed an application myself so some of the names are going to be off of course.



I belong to the 'If in doubt, rip it out' school of coding.

Correct me if I'm wrong, but it looks like you are using the same numeric scale (0-6)
in the answers to all your questions, and your seven buttons Button0-Button6 return the scores 0-6.
If that's the case, you can just have their .Click logging procedure calls pass the numerical
values (0.0, 1.0, ... 6.0) associated with the corresponding button, and change the logging 
procedure to expect a score instead of a button component.

This would eliminate the need to validate the scores at summation time.  Just add the scores.
If you just want to keep or show non-zero answers, a numeric comparison (> 0) would suffice.



OK, I had this error too and I looked everywhere to try to solve it.  But I did find it...

I had defined a procedure with an input.
I used a call to that proc in 9 button clicks.
I removed the input from the proc.
Now all the calls tot he proc in the 9 buttons were wrong, but the UI didn't recognize the change and flag it as an error.

Once I fixed that, the error was gone.



Agreed, procedure signature management is missing.
I still see type blocking dropping procedure calls onto
the blocks area with no parameter sockets.


댓글 없음:

댓글 쓰기