FM3 - calculate a field value during upgrade based on field being removed

I’m looking for a way to automaticaly fill new field values in a table from another field I’m planning to remove.
In my Cars table version 4 I have a field EngineType STRING(1) with values B for Benzin/Petrol/Gasoline , D for Diesel, L for LPG. I am about to remove that field
In version 5 table I want to have a new field FuelType STRING(3) with values P for Benzin/Petrol/Gasoline , D for Diesel, LPG for LPG, H for hydrogen etc. to match goverment standard.

I’m thinking of executing something like this in callback procedure when upgrading from version 4 to version 5

    case pFunction
    of FM3equ:UpgradingFile    !About to upgrade a file

    of FM3equ:CopyingRecord   !After copy record, before save

		if pOptions = address(Cars) and UFD:FromVersionNumber = 4 AND |
 UFD:ToVersionNumber = 5 THEN
			 CASE CarsVer4:EngineType
			 OF 'B'
				CarsVer5:FuelType = 'P'
			 OF 'D'
				CarsVer5:FuelType = 'D'
			 OF 'L'
				CarsVer5:FuelType = 'LPG'
			 END	
    of FM3equ:UpgradingFileDetailsString
!      UFDGroup = pFileName
!      message('File ' & UFD:FromLabel & ' upgrading from: ' & UFD:FromPrefix & ' To: ' & UFD:ToPrefix & '|Version: ' & UFD:FromVersionNumber & ' To: ' & UFD:ToVersionNumber)
    of FM3equ:EndUpgradeFile
!      message('Finished upgrading file: ' & pFileName)
    end

but not sure how I can refer to a field with specific table version ( CarsVer5:FuelType is just something I made up ) , also when FM3 uprades a table from say version 1 to version 6 is it going through all versions or just straight to ver 6

In this FAQ CapeSoft File Manager 3 Complete Documentation there is an example how to calculate new field value but it does not show how to refer to a field that was removed in newer table version. Is that at all possible?

If it goes from version 1 to 6 it does so in one jump.

Personally i think this is a situation where you shoukd just add a new field, and leave the old field in the table for now. Populate the new field (via a process or whatever) and remove the old field at sone point in the future.

1 Like

I have done what Bruce recommends many times over the last 20 years. For some I have just had FM3 create the new field and done the calculation via a process at time of upgrade. Just hiding the old fields so no one knows they are even there.