Forum Discussion

sorbetus's avatar
sorbetus
New Contributor
8 years ago
Solved

Get a value returned from an event handler function.

Hello,

 

Is there a way to get a value returned with an event handler function such as this one?

 

function GeneralEvents_OnLogCheckpoint(Sender, LogParams) {

var x;
//code
return x;

}

 

 

Thanks much!

  • Since the event handlers are not something that you are explicitly firing in code, I'm not sure I understand a) what you would need to return from an event handler like this and b) how you would reference it in code.  It's not like you call the event handler somewhere in order to return the value.

    If you want the event handler to generate a value that you want to use elsewhere, use the event handler to write the value out to some sort of global variable, either declared in a code unit or as a Project or Project Suite variable.  Then reference that value within your tests.

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Since the event handlers are not something that you are explicitly firing in code, I'm not sure I understand a) what you would need to return from an event handler like this and b) how you would reference it in code.  It's not like you call the event handler somewhere in order to return the value.

    If you want the event handler to generate a value that you want to use elsewhere, use the event handler to write the value out to some sort of global variable, either declared in a code unit or as a Project or Project Suite variable.  Then reference that value within your tests.

    • sorbetus's avatar
      sorbetus
      New Contributor

      Thank you Robert, I will be using a global variable.