Changes to macro BASIC from Calc 6.0.7.3 to 6.4

I have been using LibreOffice Calc 6.0.7.3 installed with Mint 19.1. A new install of Mint 20 has Calc 6.4, and will not run my existing macros. The errors (so far) seem to involve Global variables no longer working for modules in different dialogues, and variable names the same as subroutine names.

Is there a list of the changes? The version history ‘BASIC’ sections for 6.1, 6.2, 6.3 and 6.4 were no help. I need to know the level of effort required to update my macros (which run to thousands of lines of code) so I can decide if I need to revert to an older version.

Thank you

Please give us more details, upload sample file, macro code, etc…

I was not able to put much text here, so I put my reply in an ‘answer’.

Thanks.

I have been able to work around both of the problems so far. They are detailed below. The code below has worked in several versions of OpenOffice and LibreOffice going back about 9 years. My concern is that there may be other changes to BASIC that will cause problems not yet uncovered. That is why I asked what was changed.

Issue 1:
This error message is generated by CALC when any macro is run:
‘BASIC syntax error.
Variable FunnelDamage already defined.

The solution I found was to change the name of the subroutine. The macro code is:

Sub FunnelDamage

Dim InitialFunnels as integer
Dim LostFunnels as single
Dim FunnelDamage as single
Dim FunnelFraction as single

The ‘single’ after ‘FunnelDamage’ was highlighted.

Issue 2:
This error message is generated by my macro code as a msgbox:
Version missmatch, Scenario: V11 Code:
There should be a version number after ‘Code:’. This indicates a null string was returned by the LoadScenarioSub subroutine, which is in macro ‘Load’ in dialog ‘Scenario’. The variable ‘versionscenariocode’ is defined as a Global in a macro in another dialog. I found two ways to fix the problem:

  1. Duplicate the global statements in the ‘Scenario’ dialog’
  2. Combine all the macros in the same dialog.

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

Function LoadScenario ’ Called from spreadsheet macro button

If notdoneyet = 0 Then

	notdoneyet = 1

	versionscenariocode = "V11"

	yesnotext = "Load a new scenario?"
	Call YesNoMsgBox("Load "+versionscenariocode+" scenario",16)
	If yesnoreturn = 6 Then

		ButtonSheet = ThisComponent.Sheets.getByName("Buttons") ' Sheet 6, Scenario
		oCell = GetCellByName(ButtonSheet, "subrunning2")
		oCell.setPropertyValue( "CellBackColor", RGB( 0, 0, 255 ) )

		Call LoadScenarioSub

		ButtonSheet = ThisComponent.Sheets.getByName("Buttons") ' Sheet 6, Scenario
		oCell = GetCellByName(ButtonSheet, "subrunning2")
		oCell.setPropertyValue( "CellBackColor", RGB( 255, 255, 255 ) )

	Endif

	notdoneyet = 0

Endif

End Function 'LoadScenario

Function LoadScenarioSub

Dim CellRange as object
Dim oCell as Object
Dim oRow as integer
Dim oCol as integer
Dim LastShip as integer
Dim LastSide1 as integer
Dim LastSide2 as integer
Dim Ploteast as integer
Dim Plotnorth as integer
Dim Refeast as integer
Dim Refnorth as integer
Dim radperdeg as double
Dim sName as string
Dim dummytext as string
Dim ScenarioName as string
Dim ScenarioDesc as string
Dim ScenarioDate as integer
Dim scenariohour as integer
Dim scenariomin as integer

Dim minvisr as integer
Dim maxvisr as integer
Dim winddir as integer
Dim windspd as integer
Dim seastate as integer
Dim sside as integer
Dim refitflag as string
Dim shipname as string
Dim shipclass as integer
Dim shipclassrow as integer
Dim fceff as single
Dim Side1Name as string
Dim Side2Name as string
Dim ForceName1 as string
Dim formation as integer
Dim maxspeedcode as single

Dim shore1east(10) as single
Dim shore1north(10) as single
Dim shore2east(10) as single
Dim shore2north(10) as single
Dim obstructeast(10) as single
Dim obstructnorth(10) as single
Dim obstructradius(10) as single
Dim cellnamestring as string
Dim infile as string

Dim PrimaryTypeSelected as integer
Dim SecondaryTypeSelected as integer
Dim TertiaryTypeSelected as integer
Dim BoatsperDDTBunit as integer
Dim TorpedoTypeSelected as integer
Dim ColumnDistance as integer
Dim ScreenDistance as single
Dim dummy as integer
Dim shorepresentflag as integer
Dim minespresentflag as integer
Dim shoalspresentflag as integer
Dim islandspresentflag as integer
Dim shorefloat as integer
Dim screenorder1 as integer
Dim screenorder2 as integer
Dim shipnation as integer

Dim Ship_number(150) as integer
Dim ShipForce(150) as integer
Dim Guide_n_value as integer
Dim Bearingfromguide as integer
Dim bestdirectionchange as integer
Dim Distancefromguide as single
Dim Shiptype as integer
Dim LargestShipType1 as integer
Dim LargestShipType2 as integer
Dim ERoverride as integer
Dim ForceFlagship(6) as integer
Dim ForceName(6) as string
Dim LargestShipType(6) as integer
Dim PriDirector as integer
Dim SecDirector as integer
Dim TerDirector as integer
Dim APHEFraction as single
Dim OperationMode as integer

Dim Force as integer

infile = ChoseAFileName

If infile = "nullfile" Then
	Msgbox("No file chosen")
	Exit Function
Endif

filenumber = Freefile
open infile for input as filenumber

Input #filenumber, versionscenario

If versionscenario <> versionscenariocode Then
	Msgbox("Version missmatch. Scenario: " + versionscenario + " Code: " + versionscenariocode)
	Exit Function
Endif