473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem with Function Arguments

jenkinsloveschicken
I imagine this is a n00b mistake, but the problem I am having is that the first function(stratQual) is evaluating to "No" despite the argument being passed to it being greater than 80.00. The second function evalutes correctly. I have tried re-writing the first function as a switch case, but with the same results. I have also tried setting $stratQual = $faPercToGoal within the function and the function returns and displays the correct value for $faPercToGoal.

The syntax for the two appears identical, so I can't understand why they are not evaluating in the same manner. Can someone please shed some light on what I am doing wrong here?

Here is how I process each argument prior to sending to the function:
Expand|Select|Wrap|Line Numbers
  1. $faPercToGoal = number_format((($maxValFin/$faSValFin) * 100), 2);
  2. $stratQual = stratQual($faPercToGoal);
  3.  
  4. $qamPercGoal = number_format((($qamActTot/$qamGoalSum)*100), 2);
  5. $qamQual = qamQual($qamPercGoal);
  6.  
  7.  
  8. //Determine if agent strategic value percent/goal meets requirements
  9. function stratQual($faPercToGoal)
  10.     {
  11.     if ($faPercToGoal >= '80.00')
  12.         {
  13.         $stratQual = "Yes";
  14.         }
  15.         else
  16.         {
  17.         $stratQual = "No";
  18.         }
  19.     return $stratQual;
  20.     }
  21.  
  22.  
  23. //Determine if agent quality percent/goal meets requirements
  24. function qamQual($qamPercGoal)
  25.     {
  26.     if ($qamPercGoal >= '95.00')
  27.         {
  28.         $qamQual = "Yes";
  29.         }
  30.         else
  31.         {
  32.         $qamQual = "No";
  33.         }
  34.     return $qamQual;
  35.     }
  36.  
Oct 27 '07 #1
4 1345
ak1dnar
1,584 Expert 1GB
There is no issue with the functions. problem is with the calling parameters of the function. since you have used number_format() it will Format the number with grouped thousands.
Say you are passing like this :

Expand|Select|Wrap|Line Numbers
  1. $qamPercGoal = number_format((50*100), 2);
  2. echo $qamQual = qamQual($qamPercGoal); 
So the calling parameter now it's 5,000. So function is not evaluating correclty. You have to pass 5000 instead.

So remove those number_format from the calling parameters.

EDIT: I think so far you have used number which lesser than 1000 so number_format function sends the number as it is, in other words with out grouping to thosands.
Ex: number_format((5*100), 2); // 500
Oct 27 '07 #2
Worked like a charm! Thank you so much. I had a feeling it had to do with the $faPercToGoal value as it is frequently greater than 1,000.

Is there a different function I could use instead of number_format? I was trying to format the value for display in-page as well as send it to the appropriate function without creating two variables.

Again, thank you so much for the help!

-Jenkins
Oct 27 '07 #3
ak1dnar
1,584 Expert 1GB
Worked like a charm! Thank you so much. I had a feeling it had to do with the $faPercToGoal value as it is frequently greater than 1,000.

Again, thank you so much for the help!

-Jenkins
You are welcome. !

Is there a different function I could use instead of number_format? I was trying to format the value for display in-page as well as send it to the appropriate function without creating two variables.
I'm Sorry no idea about another function, that suits for both Formatting and Calculations. But by using Formatted Number you can't go for a calculation.
Oct 27 '07 #4
pbmods
5,821 Expert 4TB
Heya, Jenkins.

Why not just call stratQual() before you use number_format() and compare directly against the float value?
Oct 27 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Leslaw Bieniasz | last post by:
Cracow, 20.09.2004 Hello, I need to implement a library containing a hierarchy of classes together with some binary operations on objects. To fix attention, let me assume that it is a...
8
by: rdlebreton | last post by:
Hi, Folks! I've been trying to develop my own version of these draggable layers and I have been limiting myself to IE6...for now. I have looked at some other examples to get ideas of creating...
15
by: Hemant Shah | last post by:
Folks, We have an SQL statement that was coded in an application many years ago (starting with DB V2 I think). When I upgraded to UDB 8.2, the optimizer does not use optimal path to access the...
6
by: Edd Dawson | last post by:
Hi. I have a strange problem involving the passing of command line arguments to a C program I'm writing. I tried posting this in comp.programming yesterday but someone kindly suggested that I'd...
4
by: sods | last post by:
Hi, I write a test code about template used for strategy. it's very similar to sample code in TC++PL 13.4.1. #include <iostream> #include <string> using std::basic_string;
7
by: sfeher | last post by:
Hi All, Is there a way to preserve the arguments across functions? I have: <script> function myFirstFunction() { // arguments = 'param1'
3
by: Divick | last post by:
I was reading this section in Bruce Eckel's book which talks about passing and returning large objects ( Chapter 11: References & the Copy-Constructor ), where he explains that how to return big...
9
by: CryptiqueGuy | last post by:
Consider the variadic function with the following prototype: int foo(int num,...); Here 'num' specifies the number of arguments, and assume that all the arguments that should be passed to this...
0
by: mathewgk80 | last post by:
HI all, I am having popup calendar Javascript code. But i dont know how it is connecting to asp.net code.. I am using asp.net,c#.net and also using 3tier architecture with master page.... I...
1
by: Benke | last post by:
Hello, I'm quite new to Python and embedding python in c++. I'm trying to write a function that i can use to call a python function. It should take 3 arguments, the name of the python file, the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.