3

Does anyone know why INTEGER(" ") is zero in Progress 4GL?
The result is same even if you pass empty string to INTEGER() function. What could be the theory around this? Please help

I have gone through the documentation but couldn't find anything about this.

Austin
  • 1,237
  • 1
  • 11
  • 22

3 Answers3

2

It's possible that the INTEGER() function does trimming of the input data.

This simple example shows signs of trimming:

DISPLAY INTEGER("1") = INTEGER("   1   ").

Displays yes

The spaces around the 1 is really not affecting the outcome of the conversion above leading me to think that INTEGER does trimming. Same result for:

DISPLAY INTEGER(" ") = INTEGER("").

I have no real idea as to why INTEGER("") returns 0 and not ? like for instance INTEGER("hello"). I guess it's just a matter of definition.

Jensd
  • 7,886
  • 2
  • 28
  • 37
1

"Why" is a religious question...

I believe that the 4GL is probably treating a blank string like it would an empty integer fill-in. (Keep in mind that " " is equal to "" in the 4gl.)

Try this:

define variable i as integer no-undo.

i = 2.

update i.

Type a space bar. Notice how the value goes to zero?

Tom Bascom
  • 13,405
  • 2
  • 27
  • 33
  • I think it's not religious but it's there for the blank when zero format which shows 0 as space. `def var i as int form "zzz". update i.` – carl verbiest May 14 '14 at 14:36
0

"" is a default value for character. If you define a char variable and do not specify INIT value, it will be "". 0 is a default value for integer. So INTEGER("") is very similar to integer with default initial value, which is 0.

Yuri Solodkin
  • 530
  • 8
  • 26