Highlighted
Super Contributor.
Super Contributor.
810 views

  Good morning, can i make an invoke a method created in the form of events? For example:

  method-id button3_Click final private.
       01 newForm2 type CfgEmpresa.Form1.
       procedure division using by value sender as object e as type System.EventArgs.
           set newForm2             to new CfgEmpresa.Form1
           invoke newForm2::ShowDialog()
       end method.
   
  method-id ef-NumPedido_KeyPress final private.
       77 wt pic x(020).
       procedure division using by value sender as object e as type System.Windows.Forms.KeyPressEventArgs.
            move e::KeyChar to wt
           if wt equal "13"
              invoke button3_Click
           end-if
      
       end method.

method-id button3_Click final private.
       01 newForm2 type CfgEmpresa.Form1.
       procedure division using by value sender as object e as type System.EventArgs.
           set newForm2             to new CfgEmpresa.Form1
           invoke newForm2::ShowDialog()
       end method.
   
 method-id ef-NumPedido_KeyPress final private.
       77 wt pic x(020).
       procedure division using by value sender as object e as type System.Windows.Forms.KeyPressEventArgs.
            move e::KeyChar to wt
           if wt equal "13"
              invoke button3_Click
           end-if
      
       end method.

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Invoke

Jump to solution

No, that wouldn't work because the event methods are expecting certain parameters such as the object that triggered the event and the eventargs. That is why the procedure division using header looks like:

procedure division using by value sender as object e as type System.EventArgs

It would probably make more sense to place the code that you want executed by both events into a common method of your own and then invoke this method from both event methods.

Example:

method-id button3_Click final private.
      procedure division using by value sender as object e as type System.EventArgs.
          invoke self::commonMethod
     end method.

method-id ef-NumPedido_KeyPress final private.
      77 wt pic x(020).
      procedure division using by value sender as object e as type System.Windows.Forms.KeyPressEventArgs.
           move e::KeyChar to wt
          if wt equal "13"
              invoke self::commonMethod    
          end-if
      end method.

method-id commonMethod private.
      01 newForm2 type CfgEmpresa.Form1.
      procedure division.
          set newForm2             to new CfgEmpresa.Form1
          invoke newForm2::ShowDialog()
      end method.

View solution in original post

0 Likes
1 Reply
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Invoke

Jump to solution

No, that wouldn't work because the event methods are expecting certain parameters such as the object that triggered the event and the eventargs. That is why the procedure division using header looks like:

procedure division using by value sender as object e as type System.EventArgs

It would probably make more sense to place the code that you want executed by both events into a common method of your own and then invoke this method from both event methods.

Example:

method-id button3_Click final private.
      procedure division using by value sender as object e as type System.EventArgs.
          invoke self::commonMethod
     end method.

method-id ef-NumPedido_KeyPress final private.
      77 wt pic x(020).
      procedure division using by value sender as object e as type System.Windows.Forms.KeyPressEventArgs.
           move e::KeyChar to wt
          if wt equal "13"
              invoke self::commonMethod    
          end-if
      end method.

method-id commonMethod private.
      01 newForm2 type CfgEmpresa.Form1.
      procedure division.
          set newForm2             to new CfgEmpresa.Form1
          invoke newForm2::ShowDialog()
      end method.

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.