Macro that worked previously in previous installation now doesn't

This macro worked on my previous laptop. It is modified from here (the second OSM code: https://digital-geography.com/geocoding-addresses-directly-in-libreoffice-calc/ - my version previously worked under

Function GetGeoDataOSM(sSearch as String) as String
       If Len(sSearch) = 0 Then Exit Function
       URL = "http://nominatim.openstreetmap.org/search?format=xml&q=" 
       URL = URL & sSearch
       oSimpleFileAccess = createUnoService( "com.sun.star.ucb.SimpleFileAccess" )
       On Error GoTo ErrorResponse
       oInputStream = oSimpleFileAccess.openFileRead(URL)
       oTextStream = createUnoService("com.sun.star.io.TextInputStream")
       oTextStream.InputStream = oInputStream
       aDelimiters = Array(ASC(">"),ASC("<"),ASC(" "),ASC("="))
       sLastString = ""
       Do While NOT oTextStream.isEOF
          sThisString = oTextStream.readString(aDelimiters,True)
          Select Case sLastString
             Case "lat":
                sLat = sThisString
                Case "lon":
                sLon = sThisString
          End Select
          sLastString = sThisString
       Loop
       GetGeoDataOSM = " Longitude: " & sLon & " Latitude: " &sLat 
       oInputStream.closeInput()
       Exit Function
       ErrorResponse:
       GetGeoDataOSM = "no values found!!!"
    End Function

When I use it in a cell (e.g. =getgeodataosm(D63), I get #name 
WHen I run it in the macro editor, I get a Basic runtime error on the second line "argument is not optional'.  If I delete that line and step through the macro, I get the same error on the next line.

Anyone got any ideas? I'm on LO 24.2.7.2 - it previously worked in LO 5.

suggests that the macro is in a library which is not yet loaded. Where do you store the macro?

try

sub main
msgbox GETGEODATAOSM("London")
end sub

In My macros, Standard, Macro 1, and then the function name. I’m not sure where that’s stored - it’s a linux mint installation and I can’t find the relevant directory, even whem showing hidden files.

… and did you enter and then run the

sub main
msgbox GETGEODATAOSM("London")
end sub

code?

You mean add it to the macro or run it separately? What does it do?

Ah, I’ve resolved it. I looked on my old machine and/ found the macros (on linux Mint) are stored in home/name_of_user/.config/libreoffice/4/basic
the basic directory was missing on my new installation, so I just copied it over. Bingo! the macro works now.