Easy way to retrieve specified string from choice argument for G'MIC GUI script? [Solved]

Given this code:

#@gui:1.Section=choice(1,"Gray","Color")
#@gui:2.Section=choice(0,"Gray","Alpha")
#@gui:3.Section=choice(0,"Color","Alpha")
#@gui:4.Section=choice(0,"Gray","Color","Alpha")
#@gui:5.Section=choice(1,"Gray","CMY")
#@gui:6.Section=choice(1,"Gray","CMYK")
#@gui:7.Section=choice(0,"CMY","Alpha")
#@gui:8.Section=choice(0,"CMYK","Alpha")
#@gui:9.Section=choice(1,"Gray","CMY","Alpha")
#@gui:10.Section=choice(1,"Gray","CMYK","Alpha")
#@gui:11.Section to use=int(1,1,10)

How would I retrieve the lower-case version of chosen string within choice. Note the “Section to use”, so, I would like to retrieve only the selected one.

It would be easier if G’MIC GUI plugin can have something like text_choice to choose string instead of number, but it does not exist.

Something like this is what I thought off:

  $=arg
  section_space=${arg\ $section_to_use,"gray,color","gray,alpha","color,alpha","gray,color,alpha","gray,cmy","gray,cmyk","cmy,alpha","cmyk,alpha","gray,cmy,alpha","gray,cmyk,alpha"}
  selection_of_section_space=${arg$section_to_use}
  section_space=${arg\ $selection_of_section_space+1,$section_space}

And I had to create this part via Python REPR to avoid doing it by hand.

"gray,color","gray,alpha","color,alpha","gray,color,alpha","gray,cmy","gray,cmyk","cmy,alpha","cmyk,alpha","gray,cmy,alpha","gray,cmyk,alpha"

Does this help?

foo: -skip ${1='I\ AM\ UPPERCASE'}
   echo {`lowercase(['$1'])`}

where $-expressions like $1 are returning unaltered, chosen string options from the GUI choose() UI function, and these are mixed-case, as presented in the UI.

gmic -m foo.gmic foo CMYK
[gmic]./ Start G'MIC interpreter (v.3.3.4).
[gmic]./ Import commands from file 'foo.gmic', with debug info (1 new, total: 4736).
cmyk
[gmic]./ End G'MIC interpreter.

No. That only tells me how to make lowercase option. Now coming to think of it, text_choice is a bad idea as I plan to support multiple languages in the future. It seems that there’s a pattern to section, and I think a easy solution exists, but it’s pretty hard to find one other than if elif etc which I don’t want to do. For now, my current solution seems to be the easiest approach, and it’s terrible looking.

Also did this as an attempt, but hard to read:

rep_section_space:
# $1 == Select Space section
if $1==1 u gray,alpha
else
 id,level_1_pos,level_2_text={id=$1-($1>1);l1=id<3?id:(id-3)>>1;l2=id>2?(!(id&1)+1);[id,l1,l2]}
 ct_text={`('colorcmyk')[$level_2_text?5,$level_2_text?2+$level_2_text:5]`}
 if $level_1_pos==2   u gray,$ct_text,alpha
 elif $level_1_pos==1 u $ct_text,alpha
 else                 u gray,$ct_text
 fi
fi
C:\Windows\System32>gmic repeat 10 { echo ${rep_section_space\ $">"} }
[gmic]./ Start G'MIC interpreter (v.3.3.4).
gray,color
gray,alpha
color,alpha
gray,color,alpha
gray,cmy
gray,cmyk
cmy,alpha
cmyk,alpha
gray,cmy,alpha
gray,cmyk,alpha

I figured out a solution within context of the larger code.

This will work out:

# ... Code Block here ...

if narg($_persistent)

 _gui_analysis_gray,_gui_analysis_color,_gui_analysis_alpha=${3-5}
 use_section,section_variable,use_link,link_visiblity=$16,$17,$64,$65
 stored_variables=$69
 
 if $use_section
  if $section_variable==1 section_space=gray,alpha
  else
  
   if $cmyk_mode ct_text={`('cmyk')[0,3+$2]]`} else ct_text=color fi
   
   if $section_variable==3   section_space=gray,$ct_text,alpha
   elif $section_variable==2 section_space=$ct_text,alpha
   else                      section_space=gray,$ct_text
   fi
   
  fi
 fi
 
else

 eval "
  const num_of_imgs=$!;
  contain_gray=contain_color=contain_alpha=0;
  repeat(num_of_imgs,p,
   current_spec_size=s#p;
   if(!contain_gray?current_spec_size<3,contain_gray=1;);
   if(!contain_color?current_spec_size>2,contain_color=1;);
   if(!contain_alpha?current_spec_size==2||current_spec_size>3,contain_alpha=1;);
   if(contain_gray&&contain_color,
    if(contain_alpha,break(););
   );
  );
  set('_gui_analysis_color',contain_color;);
  [contain_gray,contain_alpha];
  "
 _gui_analysis_gray,_gui_analysis_alpha=${}
  
 use_section:=sum($_gui_analysis_gray,$_gui_analysis_color,$_gui_analysis_alpha)>1
 if $use_section
  section_list=section_gray_color,section_gray_alpha,section_color_alpha,section_gray_color_alpha
  $section_list:=expr('x',narg($section_list))
  temp_section=section
  
  if $_gui_analysis_gray
   temp_section.=_gray
  fi
  
  if $_gui_analysis_color
   temp_section.=_color
  fi
  
  if $_gui_analysis_alpha
   temp_section.=_alpha
  fi
  
  section_variable=${$temp_section}
  
  if $section_variable==1 section_space=gray,alpha
  else
  
   if $cmyk_mode ct_text={`('cmyk')[0,3+$2]`} else ct_text=color fi
   
   if $section_variable==3   section_space=gray,$ct_text,alpha
   elif $section_variable==2 section_space=$ct_text,alpha
   else                      section_space=gray,$ct_text
   fi
   
  fi
  
 fi
 
 link_visiblity=$_gui_analysis_color?2:1
 if $link_visiblity==1 use_link=0 fi
 
fi

# ... Code Block here ...

section_space=${arg\ ${arg{$temp_section_variable+6}}+1,$section_space}

Here section_space correspond to lower case string representation of one of the Section GUI element.