[Gambas-user] Warning: Class name hidden by local declaration: key

BB adamnt42 at gmail.com
Tue Aug 1 13:56:18 CEST 2023


Well no, it's not reserved (as in "you cant use it"), Gambas is just 
telling (warning) you that you are over-ruling it's use of the word. The 
Gambas reserved words are listed somewhere in the wiki but suffice to 
say you cant do something like "Public Sub xyxxy(Public as String, Sub 
as boolean). Got it?

b

On 1/8/23 9:16 pm, Demosthenes Koptsis wrote:
> ah it is a reserved word you mean...ok!
>
> thanks!
>
> On 8/1/23 14:39, BB wrote:
>> On 1/8/23 8:54 pm, Demosthenes Koptsis wrote:
>>> i wrote a demo code for Action property as follows...
>>>
>>> i have a Form with a Menu and a Button for "save" Action
>>>
>>> ------------------------------------------------------------
>>>
>>> ' Gambas class file
>>>
>>> Public Sub Form_Open()
>>>  Me.Center
>>>  Menu1.Action = "save"
>>>  Button1.Action = "save"
>>> End
>>>
>>> Public Sub Action_Activate(key As String) As Boolean
>>>  Select Case key
>>>  Case "save"
>>>  ' call save sub at here
>>>   Print "save to a file."
>>>  End Select
>>> End
>>>
>>> ------------------------------------------------------------
>>>
>>> i get a warning at line 9, Public Sub Action_Activate(key As String) 
>>> As Boolean
>>>
>>> Class name hidden by local declaration: key
>>>
>>>
>>> What does this mean ?
>>>
>>>
>>> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>>
>> It means that you have used a, well let's say a, "significant" word 
>> as a variable name (in this case a variable described as a parameter 
>> name).
>>
>> What does that mean?
>>
>> It means that within the scope of your declaration of that variable 
>> you cannot expect to use the native Key class to be operative. So 
>> Gambas is telling you essentially that "OK, you want to use one of my 
>> special names as your own variable name and instead of it referring 
>> to my Key class, then fine I'll just use your string variable. Fine, 
>> OK then I guess you know what you're doing."
>>
>> In other words, as long as you don't refer to the native class within 
>> the scope of that procedure then everything will work as you expect.
>>
>> b
>>
>>
>>
>> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----


More information about the User mailing list