Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > General

Reply
 
Thread Tools Display Modes
  #1  
Old 11-12-2019, 12:36 PM
VanDyke82nev VanDyke82nev is offline
Registered User
 
Join Date: Jul 2017
Posts: 17
Button code for duplicate string or character

Is there a shortcut in the code for a button to send something multiple times? Like say I wanted to send 30 dashes.

------------------------------ << 30 dashes

Can I put that in a button with a shortcut?

Something like:

\[30]{-}

That was just a wild guess.

I want to keep the button code short.

Alternatively, might there be a way to use variables with the buttons? Like:

$5="-----------------------------"
\$5

thanks
Reply With Quote
  #2  
Old 11-12-2019, 04:46 PM
ashiosee ashiosee is offline
Member
 
Join Date: Oct 2019
Posts: 24
SecureCRT doesn't provide any native SEND_STRING repeat functionality.

However, you can achieve expanded functionality through scripting. Consider that you could map a button to run a script (instead of sending a string). The arguments to the script could be something like: char_sequence repeat_count

Where char_sequence represents what you want to send, and repeat_count represents the number of times you want it repeatedly sent.

Here's an example of such a script:
Code:
# $language = "Python"
# $interface = "1.0"

def main():
    # Check to make sure we have a char_sequence arg:
    if crt.Arguments.Count > 0:
        strStringSequence = crt.Arguments.GetArg(0)
    else:
        crt.Dialog.MessageBox(
            "Script argument expected: char_sequence\r\n" +
            "\r\n" +
            "This script expects two arguments: char_sequence repeat_count")
        return
    
    # Check to make sure we have a repeat_count arg:
    if crt.Arguments.Count > 1:
        try:
            nRepeatCount = int(crt.Arguments.GetArg(1))
            
        except Exception as objException:
            crt.Dialog.MessageBox(
                "Arg Error: Expected integer value." +
                "\r\n" +
                str(objException))
            return
        
    # If we get to this point, we can move forward with sending
    # the char_sequence repeat_count times
    for nIndex in range(0, nRepeatCount):
        crt.Screen.Send(strStringSequence)
    
    
main()
Would something like this meet your needs?
__________________
--Allen

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 11-12-2019, 05:16 PM
VanDyke82nev VanDyke82nev is offline
Registered User
 
Join Date: Jul 2017
Posts: 17
Thank you very much Allen!

I guess can stop looking for it for the button code, and if need be, go the script route.

I greatly appreciate your reply. Just another reason to be a fan of SecureCRT.
Reply With Quote
Reply

Tags
buttons


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

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:28 PM.