Re: Loop through values of variables

"Felipe Rezek Mohallem" <[email protected]>
Newsgroups gmane.comp.lang.delphi.programming
Message-ID <[email protected]>
Try breaking apart your string, like this:

procedure BrkApart ( str : string; c : char; strList : TStringList );
begin
var i, j: integer;
  temp: String;
begin
 j:= 0;
   Temp := '';
   StrList.Clear;
   if Str = '' then
    exit;
   for i:= 1 to Length(Str) do
    if Str[i] <> c then
       Temp := Temp + Str[i]
      else begin
       StrList.Add(Temp);
         Temp := '';
      end;
   if Str[Length(Str)] <> c then
    StrList.Add(Temp);
end;

procedure TMyForm.Break;
var
    MyList : TStringList;
    i : integer;
begin
    MyList := TStringList.Create;
    try
        BrkApart ( '5/14/18/27/32/38', '/', MyList );
        for i := 0 to MyList.count - 1 do
        begin
            // make your code here
        end;
    finally
        MyList.Free;
    end;  
end;

// Best regards,
// Felipe
  ----- Original Message ----- 
  From: Tony Vissoc 
  To: [email protected] 
  Sent: Thursday, July 31, 2003 5:19 PM
  Subject: Re: [Delphi] Loop through values of variables


  Looks like 3 nested loops.  First loop makes 5 the first number, calls second loop.  Second loop makes 14 the second number (first cannot= second cannot= third) and calls third loop.  Third loop uses 18 for initial.  Then, steps thru rest and exits.  2nd loop then grabs 18 for itself and calls third loop again, etc.

  Tony


  >>> [email protected] 07/31/03 09:26AM >>>
  I am relatively new to Delphi. I have an edit box which requires the 
  user to enter 6 numbers separated by '/'. Each number is assigned to 
  a variable (say count1 through to count6).  Could you help me to 
  create a loop that will create all the combinations from the 6 random 
  numbers that are only 3 digits long. IOW if the numbers entered were 
  5/14/18/27/32/38, then the first combination will be 5/14/18... all 
  the way to the last which will be 27/32/38. Perhaps there is some 
  better way of doing it...

  Thanks in advance!





  CodeCoffer - new Delphi code protection Tool!
  http://www.delphicollection.com/public/CodeCoffer.htm 
  ---------------------------------------------------------------
  Unsubscribe:[email protected] 
  List owner:[email protected] 
  --------------------------------------------------------------- 

  Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




        Yahoo! Groups Sponsor 
              ADVERTISEMENT
             
       
       

  CodeCoffer - new Delphi code protection Tool!
  http://www.delphicollection.com/public/CodeCoffer.htm
  ---------------------------------------------------------------
  Unsubscribe:[email protected]
  List owner:[email protected]
  --------------------------------------------------------------- 

  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 


[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Free shipping on all inkjet cartridge & refill kit orders to US & Canada. Low prices up to 80% off. We have your brand: HP, Epson, Lexmark & more.
http://www.c1tracking.com/l.asp?cid=5510
http://us.click.yahoo.com/GHXcIA/n.WGAA/ySSFAA/i7folB/TM
---------------------------------------------------------------------~->

CodeCoffer - new Delphi code protection Tool!
http://www.delphicollection.com/public/CodeCoffer.htm
---------------------------------------------------------------
Unsubscribe:[email protected]
List owner:[email protected]
--------------------------------------------------------------- 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.