Print Page | Close Window

Cloning the active session

Printed From: Rocket Software
Category: AccuTerm Knowledge Base (read only)
Forum Name: Scripting & Automation
Forum Description: Customize and control AccuTerm using scripts and automation
URL: https://forum.asent.com/forum_posts.asp?TID=669
Printed Date: March 26 2026 at 8:50pm
Software Version: Web Wiz Forums 12.03 - http://www.webwizforums.com


Topic: Cloning the active session
Posted By: anonymous
Subject: Cloning the active session
Date Posted: April 05 2006 at 4:42am
Is it possible to create a toolbar button to open a new session with the same settings as the current session?



Replies:
Posted By: PSchellenbach
Date Posted: April 05 2006 at 4:49am
Hi -

You can create a script to clone the current session, then run that script when a toolbar button is pressed. First create the following script and save it in the ...\Program Files\Atwin folder as "clone-session.atsc":

Sub Main()
Dim fn As String
On Error Resume Next
If Sessions.Count > 0 Then
fn = ActiveSession.FileName
If fn <> "" Then
   Sessions.Add fn
End If
End If
End Sub

This script checks if there is a session already open, then retrieves the file name of the active session and uses it as the file name argument of the Add function of the Sessions object.

Next, use the menu designer to add a button to the toolbar: Tools->Customize Menu, then choose the menu scope (user or application would seem appropriate), then expand the Toolbar node in the tree, select the Toolbar node, and click the New button and select Normal. In the new button's Action field, enter:

[chain "clone-session.atsc"]

Choose an icon for the new button and click OK to save the customized toolbar.

Thanks,

Pete


Posted By: Ima.Geek
Date Posted: August 16 2006 at 8:03am
This method does indeed clone the ATCF file session, but not the ATSC file session.  Is there a way to make a new session based on the current ATSC file?


Posted By: Ima.Geek
Date Posted: August 16 2006 at 8:08am
Phrased another way...

How can one create a new toolbar button that will detect which .ATSC file is currently in use and open a new session using that .ATSC file?


Posted By: PSchellenbach
Date Posted: August 16 2006 at 11:15am
Hi ImaGeek -

I presume you are using a script (.atsc) file to open a session and log in automatically? When you start AccuTerm using a script file, the script is loaded into the script editor (Tools->Script) and Sub Main is automatically executed. So, to rerun the script, all you need to do is run Sub Main again. Scripts loaded in the script editor window are "shared scripts" and any public Subs and Functions are available to any other script. So all you need to do to run Sub Main of the script in the script editor is do Call Main(). So your toolbar button needs
[Call Main()]

There's no easy way to detect if there is a script loaded, and whether the loaded script will do what you want, but if you know things are set up correctly, this should work fine.

Thanks,

Pete


Posted By: Ima.Geek
Date Posted: August 17 2006 at 12:19am
Too easy..  MUCH APPRECIATED!

Thanks..   :)



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.03 - http://www.webwizforums.com
Copyright ©2001-2019 Web Wiz Ltd. - https://www.webwiz.net