Normal Topic Problem to destinguish between "" and 0 (zero) (Read 14591 times)
wattsup
Member
*
Offline



Posts: 7
Joined: Mar 16th, 2020
Problem to destinguish between "" and 0 (zero)
Sep 27th, 2020 at 2:01pm
Print Post Print Post  
Hi there Sesame pro's.

I have a small issue with a water analysis results form in am polishing up.

On the form there are several elements such as Color, Iron, Manganese, Hardness with number fields to the right of each parameter in which you enter the analysis results that all have to be between certain values in order to be marked either Good or Bad in the status text fields to the right of the number fields. I also want to clear the status field if the number field is left empty.

Example: Color has to be between 0 and 15.

/* Enter Color analysis value into R01 number field
/* Status shows up in status R011 text field

IF R01 >= 0 AND R01 <= 15
     {
     R011 = "Good"   
     }      
ELSE IF R01 > 15
     {
     R011 = "Bad"
     }      
IF R01 = ""
       {
       CLEAR(R011)      
       }

The problem with this is when we enter 0 (zero) in the number field it will not enter Good in the status field but just clears the field as if the field was empty so I gather that Sesame treats 0 (zero) and "" as identical. The problem is we often have a result of 0 in the results and status should say Good. I tried for a day to play around treating the number field as text and other functions but no luck.
Such a simple function is turning out to be a brain twister.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Problem to destinguish between "" and 0 (zero)
Reply #1 - Sep 28th, 2020 at 1:25pm
Print Post Print Post  
Hello,

You will want to use @IsBlank() to determine if the element is actually blank.

Code
Select All
IF R01 >= 0 AND R01 <= 15
{
     R011 = "Good"
}
ELSE IF R01 > 15
{
     R011 = "Bad"
}
Else IF @IsBlank(R01)
{
       CLEAR(R011)
} 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
wattsup
Member
*
Offline



Posts: 7
Joined: Mar 16th, 2020
Re: Problem to destinguish between "" and 0 (zero)
Reply #2 - Oct 4th, 2020 at 12:47pm
Print Post Print Post  
Hi Ray and thank you for your reply.

Sorry for my delay. Unfortunately this is not working.

The result field can have four possible entries where the status field then shows if the input is Good or Bad or Blank.

If R01 gets                                 R011 should show
1 to 15                                       Good
16 and up                                  Bad
Blank                                         Blank
0                                               Good

The problem is even if you use @Isblank or If R01 = "", both of these see the 0 entry as a Blank entry but the zero is not blank, it's 0 and needs to be seen as Good for the sake of a water analysis, like having 0 Iron is Good, not blank.

Maybe Sesame would need a new command like @Zero where it is treated like a real piece of information and not just equal to a blank condition, but there has to be millions of databases out there dealing with zero as a tangible value (Good) and where a blank entry produces a blank status (no value).

Leon
  
Back to top
 
IP Logged
 
wattsup
Member
*
Offline



Posts: 7
Joined: Mar 16th, 2020
Re: Problem to destinguish between "" and 0 (zero)
Reply #3 - Oct 4th, 2020 at 1:02pm
Print Post Print Post  
While I was posting the last post I was trying a few things like taking the 0 and putting it in a calculation that if 0 is entered it will always equal 1 and not blank.
I also took out the = sign for 0 on the first line IF R01 >= 0 AND R01 <= 15 to force it to look at the third condition on its own.

It seems to work now with all these variable producing the right status value.

VAR BAG AS INT
BAG=1

IF R01 > 0 AND R01 <= 15
           {
           R011 = "Good"   
                }      
IF R01 > 15
           {
           R011 = "Bad"
           }      
IF (BAG+R01=1)
           {
           R011 = "Good"
           }      
IF @ISBLANK (R01)
           {
           CLEAR(R011)      
           }

Leon
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Problem to destinguish between "" and 0 (zero)
Reply #4 - Oct 5th, 2020 at 1:46pm
Print Post Print Post  
Hi Leon,

I apologize that's what I get being in a rush. Yes the issue was the >= in the first If statement. Another way to write it would be

Code
Select All
IF @IsBlank(R01)
{
       CLEAR(R011)
}
Else IF R01 >= 0 AND R01 <= 15
{
     R011 = "Good"
}
ELSE IF R01 > 15
{
     R011 = "Bad"
} 



The reason why this is happening is because when you are comparing a numerical element value in code to a number there is no such thing as a blank number. So a blank element is 0 in terms of programming. So in the code above, you handle a blank first and then handle all actual numbers later including an actual 0.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged