on 09-09-2010 7:53 PM
Can anyone suggest why i never get to the Else statement ?
There are many {SRMARRAY.LASTDISCOVERYTIME} that do contain a date and time.
{
stringvar notdiscovered;
stringvar discovered := "discovered ok";
numbervar countofnullarrays;
if isnull({SRMARRAY.LASTDISCOVERYTIME})
Then (countofnullarrays := countofnullarrays+1;
notdiscovered :="NOT DISCOVERED")
Else
discovered :="discovered ok";
}
John: I just ran your code in CR XI R2, with the comment marks, and it worked fine. It only worked with parentheses, not braces, however.
I don't think you ever said what version and platform you were using.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I haven't looked at the code too closely, but a "//" would only mess you up if you were writing in Basic syntax, not Crystal.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi John,
Date and DateTime fields are never NULL in Crystal. A Null date would be Date (0, 0, 0).
{
stringvar notdiscovered;
stringvar discovered := "discovered ok";
numbervar countofnullarrays;
if {SRMARRAY.LASTDISCOVERYTIME} = CDateTime (0, 0, 0)
Then (countofnullarrays := countofnullarrays+1;
notdiscovered :="NOT DISCOVERED")
Else
discovered :="discovered ok";
}
Good luck,
Brian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
All, thanks for the suggestions.
I want to bump a count "countofnullarrays" for later use and the output from the if then else has to be a stringvar to contain "discovered" or "not discovered"
The field srmarray.lastdiscovewrytime is null if there is not a date/time if i add this simple
formaula to my report, it does display that the field contained a null/not null value
{
if isnull({SRMARRAY.LASTDISCOVERYTIME})
then "null"
else "not null"
}
this produces :-
CK200070700577_NCR null
CK200070700577_TSSNCR null
CK200070800687 null
CK200073300421 null
PHX_T3_0340 (NS960_0340) null
PHX_T1_0512 9/10/2010 1:15:53 PM not null
PHX_T1_0515 9/10/2010 1:15:43 PM not null
PHX_T1_4277 9/10/2010 1:15:37 PM not null
PHX_T1_0343 9/10/2010 1:15:28 PM not null
So why is why if then else not working ?
{
stringvar notdiscovered;
stringvar discovered;
numbervar countofnullarrays;
if isnull({SRMARRAY.LASTDISCOVERYTIME})
Then (countofnullarrays := countofnullarrays+1;
notdiscovered :="NOT DISCOVERED")
Else
discovered :="discovered ok";
}
Everyone, the problem is casused by a "//" comment in my code which i had removed before pasting to this forum:
{
stringvar notdiscovered;
stringvar discovered;
numbervar countofnullarrays;
if isnull({SRMARRAY.LASTDISCOVERYTIME})
//then display "not discovered"
Then (countofnullarrays := countofnullarrays+1;
notdiscovered :="NOT DISCOVERED")
Else
//then display"discovered ok"
discovered :="discovered ok";
}
if i remove the "//" comments the code works correctly.
I would suggest this is a bug ??? comments
Don't think you can have two declarations in the then
(
stringvar notdiscovered;
stringvar discovered := "discovered ok";
numbervar countofnullarrays;
if isnull({SRMARRAY.LASTDISCOVERYTIME})
Then notdiscovered :="NOT DISCOVERED"
Else
discovered :="discovered ok";
);
countofnullarrays := countofnullarrays+1;
Ian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You bet you can get multiple statements between a single combination of "then" and "else".
You just have to place them between parenthesis "()". Actually, just like he's doing...
John, are you sure that {SRMARRAY.LASTDISCOVERYTIME} does contain null-values when it has never been discovered?
Couldn't it contain just zeros?
Edited by: D. van Gerwen on Sep 10, 2010 3:16 PM
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.