Solved

Viewing Results from Function

Posted on 1997-06-06
9
194 Views
Last Modified: 2011-10-03
I have a function that gets the current record# from a Paradox table, but I can't figure out how to 'kick the function off'.  I use this code to asssign the Function's result to a label;

label12.caption := 'Record ' + inttostr(result) + ' of ' + inttostr(table1.recordcount);

;but the function never starts, thus the result is always zero.

The function code is below. How do I get the result?
******************************************************************
 Function RecordNumber(Dataset: TDataset): Longint;
  var
    CursorProps: CurProps;
    RecordProps: RECProps;

  begin
  { Return 0 if dataset is not Paradox or dBASE }
    Result := 0;

    with Dataset do begin
      { Is the dataset active? }
      if State = dsInactive then
        showmessage('datasetclosed');

      Check(DbiGetCursorProps(Handle, CursorProps));
      UpdateCursorPos;

      { Fill RecordProps with the current record's properties }
      Check(DbiGetRecord(Handle, dbiNOLOCK, nil, @RecordProps));

      { What kind of dataset are we looking at? }
      case CursorProps.iSeqNums of
        0: Result := RecordProps.iPhyRecNum;  { dBASE   }
        1: Result := RecordProps.iSeqNum;     { Paradox }
      end; { case }
    end; { with }
  end; { function }
0
Comment
Question by:d4jaj1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 

Accepted Solution

by:
chrb earned 20 total points
ID: 1336847
It's simple, you call the result wich is only for the current procedure, do this instead :
label12.caption := 'Record ' + inttostr(RecordNumber(You must write a parameter her!)) + ' of ' + inttostr(table1.recordcount);

Hope it helps you :)
Just ask if you dosn't understand

Chr

0
 
LVL 3

Author Comment

by:d4jaj1
ID: 1336848
Hate to sound stupid but I'm very new to Delphi.   What parameter are you talking about?  If I put 'Result' there I get an error - "Incompatable types - TDataSet & Integer".  Please Help.
0
 

Expert Comment

by:chrb
ID: 1336849
You must send a TDataSet parameter, result is a integer as you see by the error message. Which controlles are you using?

Chr
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Author Comment

by:d4jaj1
ID: 1336850
Now I feel even worse, cause I don't know what you mean by controls.  I hope you mean either what components I'm using or what's in my USES section.  I'm using a Datasource, Table, and db{edit, Combo, Radio group).  My USES section is below.  Thanks you your quick response.

uses

  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Menus, Lines, StdCtrls, ExtCtrls, DB, DBTables, PxConst2, PxEd2, PxDBEd2,
  DBCtrls, Grids, DBGrids, PxValRt2, ComCtrls, Buttons, Mask, fxLoc, dbiprocs,
  dbitypes, dbierrs;
0
 

Expert Comment

by:chrb
ID: 1336851
Sorry, I ment component :)
0
 

Expert Comment

by:chrb
ID: 1336852
This shuld be the string :

label12.caption := 'Record ' + inttostr(RecordNumber([name of your Datasourcecomponent].dataset)) + ' of ' + inttostr(table1.recordcount);

Hope this should works :)

Chr
0
 
LVL 3

Author Comment

by:d4jaj1
ID: 1336853
Nope, Still doesn't work.  I get the error - "Ordnial Type Required".  DSRecipe is my DataSource for the Recipe Table.  Below is the code.  Do you know what this error means?


label12.caption := 'Record ' + inttostr(RecordNumber([DSRecipe].dataset)) + ' of ' + inttostr(tblRecipe.recordcount);
0
 

Expert Comment

by:chrb
ID: 1336854
Have you tried DSRecipe.dataset instead of [DSRecipe].dataset? If not try it :) If it dosn't works I will try to see in the help file :)

Now I hope it should works :)

Chr
0
 
LVL 3

Author Comment

by:d4jaj1
ID: 1336855
Great job!  I added that code to my dataset onChnage event and it gives me the current and total records.  Thanks.

By the way, I just unlocked another question, called Trapping Function Keys".  The guy who initially answered it never gave me any clarification.  Please answer it if you want.  Its worth fifty points.
0

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month6 days, left to enroll

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question