Solved

Viewing Results from Function

Posted on 1997-06-06
9
185 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
  • 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

830 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