Normal Topic Programing-how to return a value of 0 (Read 1701 times)
Ron D
Member
*
Offline



Posts: 3
Joined: Jan 7th, 2011
Programing-how to return a value of 0
Jan 7th, 2011 at 3:11pm
Print Post Print Post  
I'm having trouble adding a string to this program spec.

<#20: IF #5="S" THEN #21=(#20-(#6*50.96-51)*0.15    ELCE #21=#20-(#6*50.96)-124)*0.15

In the second string starting with ELCE some times the returned value will show a negative value.  I want to add a statement that if the value is <1 it will return a value of 0.

Been working on this for two days now!  Just can't get it right.  Any help would be great.  Need this fix by 1/8/2011

Thank you!
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Programing-how to return a value of 0
Reply #1 - Jan 7th, 2011 at 3:21pm
Print Post Print Post  
Hi Ron,

Sesame does not program with field numbers like the statement you show. Is this question about something you are trying to do in Q&A?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Ron D
Member
*
Offline



Posts: 3
Joined: Jan 7th, 2011
Re: Programing-how to return a value of 0
Reply #2 - Jan 7th, 2011 at 3:38pm
Print Post Print Post  
Yep, I know that.  I want to get it correct and try it befor I transfer this db over to Sesame.

<#21: IF #5="S" THEN #21=(#20-(#6*50.96-51)*0.15    ELCE #21=#20-(#6*50.96)-124)*0.15

At the start I also had a typo.  <#20 Should be <#21

Q&A            Sesame

#20   =      GWages
#5     =      Status
#6     =      Dependents
#21   =      Federal


Thank you for the quick reply






  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Programing-how to return a value of 0
Reply #3 - Jan 7th, 2011 at 3:47pm
Print Post Print Post  
You also spelled ELSE incorrectly and your parentheses aren't in the right places. This will prevent Q&A from saving the program. I'm betting that you are getting the "Not a valid program spec" message, yes?

Try the code below. I fixed the errors and added the statement about converting a negative result to zero.
Code
Select All
<#21:
IF #5="S" THEN #21=#20-(#6*50.96-51)*0.15
ELSE #21=#20-(#6*50.96-124)*0.15;
If #21 < 0 THEN #21 = 0 


  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Ron D
Member
*
Offline



Posts: 3
Joined: Jan 7th, 2011
Re: Programing-how to return a value of 0
Reply #4 - Jan 7th, 2011 at 4:06pm
Print Post Print Post  
Hammer,   Thank you so much for the help and your quick reply.  It works great!   Sorry for the spelling errors I posted in the spec.
  
Back to top
 
IP Logged