Company InformationOur COBOL SolutionsCOBOL Services and TrainingSupport for our CustomersAcucorp and COBOL EventsAcucorp's Partners


















< previous      next > Print this page  

Trailing Spaces in Entry Fields / NOTIFY-CHANGE.

January 10, 1997
Author: Drake Coker
Date: 1/97
Category:  
Keywords: spaces, operators, entry fields, NOTIFY-CHANGE
Summary: This describes the way in which the 3.0 runtime handles spaces in entry-field VALUE data items.

This describes the way in which the 3.0 runtime handles spaces in entry-field VALUE data items.

In COBOL, it is common for alphanumeric data items to contain trailing spaces. The COBOL language generally ignores trailing spaces when comparing two data items or performing other operations.

In Windows' internal operations, trailing spaces are significant. For example, "abc" and "abc " are considered different values.

In order to handle these different philosophies, the runtime converts between COBOL format and Windows format as needed. In particular, when assigning an entry-field's VALUE, the runtime first removes any trailing spaces. When retrieving a VALUE from an entry-field, the runtime pads out the value with spaces to fill the receiving COBOL data item.

The removal of trailing spaces is important for two reasons:

a. If they were not removed, then the normal selection highlight that most entry-field's start with would highlight the entire field instead of just the non-space text in the field. This looks odd under Windows.
b. The field would start out "full", and Windows would reject any attempt to add new data to the field.

The automatic trailing-space handling done by the runtime handles these issues nicely.

There is one case where the rule can present problems. If you use the NOTIFY-CHANGE entry-field style, then the entry-field terminates with each new character entered. If the COBOL code that follows then redisplays the field, it can prevent the entry of a space into the field.

Consider the following code fragments:

  screen section.
  ...
      03  field-1, entry-field, value data-1, 
          notify-change, exception procedure exc-1.

  procedure division.
  ...
  exc-1.
          display field-1.

The "exc-1" paragraph gets executed with each change to "field-1". When it gets executed, the runtime automatically places the current value of the entry-field in "data-1". In the process, the data is padded with spaces. The display statement in "exc-1" causes "field-1" to be updated. Usually this would not have any noticable effect since the data in "data-1" is the same as the entry-field's value. However, if the user enters a space, then problems arise. The value is first padded with spaces, then trailing spaces are removed when the update occurs. This presents a case where the updated value is different from the current value: the space has been removed. What the user sees is that he cannot enter a space.

When using the NOTIFY-CHANGE style, you should probably avoid doing a general DISPLAY of the affected entry-field if you are using the Screen Section. This is because the Screen Section DISPLAY will always try to update the field's value. Instead, you should use the MODIFY verb to change just those aspects of the field that you wish to change. This will leave the VALUE alone. Of course, if you want to change the VALUE, then you can use the DISPLAY verb.

####

Acucorp, extend and ACUCOBOL are trademarks or registered trademarks of Acucorp, Inc. All rights reserved. All other trademarks are the property of their respective owners.

 

 

Contact | Site Map | | Legal | Trademarks | Privacy | Print this page
Acucorp, Inc., 9920 Pacific Heights Blvd., San Diego, CA 92121, +1 858.795.1900
© 1999-2008, Acucorp, Inc. All rights reserved.


Get the most recent Code Updates
Download an Evaluation of ACUCOBOL- GT
View recorded Webinars and demos
Download the latest version of Acucorp News
Find out about the latest Training Opportunities
Language