Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Delphi: Search Method -- Memo.Lines to Binary Record file

Posted on 2007-04-07
5
Medium Priority
?
1,669 Views
Last Modified: 2013-11-23
Hi everyone, you'll excuse my poor programming skills but i plane to import some computernames and there server names into my binary file already created.
If computer name already exists in the binary record, then it pops up something. Else, it Add's it to the Binary file with it's appropriate server.

I wanted (or open to  use something else than a Memo Text box)  to use Memo text to copy/paste my text file, then execute the Search routine but my code is so poor that i came here :)
Exemple of Data i want to import into my Record file:
WW0003DD000  SRV001DT003
WW0003DD002  ORI001DT022
WW0003DD003  FFF001DT013

Idea of the Code...
type Elements =record
                PC_Name,Local_SRV,Print_SRV:string[15];
               end;

var
  DBase : Elements;
  f : file of Elements;
  FileName:string;
  t:integer;

procedure TForm4.Button1Click(Sender: TObject);
var i,n:integer;
begin
 assignfile(f,FileName);
 {$i-}reset(f);{$i+}
 i:=0;
 n:=0;
 for n:=0 to memo1.Lines.count -1 do
  Begin
    with Dbase do
      Begin
       seek(f,0);
       read(f,Dbase);
       While not eof(f) do
         Begin
          Repeat
            seek(f,i);
            read(f,Dbase);
            showmessage(Memo1.Lines[n] +' PC not Found!! !');
            i:=i+1;
          until ( memo1.Lines[n] = PC_Name );

          Begin
           showmessage('PC Found ' +Memo1.Lines[n]+'....'+inttostr(n));
           i:=0;
           seek(f,i);
           read(f,Dbase);
          end;
         end;
      end;
   end;
       showmessage('Exit of the file');
      exit;
end;

If you guys got any other search method it yould be so much apreciated.   Thank you.
0
Comment
Question by:mediteranio
[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
  • 2
5 Comments
 
LVL 11

Accepted Solution

by:
calinutz earned 1000 total points
ID: 18870386
Why don't you use an xml file to store your data in it?
It's easyer to work with... plain database use.

Use ClientDataset to store and retrieve data from your records.

Tutorial for using Client DataSet can be found here:
http://delphi.about.com/od/usedbvcl/a/tclientdataset.htm

It's a better way to do it

Regards
0
 

Author Comment

by:mediteranio
ID: 18870547
You are right Calinutz. I'm checking this. It's all new for me :)

Thank you.
0
 

Author Comment

by:mediteranio
ID: 18921385
I did a small program who creates an XML TDocument file. Creating a file with some data i have no trouble.  But when i want to import Data from my XML, i'm having some hard time.  You guys know how to get data from an XMl file?  Please i need some help!! :)

Here's an example of my newbie code:

[code]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, xmldom, XMLIntf, StdCtrls, msxmldom, XMLDoc, stages;


type
  TForm1 = class(TForm)
    XMLDoc: TXMLDocument;
    BtnCreation: TButton;
    Memo1: TMemo;
    Memo2: TMemo;
    Button1: TButton;
    procedure BtnCreationClick(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.BtnCreationClick(Sender: TObject);
var
  stage,stagiaires,stagiaire : IXMLNode;  //Noeuds de référence

begin
  memo1.Clear;
  XMLDoc.DocumentElement := XMLDoc.CreateElement('stages','');

  stage := XMLDoc.DocumentElement.AddChild('stage');

  stage.Attributes['nom'] := 'WORD 2000 Initiation';
  stage.Attributes['date'] := '14/06/2001';

  stagiaires := stage.AddChild('stagiaires');

  stagiaire := stagiaires.AddChild('stagiaire');
  stagiaire.Attributes['nom'] := 'MAGIC Jordan';
  stagiaire.Attributes['age'] := '35';

  stagiaire := stagiaires.AddChild('stagiaire');
  stagiaire.Attributes['nom'] := 'ESSONCHA Jean-Roland';
  stagiaire.Attributes['age'] := '38';


  stage := XMLDoc.DocumentElement.AddChild('stage');
  stage.Attributes['nom'] := 'SQL SERVER 7 Administration';
  stage.Attributes['date'] := '11/06/2001';

  memo1.Lines.Assign(XMLDoc.XML);
  XMLDoc.SaveToFile('stages.xml');

  end;


procedure TForm1.Button1Click(Sender: TObject);
var
  Element : IXMLStagesType;
  i: integer;
begin
  Element := GetStages(XMLDoc);
  for i := 0 to Element.stages.Count - 1
    do memo2.Lines.Add(Element.stagiaires[i].nom);
end;
end.
[/code]

I get errors while compiling
  [Error] Unit1.pas(79): Undeclared identifier: 'stages'
  [Fatal Error] Project1.dpr(6): Could not compile used unit 'Unit1.pas'

Thank you for any help.
0
 
LVL 1

Expert Comment

by:Computer101
ID: 21156543
Forced accept.

Computer101
EE Admin
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

688 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