Tera Term Macro Examples

TeraTerm Macro Language; Built-in logging; Freeware! TeraTerm Pro Web 3.1.3 - Enhanced Telnet/SSH2 Client. Applications & Examples TeraTerm Pro Web can act as a 'middle-man' to provide communication between platform-independent web-based application servers (such as ColdFusion, PHP, ASP, Perl, etc) and any remote Telnet/SSH host.

What is subroutine.ttl? Tera Term Macro has limited support for writing reusable code. It is possible to include a file but it is not possible to use a goto or call command to easily jump to a specific block of code in a file. Subroutine.ttl emulates a function call syntax and allows you to write more modular, compartmentalized code. For example, given two files (main.ttl and util.ttl), you could write something like this in main.ttl: callsub = 'util:clear_system_logs' include 'subroutine.ttl' This will call the clear_system_logs subroutine in util.ttl::clear_system_logs; Put your code here! Return subroutine.ttl requires Tera Term version 4.66 or higher.

It is licensed under the terms of. See LICENSE.txt for the full text of the license.

How do I use it? You will need to copy subroutine.ttl into your source code directory and copy the following code to the top of each of your modular.ttl files:; Confirm that ``__include_goto_label`` is defined and is a string.

Ifdefined __include_goto_label if result == 3 then; Confirm that ``__include_goto_label`` is not an empty string. Strlen __include_goto_label if result then; Confirm that ``__include_goto_label`` is an actual label. Sprintf2 __execstr 'ifdefined%s' __include_goto_label execcmnd __execstr if result == 4 then; The label exists. Call the subroutine and return. Sprintf2 __execstr 'call%s' __include_goto_label execcmnd __execstr result = 0 exit endif result = GOTO_LABEL_NOT_DEFINED exit endif endif; This is the default subroutine to call. Change the name if desired.

Call default exit Then, back in main.ttl, set the callsub variable. You can use one of the following formats: •: • If the goto label is not specified, the hook code above will call the default subroutine.

Secure vault by boyt reset. For readability, you can also leave the '.ttl' extension off of the filename. Second, include subroutine.ttl in your main file. Example: main.ttl -----------------------------------------------------------------------; The hook in util.ttl will call the default subroutine; if you just include util.ttl. Include 'util.ttl'; Call the default subroutine. Callsub = 'util' include 'subroutine.ttl'; Call the ``clear_system_logs`` subroutine.

Callsub = 'util:clear_system_logs' include 'subroutine.ttl' What happens if there is a problem? As much as possible, subroutine.ttl attempts to avoid throwing errors. To avoid errors, it attempts to detect errors before they happen and will return an error code in the result variable. It also defines several constants that you can use for more readable error checking. For instance: callsub = 'util:label_with_typoo' include 'subroutine.ttl' if result == GOTO_LABEL_NOT_DEFINED then messagebox 'The goto label is not defined!' 'Shwoops' endif Here is the complete list of error code constants and their meanings: Constant name Meaning CALLSUB_IS_NOT_DEFINED The callsub variable has not been set. CALLSUB_IS_NOT_A_STRING The callsub variable is not a string.

CALLSUB_IS_EMPTY The callsub variable is an empty string. GOTO_LABEL_NOT_DEFINED The specified goto label is not valid. INCLUDE_DEPTH_EXCEEDED The maximum include depth (9) has been exceeded. INCLUDE_FILE_NOT_FOUND The specified file does not exist.