Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to make methods in beanshell?

I made a simple beanshell ide in android using an edittext and a button. When the button is clicked, Interpreter.eval() is called and edittext.getText().toString() is passed in as the parameter. I want to know: how can I make a method in beanshell and run it?

This is the code i m trying to execute in my beanshell ide:

import android.widget.Toast

int i=add(1, 5);
Toast.makeText(context, ""+i, 5000).show();

int add(int i, int j){
    return i+j;
}

But i get the following error:

Command not found: add()

like image 590
awareeye Avatar asked Dec 14 '11 13:12

awareeye


1 Answers

Have you tried moving your function definition above its usage, like so;

import android.widget.Toast

int add(int i, int j){
    return i+j;
}

int i=add(1, 5);
Toast.makeText(context, ""+i, 5000).show();

Does that make any difference?

like image 174
Tobbe Avatar answered Oct 06 '22 23:10

Tobbe