1 Reply Latest reply on May 12, 2008 8:32 AM by Newsgroup_User

    which handler calls specific handler?

    Level 7
      Hi

      Is is possible do find out which handler(global script function) has called
      some specific handler?

      For example I have 3 handlers (f1, f2, f3) calling handler subF()

      on f1
      subf('aaa')
      end


      on f2
      subf('bbb')
      end


      on f3
      subf('bbb')
      end

      on subF param
      put "param"
      end

      It is just a schema, each handler have over 50 lines of code
      And I have a problem that sometimes my handler subF gets empty parameters. I
      could debug it in authoringmode, but my scripts have more switch nodes and
      application works differently in projector and in authoring-mode. Therefore
      I need to do it in runtime

      Is is possible to define in runtime using lingo which handler has called
      current handler?

      Any help will be appreciated
      game_dev


        • 1. Re: which handler calls specific handler?
          Level 7
          The short answer is No. There is no predefined way to know which
          handler called another handler.

          The long answer is Yes. You can write up a way to make it do that.
          Perhaps the simplest way would be to setup a global variable like
          gLastCalled and set it just before calling the actual handler... so your
          script would look like this:

          global gLastCalled
          on f1
          gLastCalled="f1"
          subf('aaa')
          end


          on f2
          gLastCalled="f2"
          subf('bbb')
          end


          on f3
          gLastCalled="f3"
          subf('bbb')
          end

          on subF param
          put "param"
          end

          Then, when your program crashes or whatever it does wrong, just cehck
          the value of gLastCalled.

          Another way to do it that may be out of order since your program is
          bigger and more complex than this example would be to have your handlers
          return something after peforming their function. Like you can return
          the name of the handler or some other useful identifier... then check
          the value of that return to see where it came from.