populating a menu in user_prop_add_enum()

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

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

populating a menu in user_prop_add_enum()

#1 Post by JackZ »

Hello all.

I am trying to setup a user property in a menu form by populating a table, then creating a long string out of it and using this string as a list of choices in user_prop_add_enum(), but to no avail.
Pulling my hair on this one, can you point me to where I made a mistake?
I don't have any error message, but the menu is not populated, except for the explicitly described default value
in choice_prop = user_prop_add_enum("Event", lestring, "ZOOM_OUT", "You can choose one of these Events")
Or does that mean that user_prop_menu() does not allow this?

The table is properly populated, so this is NOT a csv issue.
The string lestring seems correct when printed, but is not used in the user_prop() function

Code: Select all

-- liste des events.csv is location in the resources folder
data = static_data_load("liste des events.csv", "csv_header=true")
events={}
lestring=" " -- String of available events
if data ~= nil then
 
  for key,value in pairs(data) do
    print(key.." "..value["Events"]) -- verification purpose
    events[key]=value["Events"]
    lestring=lestring..","..(events[key])
  end
end
print(lestring)  -- verification purpose, the string is correctly completed ?????
choice_prop = user_prop_add_enum("Event", lestring, "ZOOM_OUT", "You can choose one of these Events")
Thank you in advance

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

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: populating a menu in user_prop_add_enum()

#2 Post by Keith Baxter »

Cousin Jacques, what you want cannot be done.

The table has to be declared at runtime. Not loaded as a static data csv, .json or text file which contents are not available at run time.

This has been discussed here some time back.
Put your data as a table and it will work. Not as static data.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

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

Re: populating a menu in user_prop_add_enum()

#3 Post by JackZ »

@Keith Baxter Hmm that’s weird because I used synchronous loading at runtime and the string “le string” appears to be created, since I can print it. And from my code above, I create first a table populated with the csv file, THEN create the string “lestring” from this table.

I simply cannot use this string subsequently as a parameter in user_prop_add_enum(), I don’t know why
Last edited by JackZ on Sun May 28, 2023 8:36 pm, edited 2 times in total.
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: populating a menu in user_prop_add_enum()

#4 Post by Keith Baxter »

JackZ wrote: Sun May 28, 2023 8:03 pm @Keith Baxter Hmm that’s weird because I used synchronous loading at runtime and the string “le string” appears to be created, since I can print it.

I simply cannot use this string subsequently as a parameter in user_prop_add_enum(), I don’t know why
Put your table in the script.

my_table = {"Help", "No help", " ", " ", " ", " "}

And it will work.
Do not load as static data for user prop.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

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

Re: populating a menu in user_prop_add_enum()

#5 Post by JackZ »

@Keith Baxter Seems you are right. Just tested with a prepopulated table (1784 items) and the menu appears right away. I learned a new trick. Thanks!
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: populating a menu in user_prop_add_enum()

#6 Post by Keith Baxter »

JackZ wrote: Sun May 28, 2023 8:36 pm @Keith Baxter Seems you are right. Just tested with a prepopulated table (1784 items) and the menu appears right away. I learned a new trick. Thanks!
Jacques,

No problems cousin. Glad I could assist.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

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

Re: populating a menu in user_prop_add_enum()

#7 Post by Sling »

The reason it’s like this is because user properties are pre scanned before running the instrument so they are available for setting prior to the instrument being run. So as Keith says the data for user property population has to be there immediately without any code having to run first. I’ve had similar needs for generation of a user property like this in the past but sadly it’s not possible with the pre scan. I guess it could work if Corjan could add in say a specific api function that if present is run as part of the pre-scan.

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

Re: populating a menu in user_prop_add_enum()

#8 Post by JackZ »

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

Post Reply