function parameters-event, variable

I have 2 scripts, one is part of the editor and the other a keyboard app that gets around the nativeText problems on the PC.

The editor calls the keybaord app and it comes up, you enter the information, concat the string and send it back. What I want to do is tell the typed string which of two functions to go to. I thought it best to have the function that calls it send in a parameter that can be read and based on that send the value to the right place. Only when I try to send in a parameter, it comes back as being nil.

editor script
    bleh=1

    kb.SetupKb()

    kb.Keyboard(bleh)

keyboard script

     function TestMode(event, bleh)
            local bleh
            local id= event.target.id

                theString = theField.text

                print(“Give me Bleh-” … bleh)
                Callbackfunction(theString)

                --return theString
            else
                theField.text = theField.text…string.char(event.target.id)

            end
        end

What am I missing??

Thanks!

This code looks incomplete to diagnose your issue.  In your editor script you call a function called kb.Keyboard, but you haven’t shown that function’s code.  Likewise in your keyboard script, you’ve shown a function called TestMode but haven’t   shown how that function gets called.  Also, within that function, you refer to a variable called theField, but you haven’t shown where this variable comes from (unless it’s global).  The statement “-- return theString” is commented out, and it’s not clear if this is intentional or not.

  • Andrew

You can also just pass in the function pointer itself… (Provided the possible functions called take the same type/number of arguments/none).

To pass in the function point, just pass in the name of the function, such as test(var1, var2, myFunction )

To call the passed in function, you just say myFunction()… (you can add args to it if you want as well).

As far as things being passed around ending up as nil… Like Auk said, it doesn’t look like there’s enough there to know what’s going on. (plus you used bleh in the argument, and also declared bleh as a local – very hard to tell whats going on).

This code looks incomplete to diagnose your issue.  In your editor script you call a function called kb.Keyboard, but you haven’t shown that function’s code.  Likewise in your keyboard script, you’ve shown a function called TestMode but haven’t   shown how that function gets called.  Also, within that function, you refer to a variable called theField, but you haven’t shown where this variable comes from (unless it’s global).  The statement “-- return theString” is commented out, and it’s not clear if this is intentional or not.

  • Andrew

You can also just pass in the function pointer itself… (Provided the possible functions called take the same type/number of arguments/none).

To pass in the function point, just pass in the name of the function, such as test(var1, var2, myFunction )

To call the passed in function, you just say myFunction()… (you can add args to it if you want as well).

As far as things being passed around ending up as nil… Like Auk said, it doesn’t look like there’s enough there to know what’s going on. (plus you used bleh in the argument, and also declared bleh as a local – very hard to tell whats going on).