#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Location
    Scotland
    Posts
    16
    Rep Power
    0

    reading and writting to the same text file !!




    Hi

    I am trying to write 2 text files from 1 text file to populate a combobox and to then populate a edit box on change of the combo box anyway the problem I have is I cant seem to write to the combobox

    here is the code any help would be much apprexciated

    procedure TForm1.startup(sender: TObject);
    var
    SomeTxtFile : TextFile;
    anotherfile :TextFile;
    yetanotherfile :Textfile;
    parseline : string;
    begin
    deletefile('c:\impex\desc.txt');


    AssignFile(SomeTxtFile, 'c:\impex\concess.asc');
    AssignFile(anotherFile, 'c:\impex\style.txt');
    AssignFile(yetanotherFile, 'c:\impex\desc.txt');
    Reset(SomeTxtFile);

    while not EOF(SomeTxtFile) do begin
    ReadLn(SomeTxtFile, parseline);
    if copy(parseline,31,1) = 'Y' then begin
    WriteLn(anotherfile,parseline,1,5);
    WriteLn(yetanotherfile,parseline,1,30);
    end;
    end;
    CloseFile(SomeTxtFile);
    CloseFile(anotherfile);
    CloseFile(yetanotherfile);
    Combobox1.Text := 'anotherfile';
    end;
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,625
    Rep Power
    4247
    You're doing things the wrong way. To add items to a Combobox's menu, simply do this:
    Code:
    ComboBox.Items.Add('item to add');
    In your case, all you have to do is do a ComboBox.Items.Add(parseline); inside your while loop. There's no need to write an intermediate file at all.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Location
    Scotland
    Posts
    16
    Rep Power
    0

    Exclamation


    Thanks works a treat now need to populate a Tedit with part of the parseline info I choose in the combo box.
  6. #4
  7. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,625
    Rep Power
    4247
    This is very easy too. Note that all TEdit components have a Text property that sets/gets the value of the text in the box. The ComboBox also has a Text property. All you have to do is wire up the ComboBox's OnChange event, so that it changes the text in the text box, whenever the ComboBox's text changes.
    Code:
    procedure TForm1.ComboBox1Change(Sender: TObject);
    begin
    	Edit1.Text := ComboBox1.Text;
    end;
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Location
    Scotland
    Posts
    16
    Rep Power
    0
    Thanks thats great and I could already do that however I only want it to put "part" of the Parse line and not the part I have already put in the combobox

    Thanks
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Location
    Scotland
    Posts
    16
    Rep Power
    0

    Barcode


    ok thanks have sorted that out now I have a barcode componant from nan-soft on this program ans am trying to print using it

    I have a demo version of it however this is in delphi 7 and uses components which come with 7.

    Has anyone used this in delphi 5 and if so how did you print

    Thanks

IMN logo majestic logo threadwatch logo seochat tools logo