Assignment accessor must be invoked by assigning a value

This error has me stumped. I have several Popup Menus in my desktop project to fill with a country list. So I created a global method to load the Popup Menus. The method takes the PopupMenu as parameter, assigns values to the control, and returns the control with the assigned values. However, when I run the project, I get the error “Assignment accessor must be invoked by assigning a value”. I don’t know what that means. The only reference I can find for this error relates to XojoScript.Errors. Can anyone help me with this. Here is my code:

Public Sub FillCountryList()
Var popCountries As New PopupMenu
popCountries = FillCountryPopupMenu(popCountries)
End Sub

Public Function FillCountryPopupMenu(Assigns popMenuName As PopupMenu) as PopupMenu
Var rs As RowSet
Var iIndex As Integer = 0
rs = App.StoreDB.GetCountries
If rs <> Nil Then
For Each row As DatabaseRow In rs
popMenuName.RowTagAt(iIndex) = row.Column(“countries_id”).IntegerValue
iIndex = iIndex + 1
End If
Catch error As RuntimeException
MessageBox("RuntimeError: " + error.Message + " at " + CurrentMethodName)

Catch error As DatabaseException
MessageBox("DB_Error: " + error.Message + " at " + CurrentMethodName)
End Try

return popMenuName
End Function

Isn’t the usage of Assigns permitted if it’s the only parameter? Why not use Extend instead?

Assigns vs Extends

Could you get me an general example of how I could use Extend instead? I would greatly appreciate it. Thank you.

Not at a Dev Machine right now, but i’d say just replace the Assigns Keyword with Extends:
Public Function FillCountryPopupMenu(Extends popMenuName As PopupMenu)
and then call the extension like this: PopUpMenu.FillCountryList.

Oh! And remove the return popMenuName line, when you try the Extend Method. Because you are not returning the PopUpMenu you are manipulating it directly. :wink:

(Need to leave now, can’t answer in time anymore) - Good luck! :slight_smile:

That worked! Thank you so much Sascha! You’re awesome!

1 Like

it has to be the last parameter

But the documentation says otherwise: " If there is only one parameter, the use of Assigns is permitted."

Or is my poor english fooling me again? :smiley:

Docs could be wrong here @Paul_Lefebvre ?

Docs are oddly worded for that error perhaps, but not wrong. Essentially Assigns must be the last or only parameter.

Regarding the original question, FillCountryPopupMenu is using Assigns but is calling it without an assignment. In addition there is a return value on the function that you cannot access with an assignment.

Looks like Extends is more what the OP wanted.

More about Assigns and Extends is here:


In the case there is only one parameter then its also the last parameter :stuck_out_tongue:

1 Like