Absent Member.
Absent Member.
872 views

Visual Cobol #region problem

Hi!

I will convert this c# code snip in Visual Cobol code:

==============================================================================

#region MinimumValue Property

public static double GetMinimumValue(DependencyObject obj)

{

return (double)obj.GetValue(MinimumValueProperty);

}

public static void SetMinimumValue(DependencyObject obj, double value)

{

obj.SetValue(MinimumValueProperty, value);

}

public static readonly DependencyProperty MinimumValueProperty =

DependencyProperty.RegisterAttached(

"MinimumValue",

typeof(double),

typeof(TextBoxNumeric),

new FrameworkPropertyMetadata(double.NaN, MinimumValueChangedCallback)

);

private static void MinimumValueChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)

{

TextBox _this = (d as TextBox);

ValidateTextBox(_this);

}

#endregion

==============================================================================

I know that #Region = $Region is...

But how can i convert the rest?

Have anyone an idea?

 

 

 

 

 

 

Best Regards

Bernd Riemke

Tags (3)
0 Likes
3 Replies
Micro Focus Expert
Micro Focus Expert

Region is only used to make source code easier to read, so it can be ignored. It's not clear to me why your title refers to it as a "problem".

Ignoring the region directive, the COBOL equivalent would be along these lines:

*> I don't think COBOL has an equivalent of C#'s "readonly", so I'm making this a read-only property
01 minimumValueProperty type DependencyProperty
    value type DependencyProperty::RegisterAttached(
        "MinimumValue"
        type of binary-float
        type of type TextBoxNumeric
        new FrameworkPropertyMetadata(binary-float::NaN, MinimumValueChangedCallback)
    )
    static property as "MinimumValueProperty" with no set.
method-id GetMinimumValue(obj as type DependencyObject) returning result as float-long static.
    set result to obj.GetValue(MinimumValueProperty) as float-long
end method.
method-id SetMinimumValue(obj as type DependencyObject, #value as float-long) static.
    invoke obj::SetValue(MinimumValueProperty, value)
end method.
method-id MinimumValueChangedCallback(d as type DependencyObject,
                                      e as type DependencyPropertyChangedEventArgs)
          static private.
    declare _this as type TextBox
    if d instance of type TextBox
        set _this to d as type TextBox
    end-if
    invoke ValidateTextBox(_this)
end method.

That's untested, but it would be something along those lines. If you could be more specific about your problem, we might be able to be more helpful.

0 Likes
Micro Focus Expert
Micro Focus Expert

You can use "INITIALIZE ONLY" to make a field read-only.


Fields - Documentation

0 Likes
Micro Focus Expert
Micro Focus Expert

Thanks - missed that in the docs. And also this one in the language comparison:

documentation.microfocus.com/.../GUID-160C3A93-45A9-4F03-A6F5-CACD9F848C98.html
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.