IMPORTANT ANNOUNCEMENT

These forums were permanently set to read-only mode on July 20, 2022. From that day onwards, no new posting or comment is allowed on the site, but the historical content remains intact and searchable.

A new location for posting questions about PlanetPress Suite is now available:

OL Learn - PlanetPress Classic (opens in new tab)

Topic Options
#57059 - 05/21/19 05:00 PM if statment
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 400
Loc: Home
Hi, my if statement is not working, your help is appreciated!

if(&AAA >= &BBB) and (&CCC >= &DDD)

&result1 := inttostr(&EEE + 1)
else
&result1 := inttostr(&EEE)
endif()



I also tried below with no luck

if(and( if(&AAA > &BBB ,if(&CCC > &DDD))

&result1 := inttostr(&EEE + 1)
else
&result1 := inttostr(&EEE)


&Result2:= inttostr(&result1)
_________________________
Peace

Top
#57060 - 05/21/19 05:31 PM Re: if statment [Re: Sami786]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 681
Loc: Québec, Canada
try this:
Code:
if((&AAA >= &BBB) and (&CCC >= &DDD))
  &result1 := inttostr(&EEE + 1)
else
  &result1 := inttostr(&EEE)
endif()


If that doesn't work, what is the actual result VS the expected result?
Do you get an error message?
_________________________
♪♫♪♫
99 frigging bugs in my code
99 frigging bugs
Take one down
Code around
127 frigging bugs in my code
♪♫♪♫

Top
#57061 - 05/22/19 11:41 AM Re: if statment [Re: Sami786]
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 400
Loc: Home
there's no error but the result always goes to else and it's wrong.

DATE EXAMPLE:
16/04/1956
15/04/2024

I need to check DD and MM only not the YYYY.
In this case 16/04 is bigger then 15/04 the result should go to add one to the year. but it's not!

I'm comparing two dates, and when one is bigger then others I need to add 1 into the year. Is there any function written for this scenario to compare two dates? that's why I'm using if statement to find the result!
Please share your thoughts with many thanks.
_________________________
Peace

Top
#57062 - 05/22/19 11:43 AM Re: if statment [Re: Sami786]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 681
Loc: Québec, Canada
Did you used strtoint() function when setting up your month and day values into your variables? If not, you are comparing strings.
_________________________
♪♫♪♫
99 frigging bugs in my code
99 frigging bugs
Take one down
Code around
127 frigging bugs in my code
♪♫♪♫

Top
#57063 - 05/22/19 01:07 PM Re: if statment [Re: Sami786]
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 400
Loc: Home
strtoint() is used, code is attached.

%DOB
define(&dobYYYY,integer,0)
set(&dobYYYY,strtoint(@(6,7,10)))

define(&dobDD,integer,0)
set(&dobDD,strtoint(@(6,1,2)))

define(&dobMM,integer,0)
set(&dobMM,strtoint(@(6,4,5)))

%Effective DD,MM date
define(&EfectiveDD,integer,0)
set(&EfectiveDD,strtoint(@(7,1,2)))

define(&EfectiveMM,integer,0)
set(&EfectiveMM,strtoint(@(7,4,5)))

define(&ExpirYear,integer,0)
define(&ExpirYear1,integer,0)

%Find the expiration Year
define(&ExpirationYear,integer,0)
&ExpirationYear := &dobYYYY + 65 % this works fine

%find if DOB DD&MM is bigger then Effective DD&MM
if((&dobMM >= &EfectiveMM)and(&dobDD >= &EfectiveDD))
&ExpirationPlusOne := inttostr(&ExpirationYear + 1)
else
&ExpirationPlusOne := inttostr(&ExpirationYear)
endif()

&Expiration := inttostr(&ExpirationYear)

variable type is string for:
&Expiration
&ExpirationPlusOne


Edited by Sami786 (05/22/19 01:10 PM)
_________________________
Peace

Top
#57064 - 05/22/19 01:40 PM Re: if statment [Re: Sami786]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 681
Loc: Québec, Canada
I just tried your code, with the dates your provided, and it does go in the IF, not the else.

The 1 year is being added.

I added code to show on screen the result of %ExpirationPlusOne and the result is 2022.
_________________________
♪♫♪♫
99 frigging bugs in my code
99 frigging bugs
Take one down
Code around
127 frigging bugs in my code
♪♫♪♫

Top
#57065 - 05/22/19 02:22 PM Re: if statment [Re: Sami786]
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 400
Loc: Home
one the one record works! I tried below dates, non of them works.

18/07
29/04 does not works

12/06
13/07 does not work
_________________________
Peace

Top
#57066 - 05/22/19 02:41 PM Re: if statment [Re: Sami786]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 681
Loc: Québec, Canada
To help you properly we would need to see the Template and reproduce the issue. I suggest you open a technical support call at 1-866-348-5863 or through our website.
_________________________
♪♫♪♫
99 frigging bugs in my code
99 frigging bugs
Take one down
Code around
127 frigging bugs in my code
♪♫♪♫

Top
#57067 - 05/23/19 10:52 AM Re: if statment [Re: Sami786]
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 400
Loc: Home
once again, the syntax is working but the result is wrong and it's tricky one!

here is the problem! if statement only works in this situation when both brackets meet the condition,else it will be false! example:

this works because 16 > 15 and 4 is >= 4
16/04/1956
15/04/2024
answer is 2022

this will not work because 18 is < 29
18/07/1963
29/04/2019
answer should be 2029 but it's not!

How do I go about this tricky situation?


Edited by Sami786 (05/23/19 10:55 AM)
_________________________
Peace

Top
#57068 - 05/24/19 09:53 AM Re: if statment [Re: Sami786]
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 400
Loc: Home
This issue is resolved , thank you
_________________________
Peace

Top