Highlighted
Absent Member.
Absent Member.
800 views

.Net Cobol

Jump to solution

How would one do this in Cobol .Net?  My main concern is the IsValidData function.  How would I write that in .net cobol using invoke.  I tried

                   invoke type Validator::IsPresent(txtCode) and

                   invoke type Validator::IsDecimal(txtPrice) returning validData

but there is a syntax error with the 'and'.

 

If isValidData() then

    *Do somthing

end if

 

Public Function IsValidData() as Boolean

    Return Validator.IsPresent(txtCode) andalso

                Validator.IsDecimal(txtPrice)

end function

 

Class - Validator

Public Shared Function IsPresent(textbox as Textbox) as Boolean

        if textbox.text = " " then Messagebox.Show("Error")

         return false

         else

          return true

end function.

 

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: .Net Cobol

Jump to solution

Or somewhat more concise:

method-id IsValidData returning myRet as condition-value.
   set myRet to Validator::IsPresent(txtCode) and Validator::IsDecimal(txtPrice)
end method IsValidData.

Whether this is better is a matter of opinion, of course; it's just a stylistic difference.

Personally, since this method has no parameters and is a function of the state of the object, I'd make it a property:

method-id get property IsValidData returning myRet as conditiion-value.
    set myRet to Validator::IsPresent(txtCode) and Validator::IsDecimal(txtPrice)
end method.

Or equivalently:

property-id IsValidData condition-value.
   getter.
      set property-value to Validator::IsPresent(txtCode) and Validator::IsDecimal(txtPrice)
end property IsValidData.

Note all of this assumes Validator is non-null, etc.

View solution in original post

0 Likes
2 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: .Net Cobol

Jump to solution
You could use something like:

method-id IsValidData.
procedure division returning myRet as condition-value.

if Validator::IsPresent(txtCode) and
Validator::IsDecimal(txtPrice)
set myRet to true
else
set myRet to false
end-if
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: .Net Cobol

Jump to solution

Or somewhat more concise:

method-id IsValidData returning myRet as condition-value.
   set myRet to Validator::IsPresent(txtCode) and Validator::IsDecimal(txtPrice)
end method IsValidData.

Whether this is better is a matter of opinion, of course; it's just a stylistic difference.

Personally, since this method has no parameters and is a function of the state of the object, I'd make it a property:

method-id get property IsValidData returning myRet as conditiion-value.
    set myRet to Validator::IsPresent(txtCode) and Validator::IsDecimal(txtPrice)
end method.

Or equivalently:

property-id IsValidData condition-value.
   getter.
      set property-value to Validator::IsPresent(txtCode) and Validator::IsDecimal(txtPrice)
end property IsValidData.

Note all of this assumes Validator is non-null, etc.

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.