Re: Bug using 'now' as variable name in 4GL
Posted in 1993
>From: uunet!coral.cs.jcu.edu.au!stuart (Stuart Kemp)
>Subject: Bug using 'now' as variable name in 4GL
>Date: 4 Aug 93 01:16:30 GMT
>To: informix-list@rmy.emory.edu
>X-Informix-List-Id: <news.3970>
>
>Using 4GL 4.10.UE2 on SCO 3.2.4
>I tried using a variable called 'now' in a 4GL program ... core-dump city!
>The word 'now' is in the list of reserved words ... anyone know what is it
>for, or what it does? Either of the following will dump core when run:
>
>define d date
>main
> let d = now
>end main
>-----------
>main
> call bug(today)
>end main
>
>function bug(now)
> define now date,
> y integer
> let y = year(now)
>end function
I don't remember seeing any replies to this query, and I'm cleaning
out my mail file. Looking at the source code, the intended answer
seems to be that in an SQL form, I4GL form, an ACE report or an I4GL
report function, you should be able to use NOW as a synonym for
CURRENT. However, ACE does not recognise the column "now" when it is
run, the I4GL report does not produce anything visible, but the SQL
form does work correctly. I didn't test the I4GL form. I don't think
the examples above should dump core. It's a moot point whether the second
one should compile or not -- the function bug has both an intrinsic
function and a variable with the same name visible; you couldn't do that
with C.
I used the following examples and 4.11 compilers (sformbld, saceprep,
form4gl, fglpc):
# SQL form
database displayonly
screen
{
[f000 ]
}
end
attributes
f000 = displayonly allowing input type datetime year to second, default = now;
end
# 4GL form
database formonly
screen
{
[f000 ]
}
end
attributes
f000 = formonly.dtcolumn type datetime year to second, default = now;
end
# ACE report
database svs end
select * from systables endformat
on every row print now
end
# I4GL report
main
start report r
output to report r(1)
finish report r
end main
report r(i)
define i integer
format
on every row print now
end report
I didn't know any of this before I went investigating. I live and learn.
Yours,
Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>