Extracting a Lua menu item - General Help and Assistance on using CHDK stable releases - CHDK Forum  

Extracting a Lua menu item

  • 7 Replies
  • 2476 Views
Extracting a Lua menu item
« on: 18 / June / 2022, 13:06:42 »
Advertisements
@reyalp

I have the following in my script

Code: [Select]
#mode = 0 "Focus?" {Off X2INF Min2INF Manual Min2X SupRes}

I wish to access the text associated with a menu item, eg 1 above is “X2INF”, but I can’t work out how.

Hope you can help.

Cheers

Garry

*

Offline Caefix

  • *****
  • 947
  • Sorry, busy deleting test shots...
Re: Extracting a Lua menu item
« Reply #1 on: 18 / June / 2022, 13:22:52 »
Here need to copy headerline to a Lua string-table and access via print(tab[mode+1])  :)
« Last Edit: 18 / June / 2022, 13:38:00 by Caefix »
All lifetime is a loan from eternity.

Re: Extracting a Lua menu item
« Reply #2 on: 18 / June / 2022, 13:36:30 »
@Caefix

Yes, I know I can fudge it, but I thought there may be a hidden way of getting direct access ;-)

*

Offline Caefix

  • *****
  • 947
  • Sorry, busy deleting test shots...
Re: Extracting a Lua menu item
« Reply #3 on: 18 / June / 2022, 13:46:55 »
 ;) ... The header is parsed in core/gui_script.c, different area...
All lifetime is a loan from eternity.


Re: Extracting a Lua menu item
« Reply #4 on: 18 / June / 2022, 14:06:00 »
;) ... The header is parsed in core/gui_script.c, different area...

Maybe another request for @reyalp Lua additions, ie get the text value of a Lua menu item  ;)

*

Offline reyalp

  • ******
  • 14121
Re: Extracting a Lua menu item
« Reply #5 on: 18 / June / 2022, 14:12:33 »
I have the following in my script

Code: [Select]
#mode = 0 "Focus?" {Off X2INF Min2INF Manual Min2X SupRes}

I wish to access the text associated with a menu item, eg 1 above is “X2INF”, but I can’t work out how.
Use the table option, like
Code: [Select]
#mode = 0 "Focus?" {Off X2INF Min2INF Manual Min2X SupRes} table
Then you can access the string with mode.value. You can also access the index with mode.index. Note .index is one based, unlike items created without the table option. See https://chdk.fandom.com/wiki/CHDK_Script_Header
Don't forget what the H stands for.

Re: Extracting a Lua menu item
« Reply #6 on: 18 / June / 2022, 14:22:37 »
I have the following in my script

Code: [Select]
#mode = 0 "Focus?" {Off X2INF Min2INF Manual Min2X SupRes}

I wish to access the text associated with a menu item, eg 1 above is “X2INF”, but I can’t work out how.
Use the table option, like
Code: [Select]
#mode = 0 "Focus?" {Off X2INF Min2INF Manual Min2X SupRes} table
Then you can access the string with mode.value. You can also access the index with mode.index. Note .index is one based, unlike items created without the table option. See https://chdk.fandom.com/wiki/CHDK_Script_Header

Many thanks :-)

*

Offline Caefix

  • *****
  • 947
  • Sorry, busy deleting test shots...
Re: Extracting a Lua menu item
« Reply #7 on: 18 / June / 2022, 14:48:57 »
All lifetime is a loan from eternity.


 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal