Top
PowerCOBOL V11.0 User's Guide
FUJITSU Software

5.4.3 Setting and Referencing Control and Form Properties

The following COBOL statements can act on the properties that are assigned to controls and forms:

There are some restrictions on the syntax and usage of these statements when they are used to set and refer to properties.

5.4.3.1 MOVE Statement

The MOVE statement copies the value of a control's property to a data control.

5.4.3.1.1 Syntax
MOVE CONTROL-PROPERTY TO RECEIVE-CONTROL 
5.4.3.1.2 Syntax and Usage Rules

Refer to the "NetCOBOL Language Reference" for additional information.

5.4.3.1.3 Example

Move the current value of the horizontal scroll bar control (CmScroll1) to the variable defined in the WORKING-STORAGE section.

DATA DIVISION.                                            
WORKING-STORAGE SECTION.                                  
 01  CURR-SCROLL-VALUE  PIC  S9(9) COMP-5.                
  :                                                     
PROCEDURE DIVISION.                                       
  :                                                     
    MOVE  "Value" OF CmScroll1 TO CURR-SCROLL-VALUE.                                                    

Note

Every property has attributes. In the above example, the attribute for Value is S9(9) COMP-5.

5.4.3.2 ADD Statement

The ADD statement is used to increase the numeric value of one control by the numeric value of another.

5.4.3.2.1 Syntax
ADD CONTROL-PROPERTY TO {DATA-NAME [ROUNDED]}
    [ON SIZE ERROR UNCONDITIONAL-STATEMENT]
    [NOT ON SIZE ERROR UNCONDITIONAL-STATEMENT]
    [END-ADD]
5.4.3.2.2 Syntax and Usage Rules

Refer to the "NetCOBOL Language Reference" for additional information.

5.4.3.2.3 Example

ADD the large step of vertical scroll bar control (CmScroll2) to the CURR-VALUE, which is maintained in the WORKING-STORAGE section.

DATA DIVISION.                                                  
WORKING-STORAGE SECTION.                                        
01 CURR-VALUE PIC  S9(9) COMP-5 VALUE IS 0.                     
  :                                                           
PROCEDURE DIVISION.                                             
  :                                                            
  ADD  "LargeStep" OF CmScroll2 TO CURR-VALUE.                 
  :                                                       

5.4.3.3 SUBTRACT Statement

The SUBTRACT statement is used to decrease the numeric value of one control's property by the numeric value of a data control.

5.4.3.3.1 Syntax
SUBTRACT CONTROL-PROPERTY
        FROM {CONTROL-NAME [ROUNDED]} ...
    [ON SIZE ERROR UNCONDITIONAL-STATEMENT ]
    [NOT ON SIZE ERROR UNCONDITIONAL-STATEMENT ]
    [END-SUBTRACT]
5.4.3.3.2 Syntax and Usage Rules

Refer to the "NetCOBOL Language Reference" for additional information.

5.4.3.3.3 Example

SUBTRACT the large step of the vertical scroll bar control (CmScroll2) from the CURR-VALUE, which is maintained in the WORKING-STORAGE section.

DATA DIVISION.                                                  
WORKING-STORAGE SECTION.                                        
  01  CURR-VALUE  PIC  S9(9) COMP-5 VALUE IS 0.                 
  :                                                       
  PROCEDURE DIVISION.                                           
  :                                                       
      SUBTRACT "LARGESTEP" OF CmScroll2 FROM CURR-VALUE.       
  :                                                       

5.4.3.4 COMPUTE Statement

The COMPUTE statement is used to calculate the numeric value of a control using the numeric value of another.

5.4.3.4.1 Syntax
  COMPUTE  Unique-Data-Name  =  Arithmetic-formula
5.4.3.4.2 Syntax and Usage Rules

Refer to the "NetCOBOL Language Reference" for additional information.

5.4.3.4.3 Example

Set the font size of StaticText control (CmStatic1) to be 2 points larger than the font size of CommandButton control (CmCommand1).

 DATA DIVISION.
WORKING-STORAGE SECTION.

PROCEDURE DIVISION.

...

COMPUTE "Size
" OF "Font" OF CmStatic1 = "Size" OF "Font" OF CmCommand1 + 2

5.4.3.5 IF Statement

The IF statement is used to evaluate properties and control the execution of the program based on the results.

5.4.3.5.1 Syntax
IF CONTROL-PROPERTY COMPARISON OPERATOR   
        RIGHT-SIDE-OF-CONDITION
THEN  {{STATEMENT-1} ...  |  NEXT  SENTENCE  }
{ 
  {ELSE  {STATEMENT-2} ... [END-IF]}|
  {ELSE  NEXT SENTENCE  }|
  {END-IF}}
5.4.3.5.2 Syntax and Usage Rules

The property of a control can be used as the left side of an IF statement. Refer to the "NetCOBOL Language Reference" for a complete list of the rules for using IF statements.

5.4.3.5.3 Example

If the CheckBox control (CmCheck1) is checked then the image called 'IMAGE-BMP' is displayed. If it is not checked then nothing is displayed.

 IF  "Value" OF CmCheck1  =  1                
   MOVE "IMAGE-BMP" TO "ImageName" OF CmImage1   
END-IF.                                                 

5.4.3.6 DISPLAY Statement

The DISPLAY statement is used to display data on the screen of the computer.

5.4.3.6.1 Syntax
DISPLAY {UNIQUE-NAME | CONSTANT | CONTROL-PROPERTY}
       [UPON CALL-NAME]
5.4.3.6.2 Syntax and Usage Rules

Refer to the "NetCOBOL Language Reference" for a complete list of rules for using the DISPLAY statement.

5.4.3.6.3 Example

Display the image name of image control (CmImage1) on the console window.

DISPLAY "Current displayed image is "                     
        "ImageName" OF CmImage1.                          

5.4.3.7 EVALUATE Statement

You can use the properties of a control as selection criteria in the EVALUATE statement.

5.4.3.7.1 Syntax
  EVALUATE  CONTROL-PROPERTY
  WHEN      OBJECT-TO-SELECT
    ...
  WHEN      OBJECT-TO-SELECT
    ...
    :
END-EVALUATE
5.4.3.7.2 Syntax and Usage Rules

Refer to the "NetCOBOL Language Reference" for a complete list of rules for using the EVALUATE statement.

5.4.3.7.3 Example
EVALUATE  "Caption" OF COLOR-NAME                          
WHEN     "BLACK"                                          
    MOVE  "BLACK "        TO "Caption" OF COLOR-TEXT           
WHEN      "RED"                                           
    MOVE  "RED"           TO "Caption" OF COLOR-TEXT              
WHEN      "YELLOW"                                       
    MOVE  "YELLOW"        TO "Caption" OF COLOR-TEXT           
WHEN      OTHER                                           
    MOVE  "INVALID COLOR" TO "Caption" OF COLOR-NAME       
END-EVALUATE