Homepage › Clovertech Forums › Cloverleaf › Can we get a list of Global Variable Keys in Tcl?
- This topic has 16 replies, 6 voices, and was last updated 2 months, 3 weeks ago by
Jim Kosloskey.
-
CreatorTopic
-
May 1, 2023 at 3:43 pm #120522
Jim Kosloskey
ParticipantCloverleaf 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.
-
CreatorTopic
-
AuthorReplies
-
-
May 1, 2023 at 4:02 pm #120523
Jay Hammond
ParticipantDoes 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, 4 months ago by
Jay Hammond.
-
This reply was modified 1 year, 4 months ago by
Jay Hammond.
-
This reply was modified 1 year, 4 months ago by
Jay Hammond.
-
This reply was modified 1 year, 4 months ago by
-
May 1, 2023 at 4:24 pm #120527
Jim Kosloskey
ParticipantThat did it – thanks Jay.
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
-
May 1, 2023 at 5:01 pm #120528
Jeff Dinsmore
ParticipantInteresting.
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 -
May 1, 2023 at 5:19 pm #120529
Jim Kosloskey
ParticipantI 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.
-
May 1, 2023 at 10:13 pm #120530
Charlie Bursell
ParticipantStrange 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 = 0tcl> info globals Hci*
HciSiteDir HciRoot HciSite HciProcessesDir HciMasterSiteDir HciMasterSite HciRootDir -
May 2, 2023 at 8:50 am #120531
Jim Kosloskey
ParticipantInteresting, 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.
-
May 2, 2023 at 10:21 am #120532
Jeff Dinsmore
ParticipantAnd, 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 -
May 2, 2023 at 11:08 am #120533
Jim Kosloskey
ParticipantJeff – 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.
-
May 2, 2023 at 10:30 pm #120534
Charlie Bursell
ParticipantI 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
-
May 3, 2023 at 12:56 pm #120536
Jim Kosloskey
ParticipantI 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.
-
June 7, 2024 at 11:04 am #121462
Feda Birani
ParticipantJim,
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?
-
June 7, 2024 at 11:41 am #121463
Jim Kosloskey
ParticipantFreda,
email me and we can discuss this off-line.
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
-
May 3, 2023 at 1:03 pm #120537
Jeff Dinsmore
ParticipantI 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 -
May 3, 2023 at 1:09 pm #120538
Jim Kosloskey
ParticipantJeff,
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.
-
June 12, 2024 at 3:49 am #121481
jianasingh
ParticipantWhat is TCL?
-
This reply was modified 2 months, 3 weeks ago by
jianasingh.
-
This reply was modified 2 months, 3 weeks ago by
-
June 12, 2024 at 9:15 am #121483
Jim Kosloskey
ParticipantTcl Developer Site (tcl-lang.org)
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
-
-
AuthorReplies
- You must be logged in to reply to this topic.