Highlighted
Absent Member.
Absent Member.
1431 views

WPF Call My own Methode

Jump to solution

Hi!

I will call my own Methode in WPF...

Have anyone a short sample fro me?

Best Regards

Bernd Riemke

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: WPF Call My own Methode

Jump to solution

This is covered in the docs under comparison of managed COBOL to C# here:

You can add snippets to your code using the Ctrl+K, Ctrl+X keys.

For method code use Ctrl+K, Ctrl-X and then type met and select method-id and fill in the blanks.

For your simple example with no parameters it would look like:

      invoke self::ButtonOnOff

...

method-id. ButtonOnOff.
procedure division.
   goback.
end-method.

For examples of passing parameters or returning parameters:

      01 mystring string.
      procedure division.
         
          set mystring to "test"
          invoke self::MyMethod(mystring)
          set mystring to self::MyMethod2
      end method.
      method-id MyMethod public.
      procedure division using mystring as string.

          set mystring to "Hello"
          goback.
      end method.

      method-id MyMethod2 public.
      procedure division returning mystring as string.

          set mystring to "Hello"
          goback.
      end method.

View solution in original post

0 Likes
5 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: WPF Call My own Methode

Jump to solution

You would call your own methods in the same manner that you would call any method in a .net framework class, using either the set statement if you are returning a value or the invoke statement if you are not.

Take a look at the samples browser under Start menu-->All Programs-->Micro Focus Visual COBOL-->Samples and then select Windows Presentation Foundation in the left hand window and then one of the samples listed in the right hand side and open this up in Visual Studio.

Also click on COBOL for .NET in the left window and select Core .NET for a sample that demonstrates using basic .NET functionality like callng methods, etc...

Thanks

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: WPF Call My own Methode

Jump to solution

I have look there before but that is not what i Need!

I need a own Methode under WPFand that will i invoke...

So the documentation and samples are not helping there...

Best Regards

Bernd Riemke

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: WPF Call My own Methode

Jump to solution

Hi,

for any sample stuff on WPF, I usually search the web for samples in C#: The xaml part of those samples will fit for Visual COBOL. An example here is to get more events which will need a hook in XAML.

Using Visual COBOL 2.1 upd 1 I had no problem so far in moving such C# into Visual COBOL, which makes it easier to mix legacy structures with the new stuff. This include things like datagrid and tabbed screens.

Joachim Blome

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: WPF Call My own Methode

Jump to solution

like this in C#:

       ...

       ButtonOnOff();

       ...

       ...  

       public void ButtonOnOff()

       {

       }

Best Regards

Bernd Riemke

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: WPF Call My own Methode

Jump to solution

This is covered in the docs under comparison of managed COBOL to C# here:

You can add snippets to your code using the Ctrl+K, Ctrl+X keys.

For method code use Ctrl+K, Ctrl-X and then type met and select method-id and fill in the blanks.

For your simple example with no parameters it would look like:

      invoke self::ButtonOnOff

...

method-id. ButtonOnOff.
procedure division.
   goback.
end-method.

For examples of passing parameters or returning parameters:

      01 mystring string.
      procedure division.
         
          set mystring to "test"
          invoke self::MyMethod(mystring)
          set mystring to self::MyMethod2
      end method.
      method-id MyMethod public.
      procedure division using mystring as string.

          set mystring to "Hello"
          goback.
      end method.

      method-id MyMethod2 public.
      procedure division returning mystring as string.

          set mystring to "Hello"
          goback.
      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.