Calc basic macro function passing cell fails after Libre Office upgrade

REM  *****  BASIC  *****

Function MAX89(a)
String aa
Dim L,tstv,mx

REM 
L= Len(a)
If L = 1 then

MAX89 = a

else
mx   = 0



REM
For c = 3 to l step 2
    tst  = MID(a,c,1)
    tstv = val(tst)
    If tstv > mx then
        mx = tstv
        MAX89 = mx
       
    endif


Next c

Endif

if a = "Disqualified" then
  MAX89 = 1
endif

End Function

[erAck: edited to format as code, see This is the guide - How to use the Ask site? - #6 by erAck]

The line above uses a variable “l” (lowercase l) while I think it should be an “L” (uppercase l), which contains the length of the variable a.

Could it be that, in the past versions of Calc, the variable names were case-insensitive?

Thanks Steph1 but I tried it and it did not work the I am getting a Err509 with the message "A scripting Framework error occurred while running the Basic script standard Module1 MAX89.
The Cell I an referencing H3 contains the string “7,8,9” I am refencing "=MAX89(H3)

I know what is happening… MAX89 now is a valid cell reference, therefore Calc first tries to get the content of that cell!

Rename the macro MAXIMUM89 and all occurrences of MAX89 in the code to MAXIMUM89 and it should work!

1 Like

It worked! I want to thank Steph1 and erAck…Mark

1 Like

Upgrade from what to what version even? I presume it was from a version with 1024 columns to a version that now supports 16384 columns, where MAX89 is a cell address (i.e. last column is XFD) and thus a cell address followed by ( parenthesis is not a valid expression, hence the Err:509 “Operator missing” error.

Rename the macro and its variable to something safe not resembling a cell address, like MYMAX, and it will work.