Highlighted
Absent Member.
Absent Member.
9006 views

One more C# WPF to Cobol

Jump to solution

here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 

Best Regards

Bernd Riemke

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: One more C# WPF to Cobol

Jump to solution

E-mailing me directly with product problems is not the correct way to receive product support.

Please post the problems directly to the Community Site forum so that everyone can see them or open up a support incident with Customer Care.

That being said, yes I have looked at them and there appears to be a bug in the new handling of initializing properties directly in a constructor when setting the property to another object.

It works correctly if you set the property to a string like "test" but not when setting it to a data item defined as a string.

I will rpi this problem.

As a workaround you can set the properties after the object has been instantiated.

Note that I am using the TrimEnd method to set the property as when you are using pic x data items they will be padded with spaces out to the maximum length and I don't believe that it what you want.

You should do the same thing when setting the header text in your grid or else each column will be 256 bytes wide.

     *            set GZ to new WPFGridZeilen(
     *                              property GrSpalte01 = SPStr01
     *                              property GrSpalte02 = SPStr02  
     *                              property GrSpalte03 = SPStr03
     *                              property GrSpalte04 = SPStr04
     *                              property GrSpalte05 = SPStr05
     *                              property GrSpalte06 = SPStr06
     *                              property GrSpalte07 = SPStr07
     *                              property GrSpalte08 = SPStr08
     *                              property GrSpalte09 = SPStr09
     *                              property GrSpalte10 = SPStr10
     *                              property GrSpalte11 = SPStr11
     *                              property GrSpalte12 = SPStr12
     *                              property GrSpalte13 = SPStr13
     *                              property GrSpalte14 = SPStr14  
     *                              property GrSpalte15 = SPStr15
     *                              property GrSpalte16 = SPStr16
     *                              property GrSpalte17 = SPStr17
     *                             )
                   set GZ to new WPFGridZeilen
                   set GZ::GrSpalte01 to spstr01::TrimEnd
                   set GZ::GrSpalte02 to spstr02::TrimEnd
                   set GZ::GrSpalte03 to spstr03::TrimEnd            
                   set GZ::GrSpalte04 to spstr04::TrimEnd
                   set GZ::GrSpalte05 to spstr05::TrimEnd
                   set GZ::GrSpalte06 to spstr06::TrimEnd
                   set GZ::GrSpalte07 to spstr07::TrimEnd
                   set GZ::GrSpalte08 to spstr08::TrimEnd
                   set GZ::GrSpalte09 to spstr09::TrimEnd
                   set GZ::GrSpalte10 to spstr10::TrimEnd
                   set GZ::GrSpalte11 to spstr11::TrimEnd
                   set GZ::GrSpalte12 to spstr12::TrimEnd
                   set GZ::GrSpalte13 to spstr13::TrimEnd
                   set GZ::GrSpalte14 to spstr14::TrimEnd
                   set GZ::GrSpalte15 to spstr15::TrimEnd
                   set GZ::GrSpalte16 to spstr16::TrimEnd
                   set GZ::GrSpalte17 to spstr17::TrimEnd
                   invoke GridList::Insert(z0, GZ)
                   add 1 to z0
          end-perform.

View solution in original post

0 Likes
19 Replies
Highlighted
Absent Member.
Absent Member.

RE: One more C# WPF to Cobol

Jump to solution

Hi Bernd, there is a generics sample included in the product that is worthwhile looking through.

Start the Samples browser from the start menu

Select the COBOL for .NET section

Select Generics subsection

The first sample in the solution shows how to use a generic list of strings.

Also take a look at the Collections sample.

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: One more C# WPF to Cobol

Jump to solution

ok, this helps a Little bit but i Need this lines too:

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

 List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

Best Regards

Bernd Riemke

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: One more C# WPF to Cobol

Jump to solution

For more Background:

This is in the WPF:

...

       <CollectionViewSource x:Key="cvsOptions"/>

...

This line is in c#:

...

((CollectionViewSource)this.FindResource("cvsOptions")).Source = Options

...

Best Regards

Bernd Riemke

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: One more C# WPF to Cobol

Jump to solution

This is not right...

         set ((CollectionViewSource)this.FindResource("cvsOptions")).Source to strings

Best Regards

Bernd Riemke

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: One more C# WPF to Cobol

Jump to solution

this is wrong too:

          set ((CollectionViewSource)this::FindResource("cvsOptions"))::Source to strings

The complier have problems wit the first "(" ...

Best Regards

Bernd Riemke

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: One more C# WPF to Cobol

Jump to solution

Hi Bernd, casts are done in COBOL using the syntax AS type-specifier.  I've created the following to demonstrate how this might be written in COBOL.  The three lines in method m, correspond to the original three C# lines, the rest is just framework around them...

     $set ilref"presentationframework.dll"

     $set ilusing"System.Windows.Data"

      class-id a.

      method-id m.

          declare options as list[string]

          set self::FindResource("cvsOptions") as type CollectionViewSource::Source to options

          declare GridList as list[type WPFGridZeilen]

      end method.

      method-id FindResource.

      procedure division using by value s as string

                         returning ret as type CollectionViewSource.

          set ret to null

      end method.

      end class.

      class-id WPFGridZeilen.

      end class.

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: One more C# WPF to Cobol

Jump to solution

The Compiler do something wrong...

     *    ((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

         declare options as list[string]

After this Line;

         set self::FindResource("cvsOptions") as type CollectionViewSource::Source to options

The Compiler goes back to the WPF AND Not to the next Line!?

This is the next Line:      

     *      List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

         declare GridList as list[type WPFGridZeilen]

Best Regards

Bernd Riemke

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: One more C# WPF to Cobol

Jump to solution

Not sure I fully understand the question, but in my last post I did omit the actual construction of the list.  This can be done either using our portable collections syntax:

         declare GridList as list[type WPFGridZeilen]

        create GridList

...or by using a standard 'new' (constructor) expression:

         declare GridList as list[type WPFGridZeilen] = new List[type WPFGridZeilen]

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: One more C# WPF to Cobol

Jump to solution

For more Background:

I will fill the List  like this: (c#)

                   GridList.Add(new WPFGridZeilen()

                   {

                       GrSpalte01 ="001",

                       GrSpalte02 = "Home Town"

                    }

For the filling i Need the "new" WPFGrifZeilen...

How can i fill the Gridines ?

1. New...

2. Filll...

???

Best Regards

Bernd Riemke

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: One more C# WPF to Cobol

Jump to solution

Hi Bernd, I think I answered this one in my post on your other thread "Public Class for a WPF Data Grid":

The 2.2 version of Visual COBOL does have support for property initialization as part of a 'new' expression.

Try something like:

     01 o type WPFGridZeilen.

     set o to new WPFGridZeilen(property GrSpalte01 = "Hello 01"

                                property GrSpalte02 = "Hello 02")

         display o::GrSpalte01

         display o::GrSpalte02

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: One more C# WPF to Cobol

Jump to solution

But there is a Bug....

Can I send you the source?

So you can see what i mean...

Best Regards

Bernd Riemke

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.