Procedure Parameter optional nothing empty or something like that

Hello, a simple question for using a procdure:
There are four clocks
clock1
clock2
clock3
clockDummy
I want to put them all enabledOFF without any exeption, no problem!
I want to put them all enabledOFF exept one exeption, f.e.Clock2, no problem

How can I get an information: Is there an exeption or not?
What is the right way to call the procedure with a empty parameter.

I tried some procedure blocks, but I did not found an optimal way.

Thank you for some help!

Here are some examples of my "bad" tries:

blocks


blocks(2)

blocks(4)


blocks(7)

The only way to allow empty parameters that I know of is to supply a possibly empty list in the call block.
That would let you make a procedure like

procedure disableClocks(ClockList)
  for each thisClock in list ClockList
     set thisClock.Enabled to false
  end for
end procedure

Thank you, you gave me a new idea.

blocks(2)


Just to help:

except
exception

I get a little sick when I see a lot of global variables set to redundant information about other variables and lists. It is a burden to keep everything in sync.

I generally avoid those by writing small value functions that examine the master list(s) and return their lengths or filtered subsets.

Hello TIMAI2,

I accept your exception...

Something like this ?

Hello TIMAI2,
thank you for your answer.

You are using global lists, just like me.
ABG will be still sick...?

For each loops are pre-test loops (German: abweisend), empty list: no item no work
so we can do someting like this:


blocks(1)

(only one clock can be enabled, ListeON will be empty or length of list = 1)

I recommend this online book for improving your code quality ...


from FAQ Section: Books, Tips, Tutorials for AI2

1000 Pages, a good thing in corona Times
Thank you

1 Like