Page 1 of 3 1 2 3 >
Topic Options
#56973 - 04/30/19 12:16 PM need help with PressTalk case statement
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 324
Loc: Home
Hi, I need help with finding a value from a long list.

I think I need PPressTalk to use a "case" statement or equivalent method to find the answer rather then creating so many conditions!

The value can be found by checking the "age" and "gender"
For example


if ( age = 50 ) and (gender = M )
benefit = $2500
if ( age = 51 ) and (gender = F )
benefit = $3500
....
....
if ( age = 85 ) and (gender = M )
benefit = $1500

Can you help please.

THANKS
_________________________
Peace

Top
#56974 - 04/30/19 12:33 PM Re: need help with PressTalk case statement [Re: Sami786]
Jean-Cédric Online   content
OL Expert

Registered: 10/03/16
Posts: 481
Loc: Québec, Canada
Unfortunately, there is no "switch case" in PressTalk.

You could define arrays and scroll through them with a loop.

Here's my idea:

4 arrays:
  • arrMaleAge
  • arrMaleBenefit
  • arrFemaleAge
  • arrFemaleBenefit


Each arr<Male/Female>Age holds the ages you are concern with.
Each arr<Male/Female>Benefit holds the corresponding benefit.

Using a loop, scroll through the arr<Male/Female>Age, find the right age and get the benefit from the arr<Male/Female>Benefit which reside at the same index.

Hope that helps.

Top
#56975 - 04/30/19 02:46 PM Re: need help with PressTalk case statement [Re: Sami786]
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 324
Loc: Home
This making perfect since, but I'm not that advanced to write the code! if you can find an example on the forum please let me know.

THANKS
_________________________
Peace

Top
#56976 - 04/30/19 02:59 PM Re: need help with PressTalk case statement [Re: Sami786]
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 324
Loc: Home
I think you misunderstood me, let me refrain my question
I have value age
I have value gender

I need to look and match the age and gender to input the Benefit amount from a table I have.

if (&age = 50) AND (&gender = 'M')
&Benefit := '12,00.00'

I will have to hard code the Benefit amount from a table I have!
_________________________
Peace

Top
#56977 - 04/30/19 03:01 PM Re: need help with PressTalk case statement [Re: Sami786]
Jean-Cédric Online   content
OL Expert

Registered: 10/03/16
Posts: 481
Loc: Québec, Canada
You will have to hard code everything in the arrays...yes...

Top
#56978 - 04/30/19 05:49 PM Re: need help with PressTalk case statement [Re: Sami786]
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 324
Loc: Home
can you help me how to start the array then I'll finish it up
just need a jump start smile

THANKS
_________________________
Peace

Top
#56979 - 04/30/19 06:03 PM Re: need help with PressTalk case statement [Re: Sami786]
Jean-Cédric Online   content
OL Expert

Registered: 10/03/16
Posts: 481
Loc: Québec, Canada
Now that I think of it, you only need 3 arrays. 1 for the ages and 2 for the benefits (male and female)

What you'll find between < > is for you to set, without the < > of course.

Code:
define(&arrAge,arrayinteger,<number of age>)
&arrAge[0] := 40
&arrAge[1] := 41
&arrAge[2] := 42
...

define(&arrMaleBenefit,arraystring, <same number as $arrAge>)
&arrMaleBenegit[0] := '1200.50'
&arrMaleBenefit[1] := '1150.20'
&arrMaleBenefit[2] := '960.20'
...

define(&arrFemaleBenefit,arraystring, <same number as $arrAge>)
&arrFemaleBenegit[0] := '1100.50'
&arrFemaleBenefit[1] := '1350.20'
&arrFemaleBenefit[2] := '1960.20'
...

Top
#56981 - 05/02/19 11:20 AM Re: need help with PressTalk case statement [Re: Sami786]
Damita Offline
OL Newbie

Registered: 10/28/15
Posts: 7
Loc: Georgia
I am trying to write an IF statement that requires a string to be placed in a box within the document and I am having an issue doing this in PlanetPress 7...basically understanding how to do it.

Here is what I would like to write:

IF line 97 is X put in box 55 BUT if line 97 is EMPTY put an X in box 22
_________________________
Damita Knuckles

Top
#56982 - 05/02/19 11:21 AM Re: need help with PressTalk case statement [Re: Sami786]
Jean-Cédric Online   content
OL Expert

Registered: 10/03/16
Posts: 481
Loc: Québec, Canada
I Damita,

This should be asked in a new thread as to not confused other users when they read this post back.

Thanks.

Top
#56983 - 05/02/19 11:24 AM Re: need help with PressTalk case statement [Re: Jean-Cédric]
Damita Offline
OL Newbie

Registered: 10/28/15
Posts: 7
Loc: Georgia
Okay thank you Jean I will do that. I apologize.
_________________________
Damita Knuckles

Top
Page 1 of 3 1 2 3 >