reference,tcl,expect,evaluation , Quickest way to evaluate a variable in TCL

Quickest way to evaluate a variable in TCL


Tag: reference,tcl,expect,evaluation

I have a variable myref set to:

set myref {$expect_out(buffer)}

What is the quickest way to get the $expect_out(buffer) into myval?

set myval [HOWTOEVAL $myref]


If you have a string containing just the name of a variable, you are best off using set with only a single argument:

set myref {expect_out(buffer)}
puts "The value is [set $myref]"

But if you've got that $ as well, the right thing to do is to use subst (which means “pretend this was something in double quotes”):

set myref {$expect_out(buffer)}
puts "The value is [subst $myref]"

Pick the right one for what you've got.


No Such Variable When Using While Loop in Expect

I'm attempting to access a variable within a while loop in expect, but I keep getting an error that the variable doesn't exist. The code in question: #!/usr/bin/expect spawn ./ set timeout 1 ...<extra code>... # Return the time in seconds from epoch proc getTime {year month day hour minute}...

(Dangling?) Reference returned from function does not “work”

I followed V. Romeo's Tutorial on entity management (on GitHub & Youtube). I then tried to rewrite the classes CEntity, CComponent and for testing CPosition(mostly from memory from Romeo's video/code). The problem i encounter is that, in my main i create a CEntity on the stack & add a component....

Cannot evaluating variable within IF and For loop using TCL

In following code in TCL I cannot seem evaluate the variable "a" I'm evaluating x and y, in the same For Loop I have a IF statement that is checking for a range between x and y. If valid then I'd like to perform some more calculations within the IF...

passing arguments via reference and pointer C++

I am looking at a code snippet and I have this sequence. class MyVariable { .... CustomType z; .... } A.cpp calling a function f ( & myVariable) In an included file I do have this : B.h void f ( MyVariable * myVariable); B.cpp f( MyVariable * myVariable){ CustomType...

Assign a reference return value to a non-reference variable

class A { ... }; A& getA(); A anA = getA(); What happens exactly on line 3 ? Is the copy constructor of A called, thus creating an object independent from the one returned (by reference) by the function?...

Sublists in a 2D List, Referencing

I have a 2D List of objects. I'm trying to access a list and replace it with a sublist of itself. I made up a simple example below, I want to replace dList.get(0) with dList.get(0).subList(1,3). I use a reference variable, which updates the values in the original list, but the...

How do I print more than one value per key in Tcl?

array set array_in_twos { set1 table set2 chair set1 chair } foreach combo [array names array_in_twos] { puts "$combo is $array_in_twos($combo)," } outputs: set1 is chair, set2 is chair, It seems the second 'set 1' replaces the first 'set 1'. how do i print all? set1 is table, set2 is...

Chain linked classes

I have created long chains of classes, with each link(class) knowing only the next and previous link. I see great advantage over Arrays when the index is not important. public class ChainLink { public ChainLink previousLink, nextLink; // Accessors here } Questions : What is this technique actually called? (I...

Wrong Theme being applied to PreferenceActivity with xml reference

I seem to have a problem implementing a theme onto a PreferenceActivity when i am using an XML reference to refer to said theme. I have 3 style.xml´s style.xml style.xml (v16) style.xml (v21) each of these in its appropriate values directory. To apply the theme, i reference it in my...

return reference of static member variable c++

Is there any problem to return a reference of a static member variable? (Reference to avoid copy cost) Vector accepts 4 parameters(x,y,z,w); .h class MyClass { private: static const Vector POS; } .cpp const Vector MyClass::POS(100,300,0,0); const Vector& MyClass::GetVector() { return POS; } ...

tablelist label color while mouse hovers

I've configured the background color of some lables of my tablelist by using the columnconfigure $ColumnIndex -labelbgmethod. However, the background color changes while the mouse hovers over the labels. I couldn't find any -activebackground method and I wish the background color will stay the same even when the mouse hovers...

Parameters to use in a referenced function c++

I am very confused as to what kind of variables I would put into my function here: names. I am doing a practice problem in a C++ book, because I am learning C++ and am on References and pointers right now, and cannot find a solution. Just for background information,...

Watching a variable in python?

In C++, I could imagine constructing with a reference to a counter ( see below ), and then a function would just dereference the address to get a value. Is something similar possible in python? Something like: import time class Count_Watcher: def __init__( self, to_watch ): self.to_watch = to_watch sleep_watch()...

Return type of list front (C++)

So I want to use a list for a part of my program. I'm trying to get acquainted to the library list, so I wrote a quick little program to help myself understand what's going on. It all works properly, but there's one thing I don't understand. According to this:...

returning reference to private vs public member

I would like to know what could be reasons to provide a public access method returning a reference instead of making the member public. QPoint has methods int& rxand int& ry that let me directly manipulate the coordinates. I guess the implentation looks similar to this: public: int& rx(){return x;}...

Tcl Regexp confusion

I have the following code in a tcl script $a_list - {,,} foreach a $a_list {if {[regexp adam [regsub {.*\.} $a {}]] == 1} {puts $a} } My understanding is that this looks for the string adam in $a_list and it matches when adam is the last string....

TCL get array value using variable as key name

I have the following array list that contains IANA Cipher Suites IDs (Key Name) with their corresponding names (Values) array set IANA_Ciphers [list {0000} {"TLS_NULL_WITH_NULL_NULL"} \ {0001} {"TLS_RSA_WITH_NULL_MD5"} \ {0002} {"TLS_RSA_WITH_NULL_SHA"} \ {0003} {"TLS_RSA_EXPORT_WITH_RC4_40_MD5"} \ [...] {C0AF} {"TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8"} ] Now I need to be able to access this array's values...

Object passed by reference will not exist. Swift

I have an array. var array:[customType] = [] // pseudo code func Generate_New_Array(){ //initialization of generatedNewArray array = generatedNewArray for (index,element) in array{ async_process({ Update_Data_From_Web(&array[index]) }) } }) } func Update_Data_From_Web(inout object:customType){ download_process{ object = downloadedData } } The question is , what will should I do if I call...

AngularJS - ReferenceError: $ is not defined

I'm getting the following error when I try to do this var fbcanvas = $('#fbcanvas'); This is the error I got ReferenceError: $ is not defined This is my JS code var feedbackModule = angular.module('feedbackModule', [ 'ui.bootstrap', 'dialogs' ]); feedbackModule.controller('feedbackDialog', function($scope, $rootScope, $timeout, $dialogs) { $scope.confirmed = 'You have yet...

Search for element after a designated string

I have a script that reads from a file and sorts out certain lines by a keyword. I need to be able to pick out a certain element from each of these discovered lines. The lines in the file are set up lie; $(eval $(call CreateUvmTest, keyword, element_needed, morestuff... $(eval...

TCL parsing a list of arguments to an external call

Im trying to execute a call to a python script through aldec riviera-pro my call is python $python_app_name $python_app_args However my $python_app_args are passed as a single string and not multiple strings resulting in that the python application only sees it as one argument and its execution fails. I've tried...

Why does my value change when I am not resetting it?

I have the following example exhibiting the problem I'm struggling to resolve. In the toy example, I have an array @actors with two levels. I also have an array of hashes @people which I am using to 'look up' properties of the people in @actors. The output of the program...

Tcl: Producing a Loop (*)

I want to produce a loop in Tcl that if n=2 creates: set Beam_Gravity_Load [subst {$a $b}] if n=3: set Beam_Gravity_Load [subst {$a $a $b}] if n=4: set Beam_Gravity_Load [subst {$a $a $a $b}] if n=5: set Beam_Gravity_Load [subst {$a $a $a $a $b}] and so on. "n" always is...

How to find corresponding values in columns using TCL

I'm a regular matlab user who needs to do some processing in TCL. I have no experience with tcl so up to now what I have done is by searching on google. Please pardon novice ways... I have data in column A and B which is imported via file Data_1,...

How to get selective data from a file in TCL?

I am trying to parse selective data from a file based on certain key words using tcl,for example I have a file like this ... ... .. ... data_start 30 abc1 xyz 90 abc2 xyz 214 abc3 xyz data_end ... ... ... How do I catch only the 30, 90...

Returning Some Variable from a “proc” in Tcl

Suppose that a procedure in Tcl is as follows: proc Section {ID x y} { . . "Some calculations do here" . . } Section 1 20 30 Section 2 25 35 Section 3 30 40 Section 4 35 45 Now, I define this: set IDsection {1 3} Then, I...

Why can a raw type reference refer to a generic instance? [duplicate]

This question already has an answer here: Is List<Dog> a subclass of List<Animal>? Why aren't Java's generics implicitly polymorphic? 8 answers Please help understand why Map map1 = new HashMap<String,String>(); // This compiles Map<Object,Object> map2 = new HashMap<String,String>(); // This does not. As per my understanding Map map1 is...

Running multiple exec commands and waiting to finish before continuing

I know I ask a lot of questions and I know there is a lot on here about this exactly what I am trying to do but I have not been able to get it to work in my script nor figure out why it does not let me do...

Using $variable in Parenthesis in Tcl (proc)

A part of my code in tcl is: proc Frame {columnLine} { . . . } Now I want use $variable in parenthesis. For example: set x 2. set columnLine {$x 5. 10. 15.} However, after running Tcl, I face an error! How I do solve this problem?...

Non-Greedy regex acts greedy based on the position of atoms in regex

I came across one situation where I wanted to use non-greedy atom .*? in the regex pattern. set input "Device ID: HOST1 Interface: GigabitEthernet0/1, Port ID (outgoing port): GigabitEthernet2/43 Device ID: HOST2 Entry address(es): Interface: GigabitEthernet0/2, Port ID (outgoing port): GigabitEthernet2/43 " puts "======== Non-Greedy regex starting with some other...

System.Windows.Interactivity must be referenced in the main project

So I have a WPF project and my interface in a different project than the main one. I went to reference System.Windows.Interactivity, but it would not work. Not until I added it as a reference to the main project as well... This is the first time this has ever happened...

c++ 2 ref classes should have acess to one same object of a other class

I have 2 classes let's say class a und b. And even a thrid class c. class a and b should have acess to the functions of the same object of class c. I want to have a member like a reference. So the argument in the construktor of class...

Questions on Regex algorithm (not necessarily EXPECT related)

I'm trying to create a regex to capture the neighbor detail of my devices (example output below). I could hard code each individual line, but I'm looking for a better solution. maybe learn a new algorithm. I'm interested in capturing Device ID (HOST1), Interface (GigabitEthernet0/1), and Port ID (GigabitEthernet2/43). for...

How to combine two arrays for form two column data using TCL

I have another question, how would I combine two arrays to form two columns. I've seen a zip command e.g. set n $ puts $output $n However when I save the file it is all in a single line. Kindly advice....

reference data class member visitor pattern

I have a container class that has a plain old datatype called DataStore. This data store will be passed to visitor.They share a single copy since any updated performed by the container are to be seen by visitor. class xyz { //Plain Old Datatype typedef struct DataStore { //add any...

How to get repeated number in string? [closed]

i want to get number of times particular number repeated in a string? Consider number is 2 , if 22 available in sting means , we should not consider as repeated number. set a "1232163122631261112312" in that 2 is repeated 5 times (we should not take 22 as 2 times...

Python: how to reference values in a def

As a very basic example of what I want to do, I want to update the values 1 and 2, after running them through the example method. Like how you would use ref for Java. def example(value1, value2): value1 += 2 value2 += 4 value1 = 0 value2 = 0...

How to match a colon after a close bracket

Why does the following not match the : expect { timeout {puts timedout\n} \[1\]: {puts matched\n} } > expect test.tcl [1]: timedout If I change it and remove the colon the match works: expect { timeout {puts timedout\n} \[1\] {puts matched\n} } $ expect test.tcl [1] matched Or if I...

Convert expect output from DOS to UNIX style in realtime

I write some expect scripts by connecting to a remote host through serial connection. My problem is that the output of the spawned process (enabled with log_user 1) contains DOS-style endings (each line being terminated with ^M when reading logs in VIM). I normally run dos2unix on all logs at...

Is a Java class variable a reference to a class object?

I know such question has been asked before but I couldn't find a satisfactory answer. Assume a java class : class Foo{ public int k; Foo(int a){ k=a; } } class My{ public static void main(String args[]){ Foo obj = new Foo(5);//1 obj=new Foo(8); //2 } } I want to...

Putting a string on same line tcl

I have a nmap output and I need to put strings on different lines on same line. Nmap Output: Nmap scan report for Host is up (0.014s latency). Not shown: 97 closed ports PORT STATE SERVICE 80/tcp open http 1720/tcp open H.323/Q.931 5060/tcp open sip Device type: VoIP adapter|WAP|PBX|webcam|printer...

Using a stored integer as a cell reference

Dim x As Integer Dim y As Integer For y = 3 To 3 For x = 600 To 1 Step -1 If Cells(x, y).Value = "CD COUNT" Then Cells(x, y).EntireRow.Select Selection.EntireRow.Hidden = True End if If Cells(x, y).Value = "CD Sector Average" Then Cells(x, y).EntireRow.Select Selection.Insert Shift:=xlDown Cells(x +...

C++ - Why does 2 local references to the same object stay in sync?

I would like to understand what's going on here. Obviously, there's some aspect of references or assignment operators that I am not getting right. Objective: Within a function, I want to work with 2 local reference variables to various elements of the same list: one is the iterated over and...

Using NON static class Methods Without reference

I'm new to Java. I know the concept of static and non static method. I'm wondering if it's possible to use non static methods of a class without having to create a reference to it. Like for example, for my program I'm working with Date objects, and I need to...

Expand passed arguments before printing with puts to virtual server

I am having trouble with an expect script not evaluating arguments. Everything in the puts ${file_id} block (simplified obviously) gets placed onto a virtual machine and is later used to for configuration. The block you see puts the same code into a local directory for me to see if things...

Itcl What is the read property?

I want to control read access to an Itcl public variable. I can do this for write access using something such as: package require Itcl itcl::class base_model_lib { public variable filename "" } itcl::configbody base_model_lib::filename { puts "in filename write" dict set d_model filename $filename } The configbody defines what...

References - Why do the following two programs produce different output?

I recently read about references in C++. I am aware of basic properties of references but I am still not able to figure out why following two programs produce different output. #include<iostream> using namespace std; int &fun() { static int x = 10; return x; } int main() { fun()...

Access to reference in member variable discards constness

I made a wrapper around an object in my code that should modify accesses to the object. I choose to use an object here for testing instead of a functor that would have the same functionality. Basically: The wrapper receives a reference to the object and forwards all indexed accesses...

tcl tdom parsing failed due to special charecters in xml tags

I am trying to remove some special characters which was existed in XML tags, we can use some regsubs or string map function to eliminate XML special chars in tagged text, But It is lengthy/time consuming process because our log file was very huge around ~25 MB. Is there any...

Java Pass-by-reference not working?

I'm trying to make this little game in Java but I seem to have stumbled upon a variable reference problem. My Entity class, which Player extends from, keeps a variable of type Dimension. This Dimension gets set via the constructor of the Entity class like so: protected Dimension dimension; public...