Example: OnAction = MyMethod(‘1’,RecordIndex)
hugh?
you can pass field if you want?!
OnAction = MyMethod(‘1’,field1)
I don’t think my example was clear.
What I want is on a form, in the OnAction event to call a method and write some values to pass to the method.
I know I can call a method from within a method and pass values between them, but right now that can’t be done from the form to the method. All we can do is select a method to put into a form event.
Or am I missing something?
Yes, I believe you are missing something
you can do this:
var a = field1
var b = field2
MyMethod(a,b)
if you attach this to the onAction, this should work!
Again, it seems I have not made myself clear.
Your example calls a second method from within a first method that is attached to an event on a form. I know you can do that.
What I am asking for is the ability to pass values into a method, directly from the event which calls the method.
Right now, if I want to attach a method to the onAction event of a form, I can only select it from the available methods. What I want is to be able to select it from the available methods and write one or more values that I can send to the method directly from the form event.
In the onAction method, you can access the data on the form.
In the Method Editor, look under Application\Forms%%your_formname%%\Elements
There you find all the elements you have on your form, IF you gave the elements a name!!! If you named them, they will show up there and then you can get their values.
Hope it helps,
Paul
I know that. But there are times, like in my original example, where I would like to pass a value to a method from the form, with a value that is not on the form. That is what I am asking for.
Which value are you talking about then?
If the value is not on your form, it must be either a global or a value from another form or a related value. All can be accessed through the Method Editor tree.
If that doesn’t work for you, please give a more clear example of which value you’re trying to pass
Paul
Lets say in lots pf places in my application I have delete buttons and I want all of them to go to one global method where I will have all of my delete routines. I would like, in the event which call to the method to send the method two values which are not on the form – the first is whether to popup a confirm message and the second is which stored procedure to run. So what I would like to put on the form OnAction event is something like: DelRec(1,“spDelPeople”). That would tell the funtion to first popup a confirm button and then run the spDelPeople stored procedure.
I know I can just call the DelRec method and from there I can look and see which button on which form called the method and I could create some login with that to do the same thing – but that is a whole lot more non-generic code than what would be needed if I could just send those two values from the form directly.
OK, example is clear. But it’s not possible
Best bet is making a lookup table with columnc formname, button,popup and sp.
When the generic method is triggered, you get current formname and methodtriggerelement, with that lookup the proper record in your lookup table and get the values of the columns popup and sp. And with those results shoe or not show the popup and execute the SP.
this way it’s still generic, I think.
Hope it helps.
Yeah. There are lots of work-arounds, none of them nearly as elegant as what I am asking for. Thats why I asked for it.