hi people,

I'm supposed to be creating something like a dynamic item number generator.

for example:

FROM: A 1 0 111
TO: B 2 0 112

should produce:
A 1 0 111
A 1 0 112
B 1 0 111
B 1 0 112

this would be quite easy using 4 for loops but the problem is the user should be able to control the length of the input. they can specify how long they want the numbers to be:

length [5]
FROM: A 1 0 1 111
TO: B 1 0 1 112

or

length [7]
FROM: A 1 0 1 111 A 1
TO: B 1 0 1 111 B 2

you get the picture. I'm really stumped and do not know what to do. any help would be really appreciated. thanks!

Recommended Answers

All 8 Replies

So, you need to split the string into chunks and work by value, and then go from 'start' to 'end' for each one.

yes i thought of that concept too. but how do i go about defining how many loops i need? its dynamic and therefore not fixed.

i'd really appreciate it if you can provide me with an example.

thanks in advance.

Hi,
Array size can be specified dynamically like

int[] AnArray;
      int iSize = 10;

      AnArray = new int [iSize];

So user can control the length

thanks for the reply. but i'm actually not talking about that problem. what i meant was:

1. how do i make my loops depth follow the width of the array?
2. (new question) how do i differentiate between numbers and characters and place them in the loops?

heres some psudo code
begin
split string get bunch of chunks
define output area
dostuff(chunks)
end

proc dostuff(chunks)
take first chunk
for all the bits of last chunk
for all the output areas
make a copy of current output area + bit
dostuff(chunks - current chunk)
end

i almost got it. but i cant seem to do the copy part.
here's my code:

public void GenerateCode(string[,] segmentList)
{
 for (int i = intfrom; i <= intto; i++)
 {
     GenerateCode(newsegment minus one row of segmentlist);
     //here's the problem, how do i get 'i' to be passed into the method above?
  }
}

You dont need to send I at all.

ok i got it! thanks for the pseudo code

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.