Re: C question!



Yes Tim, you are right!

Excuse me if I didn't make myself clear. But I am using an array, for I
didn't find a structure convenient in this case.

Thankyou for your concern!

--
Best regards
Robert


"Tim Roberts" wrote:

Robby <Robby@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

Yup, then I shall just keep it the way I had it.

I'd rather not get too fancy!

OK, now I have to chime in.

This is not about being "fancy". This is about good, basic software
engineering techniques. One of the most fundamental computing principles
is DRY: Don't Repeat Yourself. Anytime you find yourself doing something
repetitive, you have an opportunity to replace that with an iterative loop.
This pays huge and tangible benefits. First, when you repeat code, you
introduce many opportunities for bugs and typos. Second, when you have to
modify the code, inevitably you will forget to update one or more of the
repeated sections. Third, sooner or later you are going to want to add
more: more cases, more variables, etc. With a loop, those added cases cost
you nothing -- just increase the loop count. With repeated, you have to
cut-and-paste more copies, possibly in multiple places.

Do the right thing. Stop right now, and change your code to use an array
instead of a structure with MSG1, MSG2, MSG3, MSG4, etc.
--
Tim Roberts, timr@xxxxxxxxx
Providenza & Boekelheide, Inc.

.



Relevant Pages

  • Re: How would you do this in forth?
    ... I thought I'd just code up a quick array based solution before making ... You might try doing "found" with a DO LOOP instead of BEGIN WHILE REPEAT ... If I doesn't have to be on the stack then not-yet and got-it: ...
    (comp.lang.forth)
  • Re: Compile error using array
    ... If your array is defined within a procedure it will not be visible to other ... Tim ... I even have a For Next loop to initialize each single variable in the ... integor variable Enumr8 as the loop counter, ...
    (microsoft.public.excel.programming)
  • Re: Check value in Array
    ... your method needs, on average, to loop 224.9602 times. ... and then just shuffle the array. ... cell to see if the new random number is equal to that cell value. ... I have to repeat this step several thousands time and it ...
    (microsoft.public.excel.programming)
  • Iterating a For Loop on an array index, and repeating
    ... I have a seemingly simple task, but I am new to LabView and visual programming: ... While "Start" = true, repeat for loop ... constant, for instance I could say repeat 3 times, but this is not ... way to do this in LV 8 without going from an array to a cluster, ...
    (comp.lang.labview)
  • how many times repeat a number in an array??
    ... i have a function that gets from the user a random Array.by using the unique function i have a unique list with the arguments of the vector.with out using loop how do i find the times which a number is repeat in the array ...
    (comp.soft-sys.matlab)