Solved

Viewing Results from Function

Posted on 1997-06-06
9
169 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 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

14 Experts available now in Live!

Get 1:1 Help Now