Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-17-2019, 12:53 AM
slouw slouw is offline
Registered User
 
Join Date: Nov 2005
Posts: 143
SessionConfiguration Object

Are all objects in the SecreCRT object model rooted in a hierarchy with the apex being the crt object? I always assumed so.
The sample script kindly provided is this post
I have edited to make the hierarchy more obvious to me:


Quote:
# $language = "Python"
# $interface = "1.0"

crt_GetScriptTab = crt.GetScriptTab()
crt_GetScriptTab_Session = crt_GetScriptTab.Session.Config
crt_GetScriptTab_Session_GetOption_Emulation = crt_GetScriptTab_Session.GetOption("Emulation")
crt.Dialog.MessageBox("Current Emulation Type is set to: " + crt_GetScriptTab_Session_GetOption_Emulation)
strNewEmulation = "VT100"
crt_GetScriptTab_Session.SetOption("Emulation", strNewEmulation)
strNewEmulation = crt_GetScriptTab_Session.GetOption("Emulation")
crt.Dialog.MessageBox("New Emulation Type is set to: " + strNewEmulation)
I have generally worked out from the linkage of objects/methods what object is being returned by whatever object is referenced. I cannot find in the scripting reference help where it specifies what kind of object/datatype is returned for each object/method.

Consider the call
crt_GetScriptTab = crt.GetScriptTab()
What kind of object has been returned?
We get a clue in the subsequent statement:
crt_GetScriptTab_Session = crt_GetScriptTab.Session.Config
Whatever object has been returned in the variable crt_GetScriptTab has itself a object/method called Session.
And that object has a datatype which itself has an object/method called Config.
The object Crt.Session exists and itself has an object called Config. So this fits. The generic (vague?) Script Reference Help seems to suggest this is a good fit.
But the Crt.Session.Config object does not have a GetOption object/method. So this cant be it.

So I look from the other end.
Consider the linkage represented in line 6 above:
crt_GetScriptTab_Session_GetOption_Emulation = crt_GetScriptTab_Session.GetOption("Emulation")

What object has itself an object/method called GetOption?
A search reveals the SessionConfiguration object.
My working assumption is that the datatype returned to the variable in the line above is that described by the SessionConfiguration object.

Which brings me finally to my question.
I can find no object/method which itself has an object SessionConfiguration.
So SessionConfiguration is not rooted in the Crt.... hierachy then?
Does it have a "parent" at all?
Or does it only describe datatypes returned from elsewhere in the hierarchy?
I hope this all makes sense.
Thank you if you are still reading!

Last edited by slouw; 04-17-2019 at 01:05 AM. Reason: Typo
Reply With Quote
  #2  
Old 04-17-2019, 11:35 AM
berdmann berdmann is offline
VanDyke Technical Support
 
Join Date: Aug 2017
Posts: 264
Hi slouw,

Config is a property of the Session object, which returns the configuration associated with the session.

SessionConfiguration is itself a separate object, which provides methods for accessing session configuration through scripting.
The SessionConfiguration object does indeed have SetOption() and GetOption() methods.

Please refer once more to the Script Objects Reference help topic and take a look at the SessionConfiguration object.

Is this information helpful?
__________________
Thanks,
--Brittney

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 04-17-2019, 05:12 PM
slouw slouw is offline
Registered User
 
Join Date: Nov 2005
Posts: 143
Hi Brittney

For once that was not really helpful.
Pardon my candour but I am thinking you want to know

Quote:
Config is a property of the Session object, which returns the configuration associated with the session.
We are talking about the Crt.Session.Config object I think here
Is there a more formal/precise definition for what this "property of the session object" returns?
Consider a code fragment ItemX = Crt.Session.Config
Is there a more formal definition for ItemX?
What properties or methods would ItemX have?


Quote:
SessionConfiguration is itself a separate object, which provides methods for accessing session configuration through scripting.
The SessionConfiguration object does indeed have SetOption() and GetOption() methods.
Can any object, including this one, in effect define a datatype?
What code fragment would return the SessionConfiguration object?
Might ItemX above be of a datatype represented/defined by the SessionConfiguration object?

Quote:
Which brings me finally to my question.
I can find no object/method which itself has an object SessionConfiguration.
So SessionConfiguration is not rooted in the Crt.... hierachy then?
Does it have a "parent" at all?
Or does it only describe datatypes returned from elsewhere in the hierarchy?
Above are my questions in my previous post.
Is it possible to address them directly?
I have thought through this post carefully but I realise if I have made incorrect assumptions then maybe these questions don't make sense or are the "wrong" ones to ask

I much appreciate your help and any further reply...
Reply With Quote
  #4  
Old 04-18-2019, 12:11 PM
berdmann berdmann is offline
VanDyke Technical Support
 
Join Date: Aug 2017
Posts: 264
Hello slouw,

Lets see if I can clear up your confusion with direct responses to each of the questions that you posed.

Quote:
We are talking about the Crt.Session.Config object I think here
The statement 'crt.Session' returns a reference to a SessionConfiguration object. This specific instance of a SessionConfiguration object is tied to the Session object associated with the Tab object that represents the active tab -- the tab that was active at the point in time when you launched the script.

Rather than 'crt.Session' being thought of as a static (never-different) concept, you should think of it as being associated with whatever session is currently associated with the active tab at the very moment when the script starts running. So, if you have 8 tabs open, and the 3rd tab is active when you launch the script, 'crt.Session' will give you a reference to the Session object associated with tab #3.

Quote:
Is there a more formal/precise definition for what this "property of the session object" returns?
Consider a code fragment ItemX = Crt.Session.Config
Is there a more formal definition for ItemX?
What properties or methods would ItemX have?
The statement 'ItemX = crt.Session.Config' would return a reference to a SessionConfiguration object, the methods and properties of which are defined in SecureCRT's help under the "Script Objects Reference" chapter. Which session's configuration would be referenced? The session associated with the active tab (again, the tab that was active when the script was launched).

Quote:
> What code fragment would return the SessionConfiguration object?
It's not "the" SessionConfiguration object, it's an instance of "a" SessionConfiguration object -- which refers to the configuration associated with a session -- the session a Tab object contains. Tab objects are literally associated with tabs open in the SecureCRT window.

Quote:
Might ItemX above be of a datatype represented/defined by the SessionConfiguration object?
Yes!

Quote:
Consider the call
crt_GetScriptTab = crt.GetScriptTab()
What kind of object has been returned?
First, I wouldn't name it "crt_GetScriptTab". Instead, I'd name it 'objTab', or 'objCurrentTab' or 'objActiveTabAtTheTimeTheScriptWasLaunched' because it represents an instance of a Tab object as defined in SecureCRT's help.

The line of code 'objTab = crt.GetScriptTab()' returns a reference to the Tab object that is associated with the active tab at the moment in which the script started running (Script > Run).

Quote:
What object has itself an object/method called GetOption?
A search reveals the SessionConfiguration object.
My working assumption is that the datatype returned to the variable in the line above is that described by the SessionConfiguration object.
Your assumption is incorrect.

GetOption() is a method of a SessionConfiguration object. GetOption() returns a value. The type of the value returned depends on the name of the option you provided. You asked for the "Emulation" value. That would return a string type, the value of which reflects the current Emulation for the session in the referenced tab -- since you referenced crt.GetScriptTab(), this means the tab that was active at the very moment the script began running.

Quote:
Which brings me finally to my question.
I can find no object/method which itself has an object SessionConfiguration.
So SessionConfiguration is not rooted in the Crt.... hierachy then?
Does it have a "parent" at all?
Or does it only describe datatypes returned from elsewhere in the hierarchy?
Already answered earlier.

A "Session" object has a property named "Config". That "Config" property returns a reference to a SessionConfiguration object. The SessionConfiguration object can then be used to get/set options associated with the session's configuration.

--Brittney
Attached Images
File Type: png Sluow-ft13503_SessionConfig.png (92.3 KB, 216 views)
__________________
Thanks,
--Brittney

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 03:44 PM.