From: Ne Scripter Date: 2009-09-03T18:58:14+09:00 Subject: Counter problem for specific file types Hi all, This is a real teaser for me and would appreciate some help with the logic. I want to introduce some numbering to a data set. Basically I have two sets of items the,a control item and a process item. The control item is always assigned the number 0 eg. if type == "Control" number = "0" end A control item may or may not have process, and may have multiple processes. I have a while loop that goes through every single item and when it encounters a Control item it assigns it a 0, what I want it to do also is assign a continuous number to each process item. Take this algorithm if type = "control" number = 0 elsif type = "process" number = counter starting at one end It will keep adding a continuous number to each process item until it comes across a type of control or something else. So you will end up with an output like this control, 0 process, 1 process, 2 process, 3, control, 0 process, 1 something else, NULL control, 0 control, 0 process, 1 and so on. I hope I am making sense with this, remember this code is in a while loop going through each individual item. Any input to get started on this is greatly appreciated. -- Posted via http://www.ruby-forum.com/.