cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2445
Views
0
Helpful
8
Replies

EMM (emb. menu mngr) dynamic lists with TCL

Hi, I hope this is the right forum section for this post..

I've been trying to build a dynamic EMM interface where I have a folder structure on an USB-stick and I'd like to be able to browse this folder structure. I've gotten to the point where I can dynamicly build the first step of the structure and represent it to the user via EMM but when I make the choise of which sub-folder to view I come across some problems..

For the first layer of folder I'm using a Wizard with ChoiceList and have TCL figure out the options for sub-folders, for the next step I thought I could use the $r -array that is supposed to have the answers for the Wizards and get the previous selection from it to represent the next layer of folders in the following Wizard.

The problem that I have, is that the $r-array doesn't seem to contain anything before entering the EmbeddedTCL + TCLCommand phase.. which comes after the Wizards... so I'd like to be able to use the selection of the first Wizard to affect the outcome of the second, but unable to do so... I've tested for the $r-array in the second Wizard and it does not exists, but if I replace the second Wizard with EmbeddedTCL + TCLCommand the array does exists..

Any ideas what I'm doing wrong or if this is working as intended?

Pseudo-version of code:

Menu

Item

  Wizard

    ChoiceList + TCLCommand

  Wizard

     array $r(1) does not exists!

  EmbeddedTCL + TCLCommand

     array $r(1) does exist!

8 Replies 8

Joe Clarke
Cisco Employee
Cisco Employee

The $r array is Tcl code, and thus is only available in Tcl sections of the EMM MDF (e.g., EmbeddedTCL, IOSConfigCommand, etc.).  ChoiceList is also a Tcl container, so you should be able to (within an Item) access the $r array within it.  It's hard to know the exact problem, though, without seeing the real code.

I will post the full code tomorrow, but if I recall correctly, I tried doing info exists $r(1) within ChoiceList + TCLCommand inside the second Wizard Item and it returned 0, if I did the info exists in EmbeddedTCL after the wizard it returned 1.

Here the code that I'm using. If you try it, the $r(1) doesn't exists in the second wizard, but if you remove the second wizard, the $r(1) does exist inside the EmbeddedTCL

MenuName="Test" schemaVersion="1.1">

 

 

    proc wsplit {str sep} {

      split [string map [list $sep \0] $str] \0

    }

    proc test_var {varname} {

      return [info exists $varname]

    }

 

 

   

 

 

   

 

  "show ver | i bin"

 

 

 

 

    set List [list]

    set folders [glob -directory "usbflash0:/" -type d *]

    foreach line [wsplit $folders "usbflash0"] {

        set folder ""

      regexp {\/([\w\s]+)} $line null folder

      if {$folder != ""} {

        append List ",$folder"

      }

    }

    return [string trimright $List ","]

 

   

 

 

 

 

    #puts "r1 exists in second wizard: [info exists r(1)]"

 

   

 

 

      puts "r1 exists in Ebmedded TCL after wizard: [info exists r(1)]"

 

 

   

 

This may be a bug.  To confirm, in the next Wizard's EmbeddedTCL block, does the value of $r(1) equal that of the first Wizard's choice?

Ok, I modified the code a little to test this:

MenuName="Test" schemaVersion="1.1">





proc wsplit {str sep} {
split [string map [list $sep \0] $str] \0
}
proc test_var {varname} {
return [info exists $varname]
}








"show ver | i bin"





set List [list]
set folders [glob -directory "usbflash0:/" -type d *]
foreach line [wsplit $folders "usbflash0"] {
set folder ""
regexp {\/([\w\s]+)} $line null folder
if {$folder != ""} {
append List ",$folder"
}
}
return [string trimright $List ","]





puts "Does r1 exists in second wizard: [info exists r(1)]"
return "folder a,folder b"



puts "Does r1 exists in Embedded TCL after wizard: [info exists r(1)]"
if {[info exists r(1)]==1} {
puts "wizard 1: $r(1) wizard 2: $r(2)"
}









And here are the results (as you can see, the subfolders are defined staticly and not dynamicly at this point):

Step1

>Selected 2

Step2

>Selected 1

Step3

>Selected 1

Step4

As you can see, $r(1) doesn't exist within the second wizard..

This looks like a bug to me.  I recommend you open a TAC case to report this.  That said, EMM is end of life, so this may not be addressed.  I know it's not ideal, but you might want to look at building a menu in straight Tcl instead.  This will give you a lot more control over the formatting at the expense of some of the niceties like help and the wizards.

Ouch, EOL doesn't sound good for my project... I actually started with plain TCL, but wasn't able to clear the terminal screen, I saw some posts about it around the web, but nothing seemed to work and then I remember reading about EMM at some point in the past..

Well I guess I'll try opening a TAC, if that doesn't work I'll just have to build my own equivalent of EMM then..

Take a look at my EASy Install.  I made a poor-man's menu for that in pure Tcl.

https://supportforums.cisco.com/docs/DOC-24228

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Innovations in Cisco Full Stack Observability - A new webinar from Cisco