The heart of Dynamic Menu is the script that populates the repeating fields with the names of the layouts.

#_________________________________________clear menu
Set Variable [ $MenuCount; Value:60 ]
Set Variable [ $MenuNo; Value:1 ]
Loop
 Set Field [ !menu::menu[$MenuNo]; "" ]
 Exit Loop If [ $MenuNo = $MenuCount ]
 Set Variable [ $MenuNo; Value:$MenuNo+1 ]
End Loop
#_________________________________________set defaults
Set Variable [ $LayList; Value:LayoutNames("DynamicMenu") ]
Set Variable [ $LayCount; Value:ValueCount($LayList) ]
Set Variable [ $LayNo; Value:1 ]
Set Variable [ $LayCurrent; Value:GetValue($LayList; $LayNo) ]
Set Variable [ $LayCurrentMask; Value:Left($LayCurrent; 1) ]
If [ Get(CurrentPrivilegeSetName)="[Full Access]" ]
 Set Variable [ $Masks;Value:"0¶1¶2¶3¶4¶5¶6¶7¶8¶9¶~¶`¶!¶@¶#¶$¶%¶^¶&¶*¶(¶)¶_¶=¶+¶[¶]¶}¶¶|¶;¶:¶'¶,¶<¶.¶>¶/¶?" ]
Else
 Set Variable [ $Masks;Value:"0¶1¶2¶3¶4¶5¶6¶7¶8¶9¶~¶`¶!¶@¶#¶$¶%¶^¶&¶*¶(¶)¶_¶=¶+¶[¶]¶}¶¶|¶;¶:¶'¶,¶<¶.¶>¶/¶?¶{" ]
End If
Set Variable [ $MaskCount; Value:ValueCount($Masks) ]
Set Variable [ $MaskNo; Value:1 ]
Set Variable [ $MaskCurrent; Value:GetValue($Masks; $MaskNo) ]
Set Variable [ $MenNo; Value:1 ]
#_________________________________________start building the menu
Loop
 Set Variable [ $LayCurrent; Value:GetValue($LayList; $LayNo) ]
 Set Variable [ $LayCurrentMask; Value:Left($LayCurrent; 1) ]
 Set Variable [ $MenCurrent; Value:GetValue($LayList; $LayNo) ]
 Set Variable [ $MaskNo; Value:1 ]
#_________________________________________
  Loop
   Set Variable [ $HideLayout; Value:0 ]
   Set Variable [ $MaskCurrent; Value:GetValue($Masks; $MaskNo) ]
   If [ $LayCurrentMask = $MaskCurrent ]
    Set Variable [ $HideLayout; Value:1 ]
   End If
 Exit Loop If [ $MaskNo = $MaskCount or $LayCurrentMask =$MaskCurrent ]
 Set Variable [ $MaskNo; Value:$MaskNo+1 ]
 End Loop
#_________________________________________
  If [ $HideLayout=0 ]
   Set Field [ !menu::menu[$MenNo]; $MenCurrent ]
   Set Variable [ $MenNo; Value:$MenNo+1 ]
  End If
Exit Loop If [ $LayNo = $LayCount ]
Set Variable [ $LayNo; Value:$LayNo+1 ]
End Loop