View Single Post
  #3   Spotlight this post!  
Unread 04-11-2008, 16:03
Tristan Lall's Avatar
Tristan Lall Tristan Lall is offline
Registered User
FRC #0188 (Woburn Robotics)
 
Join Date: Aug 2001
Rookie Year: 1999
Location: Toronto, ON
Posts: 2,484
Tristan Lall has a reputation beyond reputeTristan Lall has a reputation beyond reputeTristan Lall has a reputation beyond reputeTristan Lall has a reputation beyond reputeTristan Lall has a reputation beyond reputeTristan Lall has a reputation beyond reputeTristan Lall has a reputation beyond reputeTristan Lall has a reputation beyond reputeTristan Lall has a reputation beyond reputeTristan Lall has a reputation beyond reputeTristan Lall has a reputation beyond repute
Re: Delphi ComboBox Items

It's been a while since I've used Delphi...but if I remember correctly, you'll need to do the following:
  • Populate TComboBox.Items[] with a list of filenames stored as Strings. If I'm not mistaken, this is a dynamic Array of String. There's a method already provided that will let you add String variables: TComboBox.Items.Add(). Alternatively, if this doesn't have to be changed during program operation, just use the properties window to fill in Items yourself using the […] button.
  • When the user clicks something to confirm their selection, or hits enter, read the selected item from the TComboBox. Store that data (i.e. a filename) in a String.
  • Read the file's contents. Note that even if it's a .txt file, there are multiple ways of reading it in.
    • If you assign a variable of type TextFile (equivalent to type Text), it's sequential-access, and you'll need to parse it somehow. This depends on the input specification.
    • If you use type File (or File of [some type]), you'll probably get a mess. But you're stuck with it if you need random-access capability.
    Either way, you'll need to use AssignFile() with the file variable (of type TextFile, File or File of [some type]) and the filename (of type String). Also, you'll need to use Reset() and CloseFile().
  • If you want to put data into a TMemo, you might consider reading a TextFile line-by-line with ReadLn(), and then outputting the result to TMemo.Lines[] (dynamic Array of String).
Check the help file or http://www.delphibasics.co.uk for more information on the specific functions and types.

Incidentally, as was noted by FourPenguins, this forum is typically devoted to the FIRST Robotics Competition, and discussion of related topics.

Last edited by Tristan Lall : 04-11-2008 at 16:30. Reason: This is more like it…