Jump to content
Sign in to follow this  
fj13

Looping </>

Recommended Posts

Hello!

I'm new to Delphi and to programming in general I have a hard time realizing my idea. Maybe somebody here can help me.. 

I've a list of numbers, I've already imported into Delphi. Now I want to loop thru them and determine if the number is </> than 5. If smaller than 'Micro', if bigger than 'Macro'  should be displayed beside the number. I'm stuck here!

At the end it would be cool to count the total number of Macro and Micro, but I think I'm able to do that. I would really appreciate some help! Thanks! 

Hilfe_Forum.thumb.JPG.5c3a06e57c724b760a96a1872d161f08.JPG

Share this post


Link to post

You're making it unnecessarily hard for you if you rely on interface elements (like the TMemo) for data storage and processing.

 

I guess the button "Read data" gets the numbers from the memo and then keeps them in an array or list? If yes, that's good, because it's probably the hardest part. Because if you have your numbers in a list or an array, you can then easily loop over them with a for statement.

 

If you have some code (especially what is behind your "read data") then we could help with advice tailored to your project, instead of general recommendations.

Edited by Der schöne Günther

Share this post


Link to post

Sorry of course! 

I'm reading the data from a txt.file, because then it will be easier to read already existing new data. At least that's my plan.

I hope that helps to understand.

Hilfe_Forum2.thumb.JPG.80478fac6b6b9e3e9c0eb62adcc85c9f.JPGHilfe_Forum3.thumb.JPG.b7e14468c76dac32369a166fe2d3c777.JPG

Share this post


Link to post

You should use the code blocks and insert the code within the forum, posting screen shots of the code wont help

 

You should think twice before using TMEMO as a list handler 

 

You can create an object that holds your preferred variables and add the object to a list and use it accordingly 

Share this post


Link to post

Hi all...:classic_cool:

Quote

You should think twice before using TMEMO as a list handler 

:classic_cheerleader:

 

Proposal:

 

1. create a TStringList as a private variable

2. read the *.txt file into a TStringlist  http://docwiki.embarcadero.com/Libraries/Seattle/en/System.Classes.TStrings.LoadFromFile

List.LoadFromFile

3. show the content of the *.txt File in the MEMO

Memo.Text := List.Text

 

4. iterate through the lines of the List if you want to Work with the data

for I := 0 to List.Count - 1 do
begin
  // your work
end;

5. if you change the data in the list, reload the MEMO

Memo.Text := List.Text

 

...finish. :classic_cool:

 

:classic_blink: German names? If you  search the german DP ... https://www.delphipraxis.net

Edited by haentschman

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×