# Omitted(Parameter\_Name) scope limited to Procedure?

**URL:** <https://clarionhub.com/t/omitted-parameter-name-scope-limited-to-procedure/7595>\
**Category:** questions\
**Tags:** language\
**Created:** [October 22, 2024, 3:24pm UTC](https://clarionhub.com/t/omitted-parameter-name-scope-limited-to-procedure/7595 "2024-10-22T15:24:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RchdR](https://clarionhub.com/letter_avatar_proxy/v4/letter/r/d78d45/32.png) [@RchdR](https://clarionhub.com/u/RchdR)\
**Post date:** [October 22, 2024, 3:24pm UTC](https://clarionhub.com/t/omitted-parameter-name-scope-limited-to-procedure/7595/1 "2024-10-22T15:24:10Z")

</div>

So this might be tied in with nested omits but omitted isnt a compiler directive, hence the question

> [@Omit Cannot be nested - work around](https://clarionhub.com/t/omit-cannot-be-nested-work-around/6453):
>
> Most of the time when I want to nest conditional OMITs and/or COMPILES it works as desired. However sometimes the compiler complains about it. Note: you do have to be careful to make sure that the 1st argument (the terminator string), is NOT a substring of an another OMIT/COMPILE The HELP for OMIT says The compiler reads and parses source/include files by blocks. If the end of an OMIT/COMPILE block (terminator string) is found in the current block, the compiler either with skip the text up …

```clarion
ProcedureName(<*cstring pName>)
 Code
 !do some stuff
 Return ProcedureProcess(pName)

ProcedureProcess(<*cstring pName>)

 Map
   NewVariables Procedure
 End
 Code
 NewVariables()
 If Not Omitted(pName)
   ! No compiler error - code works fine
 End
 
NewVariables Procedure
 Code
 If not omitted(pName)
   ! No compiler error and this code does nothing
 End
 If not omitted(pPairOfElliptoids)
   !compiler error Unknown identifier
 End

```

So if the compiler can spot pPairOfElliptoids dont exist, why cant it spot pName in the same local procedure?  
A compiler error would at least be nice if nothing else.

So is this also a confirmed bug along with the nested compile/omit directives?

My login doesnt work on the sv ptss so I cant file anything last time I tried so I cant check if this is a known bug.

---

<div class="post-metadata">

**Author:** ![Rick\_UpperPark](https://clarionhub.com/user_avatar/clarionhub.com/rick_upperpark/32/346_2.png) [@Rick\_UpperPark](https://clarionhub.com/u/Rick_UpperPark)\
**Post date:** [October 22, 2024, 3:40pm UTC](https://clarionhub.com/t/omitted-parameter-name-scope-limited-to-procedure/7595/2 "2024-10-22T15:40:21Z")

</div>

Bug or design limitation, it is a known issue.

OMITTED only works with parameters in the procedure or method where it is used.  
In your case pName is in scope for use as a variable because of the way Clarion handles procedure variables being in scope for local procedures/methods.  
However, that does not apply to OMITTED.

In an ABC procedure, if you want to test if a parameter to the procedure is OMITTED you need to do that in a routine to the procedure itself, not in a method like `ThisWindow.Init()`

FYI, you can format your Clarion code by surrounding it will three Backticks (`) before and after the code block. Add the “clarion” key word after the leading Backticks and it is “clarion aware”.

```clarion  
Code  
```

* * *

It works the same with 3 Tildes ~~~ … which on my keyboard is the same key.

```
~~~clarion
Code
~~~
```

---

<div class="post-metadata">

**Author:** ![RchdR](https://clarionhub.com/letter_avatar_proxy/v4/letter/r/d78d45/32.png) [@RchdR](https://clarionhub.com/u/RchdR)\
**Post date:** [October 22, 2024, 4:08pm UTC](https://clarionhub.com/t/omitted-parameter-name-scope-limited-to-procedure/7595/3 "2024-10-22T16:08:51Z")

</div>

Oh you mean format on the website, like this. [Can I remove a File Drop Combo from a form? - #6 by RchdR](https://clarionhub.com/t/can-i-remove-a-file-drop-combo-from-a-form/7478/6)

Ill have to remember the

```clarion
as formatting isnt an option popping up on my phone.
```

---

<div class="post-metadata">

**Author:** ![RchdR](https://clarionhub.com/letter_avatar_proxy/v4/letter/r/d78d45/32.png) [@RchdR](https://clarionhub.com/u/RchdR)\
**Post date:** [October 22, 2024, 4:27pm UTC](https://clarionhub.com/t/omitted-parameter-name-scope-limited-to-procedure/7595/4 "2024-10-22T16:27:04Z")

</div>

> [@Rick\_UpperPark](#):
>
> However, that does not apply to OMITTED

Only one workaround I can find is to create a new procedure (seen the appgen tree) and do some not all of the tests there.  
Size will wont return the correct size if the parameter is omitted.

I cant duplicate the parameters from the procedure to the local procedure because the compiler throws label duplicated, second used: parametername errors unless I change the parameter names just for the local procedure, which is an option I guess.

So the compiler is aware of the parameter in the local procedure so to me its looking like a bug in omitted() !

---

<div class="post-metadata">

**Author:** ![vitesse](https://clarionhub.com/user_avatar/clarionhub.com/vitesse/32/837_2.png) [@vitesse](https://clarionhub.com/u/vitesse)\
**Post date:** [October 22, 2024, 11:57pm UTC](https://clarionhub.com/t/omitted-parameter-name-scope-limited-to-procedure/7595/5 "2024-10-22T23:57:18Z")

</div>

Hi Richard and Rick

~~I’m thinking it is not a bug but is working correctly and “as expected”.~~  
(see #Edit 2 below - I recanted the above)

It all comes down to scope.

I could be mistaken as the documentation is somewhat hard to understand, but it says

 ![image](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/c/c797662f842250a1761a777980216a2fa60df37d.png)

Note specifically the bit “_is an identifier that matches the name of any procedure parameter it is called from_”.

#Edit 1. Maybe I am misunderstanding you Richard - are you saying the code where you have “! No compiler error and this code does nothing” is not performed even when pName was in fact passed to ProcedureProcess.

eg. if you have

```clarion
NewVariables Procedure
 Code
 If omitted(pName)
    stop('pName was omitted')
 else
    stop('pName = ' & pname)
 end

```

and you call procedureProcess:

```clarion
myCStr cstring('hello Richard')
  code
  procedureProcess(myCStr)

```

what do you see?

#Edit 2  
I now see the bug or “known issue” that Richard and Rick are referring to. I tested it myself and in NewVariables Procedure it thinks pName was omitted in the example code I gave above.

Perhaps a work-around for Richard is to just use len(pName) and see if it is zero.

---

<div class="post-metadata">

**Author:** ![RchdR](https://clarionhub.com/letter_avatar_proxy/v4/letter/r/d78d45/32.png) [@RchdR](https://clarionhub.com/u/RchdR)\
**Post date:** [October 23, 2024, 12:48am UTC](https://clarionhub.com/t/omitted-parameter-name-scope-limited-to-procedure/7595/6 "2024-10-23T00:48:22Z")

</div>

> [@vitesse](#):
>
> No compiler error and this code does nothing” is not performed even when pName was in fact passed to ProcedureProcess.

Correct.

Ok lets go with docs, yes I agree using it in a local proc is technically out of scope, but I dont get a compiler error stating this. Either way, I dont get a compiler error when I would expect to get one.  
Secondly the docs are ambiguous. Theres no mention of scope in the docs.

Sure it probably works in a routine but you cant pass parameters to a routine.

Plus I can do local procedure overloading because I cant do appgen procedure overloading. This is one of the things I discovered when I wrote my work in progress class writing template so I can use the appgen to write a class although I had to come up with a work around.

But wouldnt it be nice if omitted could work with parent proc parameters and throw an error when its used out of context? The latter would be nice and the docs page made less ambigous.

Edit.  
Another point on the scope is other language commands/functions dont complain about the scope, eg band(var,bitmaskequate) can use a parameter from its local procedure or the parent procedure.

It just seems short sighted to have omitted() work the way its currently working, unless there is an undocumented compiler flag to alter its behaviour?

Eg #pragma define(local\_implicits =\> on | off )
