Persistence_get returns an array

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

Post Reply
Message
Author
JackZ
Posts: 2267
Joined: Mon Feb 22, 2016 1:02 pm

Persistence_get returns an array

#1 Post by JackZ »

Hello

With the new 3.7.8 i get an error message about a wrong persistence data:

In an instrument, i created a persistence data using an array

Code: Select all

-- Create a new persistence object
persist_tank_level = persist_add("tank_level", "FLOAT[2]", {50.0,25.0})--main, aux

-- Get the data from the persistence object
local tank_level = persist_get(persist_tank_level)
print(tank_level)
then changed my mind and replaced the array by a single Float

Code: Select all

-- Create a new persistence object
persist_tank_level = persist_add("tank_level", "FLOAT", 50.0)--main, aux

-- Get the data from the persistence object
local tank_level = persist_get(persist_tank_level)
print(tank_level)
but apparently the persistence file has still an array, hence AM throws me an error when trying to use the retrieved tank_level value, which is still an array even though it is no longer declared as such.
Guess the format of the file is not updated. Where is the persistence file located, by the way?

Thanks

Jacques
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

User avatar
Corjan
Posts: 2939
Joined: Thu Nov 19, 2015 9:04 am

Re: Persistence_get returns an array

#2 Post by Corjan »

Hi,


From AM 3.6 the type argument is not actively used anymore. It is still there for backwards compatibility.
You can basically throw anything into a persistence object, and you will get exactly the same thing back.

That does mean that you are responsible as the instrument builder to be able to deal with type changes.


Corjan

JackZ
Posts: 2267
Joined: Mon Feb 22, 2016 1:02 pm

Re: Persistence_get returns an array

#3 Post by JackZ »

Corjan wrote: Fri Aug 21, 2020 6:41 pm Hi,


From AM 3.7 I think the type is not used anymore. It is still there for backwards compatibility.
You can basically throw anything into a persistence object, and you will get exactly the same thing back.

That does mean that you are responsible as the instrument builder to be able to deal with type changes.


Corjan
Thnaks Corjan, but during the development process, the type of data has changed, so the persist_add() should overwrite the file written on the disk with the new value, am I correct?
I managed to deal with by changing the name of the persistence in the persist_add(), basically creating a new file, but that is a weird behaviour, and that means that there is still the old persistence file somewhere on my hard disk, hence the question about its location, so I can delete it.
I thought the persistence file should be located within the instrument folder to avoid name confilcts?

Jacques
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

User avatar
Corjan
Posts: 2939
Joined: Thu Nov 19, 2015 9:04 am

Re: Persistence_get returns an array

#4 Post by Corjan »

Hi,


You can do another persist_put with the correct type to fix it.

The type is not used internally anymore, so it won't reset the data ever.
This is also as designed, so you can 'upgrade' the persistence data once it changes between instrument versions.


Corjan

User avatar
Sling
Posts: 5239
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Persistence_get returns an array

#5 Post by Sling »

You can also find and delete the existing persistence file for that instrument or just clear persistence from the settings tab to delete them all. It really depends on how much other stuff you have that you want to retain the persistence for.

The individual persistence files can be found at Air manager/persistence/instruments or instrument_plugin.

Tony

JackZ
Posts: 2267
Joined: Mon Feb 22, 2016 1:02 pm

Re: Persistence_get returns an array

#6 Post by JackZ »

Sling wrote: Fri Aug 21, 2020 11:48 pm You can also find and delete the existing persistence file for that instrument or just clear persistence from the settings tab to delete them all. It really depends on how much other stuff you have that you want to retain the persistence for.

The individual persistence files can be found at Air manager/persistence/instruments or instrument_plugin.

Tony
Thanks Tony, exactly what I was looking for!
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

Post Reply