#56990 - 05/02/19 03:22 PM
Re: need help with PressTalk case statement
[Re: Sami786]
|
OL Expert
Registered: 01/29/14
Posts: 400
Loc: Home
|
Jean, can you help me complete this please.
define(&arrAge,arrayinteger,[50,51,52,53,54,55,56,57,58,59]) &arrAge[0] := 50 &arrAge[1] := 51 &arrAge[2] := 52
define(&arrMaleBenefit,arraystring,[50,51,52,53,54,55,56,57,58,59]) &arrMaleBenegit[0] := '1200.50' &arrMaleBenefit[1] := '1150.20' &arrMaleBenefit[2] := '960.20'
define(&arrFemaleBenefit,arraystring,[50,51,52,53,54,55,56,57,58,59]) &arrFemaleBenegit[0] := '1100.50' &arrFemaleBenefit[1] := '1350.20' &arrFemaleBenefit[2] := '1960.20'
define (&Benefit1Year,integer,0) define(&i,integer,0) for(&i,1,1,1)
&Gender := @(105,1,1) if &Gender = 'M' &Benefit1Year := &arrMaleBenegit else
&Benefit1Year := &arrFemaleBenegit endif endfor
_________________________
Peace
|
Top
|
|
|
|
#56991 - 05/02/19 03:40 PM
Re: need help with PressTalk case statement
[Re: Sami786]
|
OL Toddler
Registered: 04/18/18
Posts: 50
|
Hi, In your age array, you already defined the ages as you declare the array, so no need to put values again in each slot afterwards. In your benefit arrays, instead of declaring them with the age at each position then overwriting them with the amounts, you should declare them with the amounts from the start define(&arrMaleBenefit,arraystring,['1200.50','1150.20',...,...,...]) then in your for loop you will want to iterate more than once I'm assuming, and call the array with the index:counter-1 &Benefit1Year := &arrMaleBenegit[&i-1] Also fix the Benegit typo in your array names
|
Top
|
|
|
|
#56992 - 05/02/19 03:52 PM
Re: need help with PressTalk case statement
[Re: Sami786]
|
OL Expert
Registered: 01/29/14
Posts: 400
Loc: Home
|
Jouberto, thank you for your help, it's my first time using arrays and I need further help please if you can.
This is what I got and it's not correct.
...
define(&arrAge,arrayinteger,[50,51,52,53,54,55,56,57,58,59]) define(&arrMaleBenefit,arraystring,[1200.00,1150.20,960.20]) define(&arrFemaleBenefit,arraystring,[1100.50,1350.20,1960.20])
define (&Benefit1Year,integer,0) define(&i,integer,0)
for(&i,1,1,1)
&Gender := @(105,1,1)
if &Gender = 'M' &Benefit1Year := &arrMaleBenefit[&i-0] &Benefit1Year := &arrMaleBenefit[&i-1] &Benefit1Year := &arrMaleBenefit[&i-2] &Benefit1Year := &arrMaleBenefit[&i-3] else
&Benefit1Year := &arrFemaleBenefit[&i-0] &Benefit1Year := &arrFemaleBenefit[&i-1] &Benefit1Year := &arrFemaleBenefit[&i-2] &Benefit1Year := &arrFemaleBenefit[&i-3] endif endfor
_________________________
Peace
|
Top
|
|
|
|
#56993 - 05/02/19 03:58 PM
Re: need help with PressTalk case statement
[Re: Sami786]
|
OL Toddler
Registered: 04/18/18
Posts: 50
|
Many things can be wrong about what you have there. Please define "not correct".
For one thing, you are passing float values to an array of strings. Make sure to pass strings ('123.45'). Your for loop will run only once, change its parameters. Your IF statements needs the evaluation to be between parentheses. Your referenced array indexes should only read [&i-1]. The for loop will take care of changing the results. You are overwriting many times the benefit1year variable. Only assign it once in each portion of the IF statement.
I feel you should definitely open a support ticket so we can understand what you are dealing with, and what you are expecting out of it.
Thanks.
|
Top
|
|
|
|
#56994 - 05/02/19 05:12 PM
Re: need help with PressTalk case statement
[Re: Sami786]
|
OL Expert
Registered: 01/29/14
Posts: 400
Loc: Home
|
as you mentioned there might be allot of things incorrect which I don't know yet, and I'm learning! thanks to you. If I'm not very far away then I think it would be very nice of you to help me now else I have to contact support. This way I learned solid define(&arrAge,arrayinteger,[50,51,52,53,54,55,56,57,58,59]) define(&arrMaleBenefit,strtofloat,[1200.00,1150.20,960.20]) define(&arrFemaleBenefit,strtofloat,[1100.50,1350.20,1960.20]) define (&Benefit1Year,integer,0) define(&i,integer,0) for(&i,1,1,20) &Gender := @(105,1,1) if (&Gender = 'M') &Benefit1Year := &arrMaleBenefit[&i-1] else &Benefit1Year := &arrFemaleBenefit[&i-1] endif endfor
Edited by Sami786 (05/02/19 05:13 PM)
_________________________
Peace
|
Top
|
|
|
|
#56995 - 05/02/19 06:10 PM
Re: need help with PressTalk case statement
[Re: Sami786]
|
OL Expert
Registered: 10/03/16
Posts: 681
Loc: Québec, Canada
|
There is a notion that seems to elude you. The idea of using 3 arrays as to get a reference benefit amount based on the age requires that they have the same number of element. Right now, your: - &arrAge has 10 elements.
- &arrMaleBenefit has 3 elements
- &arrFemaleBenefit has 3 elements
In order for this to work in a loop instead of a lot of nested if/elseif/else, you need to have the same amount of elements in each array. Once you have found the correct age from your &arrAge, you look in the corresponding gender array of benefit and grab the value that is at the same index(&i). If multiple age have the same benefit amount, simply repeat the amount multiple time in the gender arrays. BTW, strtofloat is not a type for array but a conversion function that takes a string and convert into a type float.
_________________________
♪♫♪♫ 99 frigging bugs in my code 99 frigging bugs Take one down Code around 127 frigging bugs in my code ♪♫♪♫
|
Top
|
|
|
|
#56999 - 05/06/19 04:04 PM
Re: need help with PressTalk case statement
[Re: Sami786]
|
OL Expert
Registered: 01/29/14
Posts: 400
Loc: Home
|
Hi,
Can you help me further, I tried to make this as simple as possible so I understand then once it's working I can add all the other ages and values accordingly.
Below code gives errors, not liking the arrays! can you please test this with many thanks.
define(&arrAge,arrayinteger,[50,51,52]) define(&arrMale,arraystring,['150','151','152']) define(&arrFemale,arraystring,['250','251','252'])
define(&Total,integer,0) define(&i,integer,0) define(&Gender,string,'0')
for(&i,1,1,3)
&Gender := 'M'
if(&Gender = 'M') &Total := &arrMale[&i-1] else &Total := &arrFemale[&i-1]
endif endfor
_________________________
Peace
|
Top
|
|
|
|
#57005 - 05/07/19 01:28 PM
Re: need help with PressTalk case statement
[Re: Sami786]
|
OL Expert
Registered: 10/03/16
Posts: 681
Loc: Québec, Canada
|
More something like this:
define(&myAge,integer,52)
define(&myIndex,integer,0)
define(&arrAge,arrayinteger,[50,51,52])
define(&arrMale,arraystring,['150','151','152'])
define(&arrFemale,arraystring,['250','251','252'])
define(&Total,string,'0')
define(&i,integer,0)
define(&Gender,string,'0')
for(&i,0,1,2)
if(&arrAge[&i] = &myAge)
&myIndex := &i
endif()
endfor()
&Gender := 'M'
if(&Gender = 'M')
&Total := &arrMale[&myIndex]
else
&Total := &arrFemale[&myIndex]
endif()
show(&Total)
This would show 152
_________________________
♪♫♪♫ 99 frigging bugs in my code 99 frigging bugs Take one down Code around 127 frigging bugs in my code ♪♫♪♫
|
Top
|
|
|
|
#57006 - 05/07/19 04:01 PM
Re: need help with PressTalk case statement
[Re: Sami786]
|
OL Expert
Registered: 01/29/14
Posts: 400
Loc: Home
|
Thank you so much for the script Jean, I'll try this now.
THANKS
_________________________
Peace
|
Top
|
|
|
|
#57008 - 05/08/19 05:22 PM
Re: need help with PressTalk case statement
[Re: Sami786]
|
OL Expert
Registered: 01/29/14
Posts: 400
Loc: Home
|
Hi Jean, Now I'm getting my results thanks to you. I need to do some math and I need your help again with many thanks. for example: Benefit := (age * &TotalValue div (1000)) define(&myAge,integer,0) set(&myAge,strtoint(@(1,1,2))) define(&myIndex,integer,0) define(&Benefit,integer,0) define(&arrAge,arrayinteger,[50,51,52]) define(&arrFirstYearMale,arraystring,['63','67','71']) define(&arrFirstYearFemale,arraystring,['39','42','44']) define(&Total,string,'0') define(&TotalValue,string,'0') define(&i,integer,0) define(&Gender,string,'0') for(&i,0,1,2) if(&arrAge[&i] = &myAge) &myIndex := &i endif() endfor() %&Gender := 'F' &Gender := @(2,1,1) if(&Gender = 'M') &TotalValue := &arrFirstYearMale[&myIndex] else &TotalValue := &arrFirstYearFemale[&myIndex] endif() &Benefit := (inttostr(mul(&TotalValue,&myAge )div(1000))) %show(&Benefit)
Edited by Sami786 (05/08/19 05:26 PM)
_________________________
Peace
|
Top
|
|
|
|
|
|