Find where variable is declared

Hello all,

I am trying to use the PreferenceExample in my small new project.
But I have different and more variables then the one UserID.
I can not find where UserID is declared in the example.
I have tried Find and it gives me all the places where UserID is used, but not where it is declared.

If I use the Preferences.Set(“PrefName”) = value it gives me an error that PrefName isn’t declared. I would like to add my variables to the prefs.

I am using MacOS (Mac mini)

In the past (VB6) I used the shift F2 keys and then the declaration location would show. (but this was on windows)

Thanks in advance

UserID is a property of ‘Preferences’ ?
Try searching for the preferences class

If you are referring to the PreferencesExample from the Saving Preferences blog post then there is no UserID variable.

As noted in the post:

The code users operator_lookup (which I did a webinar about last summer) to dynamically look up the preference name (“TestUser”) in a JSONItem at run time.

Operator Lookup docs

1 Like

Thank you for helping me.
But could you give me a hint?

Generally, for a variable or property you can right click on it and you should find a “Goto XXX” item in the popup menu.

I do not have Goto xxx, I do have find…

I have opened the example which is included in the Xojo program.

I have Xojo version 2021 Release 3

And thank you all for helping me.

Goto only appears when there is a variable, class name or property. If it is not appearing it is either not a variable or a parameter to the current method.

it is a special syntax

@MarkusR , I believe it is a special syntax.
But how would I use it?
Because if I use:
Dim top As Integer = Preferences.MainWindowTop
UserIDField1.Text = top.ToString()
I get the PreferenceNotFoundExeption error.

Does the variable need to exist in the pref file?
Before I start the program?

have you used
Preferences.MainWindowTop = 1
i guess it is stored in a dictionary (jsonitem) via key,value

you could replace the value at get to Lookup and give it a default value. (means rewrite this get method.)

I think I have…

But maybe in the wrong place.

I see now that it is the wrong place, it is when .Load fails.

using break points and System.DebugLog

Thank you @Marcus and everybody.
I have altered the Get method to:
If mPreferences <> Nil Then

return mPreferences.Lookup(name, “Not found”)

Return -1
End If

And now the code works perfect.
I will insert the class into my program and finally be able to save my variables.