Can we get a list of Global Variable Keys in Tcl?

Clovertech Forums Cloverleaf Can we get a list of Global Variable Keys in Tcl?

  • Creator
    Topic
  • #120522
    Jim Kosloskey
    Participant

      Cloverleaf 2209, Windows.

      I am doing some work with Global Variables for the first time.

      I am wondering if there is a way to get a list of all of the Global Variable Keys that exist in the table?

      I don’t see anything that pops out to me in the Documentation.

      email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

    Viewing 13 reply threads
    • Author
      Replies
      • #120523
        Jay Hammond
        Participant

          Does this get what you’re looking for:

           

          hcigvt
          This command is used to access the global variables.

          hcigvt {add|del|get|set|show} [varname] [varvalue] [isencrypted]
          add – adds the global variable to the variable table.
          del – deletes the global variable name from the variable table.
          get – prints the global variable value of varname.
          set – sets the global variable value of varname to a new value.
          show – shows all the variable names and values in local site.
          varname is the global variable name.
          varvalue is the global variable value.
          isencrypted determines if the global variable must be encrypted in the ini file.
          1 indicates it is encrypted.
          0 indicates it is not encrypted. This is the default.
          For example:

          C:\cloverleaf\cis6.3\integrator\bin>hcigvt show

          • This reply was modified 1 year, 7 months ago by Jay Hammond.
          • This reply was modified 1 year, 7 months ago by Jay Hammond.
          • This reply was modified 1 year, 7 months ago by Jay Hammond.
        • #120527
          Jim Kosloskey
          Participant

            That did it – thanks Jay.

            email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

          • #120528
            Jeff Dinsmore
            Participant

              Interesting.

              I’ve not seen this command before.

              How does this differ from using Tcl’s regular global variables?

              Thanks,
              Jeff.

              Jeff Dinsmore
              Chesapeake Regional Healthcare

            • #120529
              Jim Kosloskey
              Participant

                I have noted this command dumps the Global Variables .ini file not the in-memory Table.

                As well, it is not a list but a string with I think end of line or carriage control at the end of each line.

                I will need to manipulate the dump some to convert it to a searchable list.

                Perhaps this only works against the .ini file and not the in-memory Table, whereas the Tcl extensions address the in-memory table and not the .ini file.

                I am finding that when I add an entry using the Tcl extensions in a UPoC, the in-memory Table is affected but the .ini is not. If I want my addition to be preserved then it appears I need to do a gvsave to save the in-memory table to the .ini file (then it is also visible in the GUI).

                 

                email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

              • #120530
                Charlie Bursell
                Participant

                  Strange that hcigvt does not show ALL of the hci globals.

                  hcigvt show
                  HCIROOT = C:\cloverleaf\cis2022.09\integrator, encrypt = 0
                  HCISITE = charlieb, encrypt = 0
                  HCISITEDIR = C:\cloverleaf\cis2022.09\integrator\charlieb, encrypt = 0

                  tcl> info globals Hci*
                  HciSiteDir HciRoot HciSite HciProcessesDir HciMasterSiteDir HciMasterSite HciRootDir

                • #120531
                  Jim Kosloskey
                  Participant

                    Interesting, I get more when I do hcigvt:

                    C:\cloverleaf\cis2022.09\integrator\test_jim>hcitcl
                    hcitcl>hcigvt show
                    HCIROOT = C:\cloverleaf\cis2022.09\integrator, encrypt = 0
                    HCISITE = test_jim, encrypt = 0
                    HCISITEDIR = C:\cloverleaf\cis2022.09\integrator\test_jim, encrypt = 0
                    HCIMASTERSITE = master, encrypt = 0
                    HCIMASTERSITEDIR = C:\cloverleaf\cis2022.09\integrator\master, encrypt = 0
                    From master site:
                    HCIROOT = C:\cloverleaf\cis2022.09\integrator, encrypt = 0
                    HCISITE = master, encrypt = 0
                    HCISITEDIR = C:\cloverleaf\cis2022.09\integrator\master, encrypt = 0
                    hcitcl>

                    email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

                  • #120532
                    Jeff Dinsmore
                    Participant

                      And, interesting that I get less…

                      hcitcl>hcigvt show
                      Global variable is empty!

                      I must admit I’ve not used this command at all, but rather read from shell variables – mostly the global variable env for HCI-specific values like $env(HCIROOT)

                      Back to the original post… Jim – what is it that you’re after here?

                       

                       

                       

                       

                       

                       

                       

                      Jeff Dinsmore
                      Chesapeake Regional Healthcare

                    • #120533
                      Jim Kosloskey
                      Participant

                        Jeff – I am in need of checking to see if a GV Key exists to know whether to change the value for the key (it can change with the integration I am building) or add the key and value.

                        I have found out I can do the gvgetvar Tcl command and if that returns a value the key exists. That is because one cannot have an empty (null) value for a key. That then tells me the key exists.

                        However, I can see a potential need to be able to search the GV table for a specific or range of keys.

                        Unfortunately, the hcigvt command only works on the .ini file. There is no such facility for the in-memory table. The two tables can be different. A modification to the in-memory table does not commit to the .ini file automatically.

                        I think there could be a use for something like a gvshowkeys Tcl command.

                        I have some other observations which I think could be enhancement requests. I will post those separately once I have all of them collected so I can add a poll as well.

                         

                        email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

                      • #120534
                        Charlie Bursell
                        Participant

                          I guess my question would be:  When are these variables added to the global namespace?

                          I added a global using hcigvt and ran Tcl from the command line and the global did not show up using the info globals command.

                          Other than possibly a need for an encrypted global like passwords, etc. What are the benefits of this command?  It is so easy to set any global you want just by setting a variable in the global namespace, i.e.,  set ::myglobal foo,  echo $::myglobal

                          Maybe I am missing something and there are other uses that I am not aware of.  The documentation is not that enlightening

                           

                        • #120536
                          Jim Kosloskey
                          Participant

                            I am not sure they are added to the global namespace. I think that in what appears to be some instances (mine for example) they happen to match because they are placed in GV at perhaps engine startup.

                            What I am doing now for me is experimenting with this feature to see how it is used. Prospective use cases could grow out of this effort.

                            For this particular experiment I am using the GV as a repository for a value which needs to transcend engine shutdown and startup. I expecting to discover if that is true as part of this experiment.

                            In doing this I have discovered:

                            • There are really 2 GV repositories: the .ini file and in-memory.
                            • The Tcl command ONLY work on the in-memory table (with the exception of the save function).
                            • The hcigvt command only works on the .ini file.
                            • There does not appear to be a Tcl method to commit changes of the in-memory GV to the .ini.
                              • There is a save Tcl function but that saves the in-memory to .ini in total. Not something I would do without a lot of planning.
                              • One could use the hcigvt command along with the Tcl get command to save a particular in-memory entry to the .ini and this is what I am doing in this experiment. But I think it would be much better if there was a granular function in the Tcl set.
                            • I suspect, but have not confirmed, that the in-memory GV gets set in total from the .ini at engine startup.
                            • I have not investigated if there is any other way to get the in-memory reset to the .ini within the toolset other than perhaps using Tcl.
                            • One can reset the .ini with the in-memory values as I indicated earlier by using the Tcl GV save function.

                            I will try to update this post with any other discoveries I make.

                            I really am looking forward to folks who have more experience than I do with GV to contribute their experiences and knowledge here. Including your use cases.

                            I am just trying to come to a better understanding of how GV works.

                            email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

                            • #121462
                              Feda Birani
                              Participant

                                Jim,

                                I’ve started to look at Global Variables and a bit stumped. From your investigation I now know there is 2 options,  in-memory and .ini. I thought and now not sure, I was using .ini all along.  I’m trying to store the newest token in the .ini. I do this by changing what is originally in the .ini (manually added) by doing the following

                                [gvdelvar token]

                                gvsave

                                [gvaddvar token $token] (notice not using $$prefix – still uncertain what $$prefix does. Is this used for in memory?)

                                gvsave

                                This works and I see the .ini get updated when i open the gui tool.

                                However, my issue is now trying to read what I’ve put in  [hcigetvar token] on the reply tcl (diff tcl then where i added to .ini).  Says variable not found.  This makes me think it’s something to do with memory because I’m able to do [hcigetvar token] successfully, if i put it in the same tcl I added it.  I feel like I’m not understanding something.

                                How do you use the in memory, not ini and at what point do you loose what’s in memory?

                                How do you add/update & get from the .ini. I’m using the site gv.ini not master site, so assuming no other site would be affected, only what sits in this one site. Also, did you find any slowness when GV was used?

                              • #121463
                                Jim Kosloskey
                                Participant

                                  Freda,

                                  email me and we can discuss this off-line.

                                  email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

                              • #120537
                                Jeff Dinsmore
                                Participant

                                  I hate to spoil your fun, Jim, but this sounds more complex/uncertain than it needs to be.

                                  Why not just use a regular file or SQLite (or other) DB?

                                  Jeff Dinsmore
                                  Chesapeake Regional Healthcare

                                • #120538
                                  Jim Kosloskey
                                  Participant

                                    Jeff,

                                    This is a learning experiment to find out how this works. Once I am aware of the ins and outs, I can know how well it is likely to fit for various scenarios.

                                    I do not have a project waiting to be finished or a strict time line. This is just me poking around.

                                    I already know how to do the various other methods and their use cases. I am trying to build some additional knowledge.

                                    I am also experimenting with other tools in Cloverleaf with which I am unfamiliar.

                                    email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

                                  • #121481
                                    jianasingh
                                    Participant

                                      What is TCL?

                                      • This reply was modified 6 months, 1 week ago by jianasingh.
                                    • #121483
                                      Jim Kosloskey
                                      Participant

                                        Tcl Developer Site (tcl-lang.org)

                                         

                                        email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

                                    Viewing 13 reply threads
                                    • You must be logged in to reply to this topic.