Solved

Viewing Results from Function

Posted on 1997-06-06
9
174 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PDF library for Delphi 2 107
Delphi XE2 application frozen on Windows 10 10 278
find a node in VST 2 64
HTML text in the body of an email (delphi code) 12 98
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now