473,387 Members | 1,592 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.

Calling functions in c++

1
Hi,
i have a defined function, but when i run my program jumps the function without reading it. Here is how my code look like:
Expand|Select|Wrap|Line Numbers
  1.         void processComboItem(); declaring the function
  2.  void TPosGetPaymentMethodForm::processComboItem()//details of the function
  3. {
  4.         int key = PosMainForm->PosTrnObj->PayKey;
  5.  
  6.         long double         FITotal = PosMainForm->PosTrnObj->FinalInvoiceTotal;
  7.         long double         FIDue = PosMainForm->PosTrnObj->FinalInvoiceDue ;
  8.         long double         FIVat = PosMainForm->PosTrnObj->FinalInvoiceVat;
  9.         long double         FIDiscount = PosMainForm->PosTrnObj->FinalInvoiceDiscount ;
  10.         double total = 0;
  11.  
  12.         AnsiString StockCode = "";
  13.         AnsiString Slipnumber = PosMainForm->PosTrnObj->SlipNumber;
  14.         double value = 0;
  15.         PosDataForm->SelectQuery->Close();
  16.         PosDataForm->SelectQuery->CommandText = "SELECT StockCode,Value,Quantity FROM POS_Transactions WHERE Slip = '" + AnsiReplaceStr( Slipnumber, "'", "`" ) + "' and Type = '02'";
  17.         PosDataForm->SelectQuery->Open();
  18.         if (PosDataForm->SelectQuery->RecordCount > 0)
  19.         {
  20.               StockCode = AnsiString(PosDataForm->SelectQuery->FieldValues["StockCode"]);
  21.               value = double(PosDataForm->SelectQuery->FieldValues["Value"]);
  22.               PosDataForm->SelectQuery->Close();
  23.               PosDataForm->SelectQuery->CommandText = "SELECT IngredientID, Quantity FROM RECIPES WHERE KitchenItemID = '" + AnsiReplaceStr( StockCode.Trim(), "'", "`" ) + "'";
  24.               PosDataForm->SelectQuery->Open();
  25.  
  26.               if (PosDataForm->SelectQuery->RecordCount > 0)
  27.               {
  28.  
  29.                 while(!PosDataForm->SelectQuery->Eof)
  30.                 {
  31.                     PosMainForm->PosTrnObj->Search(AnsiString(PosDataForm->SelectQuery->FieldValues["IngredientID"]),"POSTerminal" );
  32.                     PosDataForm->SelectQueryCents->Close();
  33.                     PosDataForm->SelectQueryCents->CommandText = "SELECT Value FROM POS_Transactions WHERE Slip = '" + AnsiReplaceStr( Slipnumber, "'", "`" ) + "' and StockCode = '"+AnsiString(PosDataForm->SelectQuery->FieldValues["IngredientID"])+"'";
  34.                     PosDataForm->SelectQueryCents->Open();
  35.  
  36.                     if (PosDataForm->SelectQueryCents->RecordCount > 0)
  37.                     {
  38.                           total += double(PosDataForm->SelectQueryCents->FieldValues["Value"]);
  39.                     }
  40.  
  41.                     PosDataForm->SelectQuery->Next();
  42.                 }
  43.               }
  44.  
  45.               total = value - total;
  46.               PosDataForm->UpdateCommand->CommandText = "UPDATE POS_Transactions SET Value = "+AnsiString(total)+", Total = "+AnsiString(total)+" WHERE  Slip = '" + AnsiReplaceStr( Slipnumber, "'", "`" ) + "' and StockCode = '"+ StockCode +"'";
  47.               PosDataForm->UpdateCommand->Execute();
  48.         }
  49.         //restore values
  50.         PosMainForm->PosTrnObj->FinalInvoiceTotal = FITotal;
  51.         PosMainForm->PosTrnObj->FinalInvoiceDue = FIDue;
  52.         PosMainForm->PosTrnObj->FinalInvoiceVat=FIVat;
  53.         PosMainForm->PosTrnObj->FinalInvoiceDiscount=FIDiscount;
  54.         PosMainForm->PosTrnObj->PayKey = key;
  55.  
  56.  
  57. //calling the function
  58. void __fastcall TPosGetPaymentMethodForm::Button19Click(TObject *Sender)
  59. {
  60.         processComboItem();
  61.         PosPaymentReceivedKeyPress(this, 'n');
  62. }
when i run my application it doesn't go through the calling it skips that part.
can anyone help?
Feb 20 '12 #1
1 2366
weaknessforcats
9,208 Expert Mod 8TB
Have you walked this code through your debugger?

Are you even calling this function:
Expand|Select|Wrap|Line Numbers
  1. void __fastcall TPosGetPaymentMethodForm::Button19Click(TObject *Sender)
  2.  {
  3.  
?
BTW: TPosGetPaymentMethodForm::Button19Click does not use its argument.
Feb 20 '12 #2

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

Similar topics

1
by: J.P. | last post by:
Hi, I found a function with the following header: function checkLogin($username = '',$password = '',$groupid = 10,$goodRedirect = '',$badRedirect = '') Now the writer of this function is...
3
by: Charles Larry | last post by:
Is there a way to define functions after the main part of a Python script? Example: #!/usr/local/bin/python # this code yields a NameError print_message("hello world")
18
by: bart_nessux | last post by:
I need a script to call several functions at the same time. How does one call more than one function simultaneously?
1
by: Ben | last post by:
I am having trouble calling functions in another file.. Lets look at the scenario below: File xyz.cc: (I have both xyz.h and xyz.cc, for simplicity I've avoided xyz.h) ------------ struct xyz...
5
by: Andrew Slade | last post by:
Hello, I am making calls from one compilation unit to functions in another by pointers and I get the warnings below from gcc on 2.4.x Debian Linux. The executable seems to work fine but the...
5
by: Dave | last post by:
does calling a regular function cost any cpu time? In other words, is it faster to write the code of two functions into main(), or is it the exact same thing as calling two functions. I know its...
7
by: Kenneth Brody | last post by:
The recent thread on "query about main()" got me thinking... As I recall, calling a function with the wrong parameters causes undefined behavior. (These all assume that no prototype of foo()...
2
by: =?Utf-8?B?SnVsaWFu?= | last post by:
My first problem is: I am having an issue when using a web service. The web service is written by another department and say its running fine but when I call it, I sometimes I get a...
12
by: bgold | last post by:
Hey. I have a base class (SPRITE), and using this base class I have derived a large number of derived classes (PERSON, BULLET, MISSILE, etc.). Now, at a certain point in my program, I have a pair...
7
mreeves000
by: mreeves000 | last post by:
Greetings, Ok so, what I am trying to do is have one file that stores several functions so I can use them across the entire site. So first I have the page, in every page I call header.php, and...
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: 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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.