Skip to content

ati (compatability)

ATI tnz interface

ATI (Automated Task Interpreter) was an IBM-internal language/runtime built for automating 3270 terminal interaction. It had a syntax very similar to Rexx. This module is intended to help with porting ATI code to python. It is also the base of the zti tool.

Some of these functions have enhancements on top of the ATI function. Enhancments include using a negative index/position or length to indicate a position relative to the END of the string. See individual functions for details.

USAGE The way to make a python script that is most like ATI source code is to use 'import *'. Be warned that this will override the 'set' symbol (otherwise a python builtin function).

    from tnz.ati import *
    set('SESSION', 'SES1')
    wait(lambda: scrhas('RUNNING'))
    drop('SESSION')

The next step up in being more pythonic is to import the module
as a symbol, but still make the assumption that python is running
a single ATI program.

    from tnz import ati
    ati.set('SESSION', 'SES1')
    ati.wait(lambda: ati.scrhas('RUNNING'))
    ati.drop('SESSION')

In a more complex program that may manage multiple ATI programs,
the Ati class can be imported.

    from tnz.ati import Ati
    ati = Ati()
    ati.set('SESSION', 'SES1')
    ati.wait(lambda: ati.scrhas('RUNNING'))
    ati.drop('SESSION')

And a more pythonic way of using ATI-like variables can be used.
Note that this bypasses much of the ATI tracing/logging.

    from tnz.ati import Ati
    ati = Ati()
    ati.session = 'SES1'
    ati.wait(lambda: ati.scrhas('RUNNING'))
    ati.drop('SESSION')

Special ATI-like variables that did not exist in ATI:

LOGCOUNT
    Default is 9. Can be set to other positive integers. Used
    only when LOGMAX is non-zero. Used to determine the number of
    backup logs kept when a log reaches the maximum size. When
    the number of bytes in the log is about to exceed this value,
    the log file is closed and a new file is opened for output.
    The old file will be renamed to end in '.n', where 'n' is the
    current total number of backups. The first backup will end in
    '.1', the second in '.2', etc.

LOGMAX
    Default is 0. Can be set to a positive integer. When
    non-zero, value is the number of bytes at which log
    rollover/rotation occurs. When the number of bytes in the log
    is about to exceed this value, the log file is closed and a
    new file is opened for output.

LOGTRUNC
    Default is 1. Can be set to 0 or 1. Affects processing done
    when LOGDEST is set. When 1 and LOGDEST identifies an
    existing file, the file will be truncated to 0 bytes before
    logging begins. When 0 and LOGDEST identifies an existing
    file, log entries will be appended to the existing file.
    After LOGDEST is set to a file, LOGTRUNC is set to 0.
Environment variables used

COLORTERM (see _termlib.py) DATEFORM ESCDELAY (see zti.py) SESSION_PS_SIZE TERM_PROGRAM (see _termlib.py) TNZ_COLORS (see tnz.py) TNZ_LOGGING (see tnz.py) ZTI_AUTOSIZE (see zti.py) ZTI_SECLEVEL (see tnz.py) ZTI_TITLE (see zti.py) _BPX_TERMPATH (see _termlib.py)

Copyright 2021, 2024 IBM Inc. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

CASI module-attribute

CASI = _AtiConst('CASI')

EOL module-attribute

EOL = _AtiConst('EOL')

FALSE module-attribute

FALSE = '0'

FIRST module-attribute

FIRST = _AtiConst('FIRST')

LAST module-attribute

LAST = _AtiConst('LAST')

OFF module-attribute

OFF = _AtiConst('OFF')

ON module-attribute

ON = _AtiConst('ON')

TRUE module-attribute

TRUE = '1'

ati module-attribute

ati = Ati()

backtab module-attribute

backtab = '[backtab]'

btab module-attribute

btab = '[backtab]'

cdn module-attribute

cdn = '[down]'

clear module-attribute

clear = '[clear]'

clf module-attribute

clf = '[left]'

copies

copies(string, cnt)

returns cnt concatenated copies of string. The cnt must be a positive whole number or zero.

crt module-attribute

crt = '[right]'

cup module-attribute

cup = '[up]'

curdown module-attribute

curdown = '[down]'

curleft module-attribute

curleft = '[left]'

curright module-attribute

curright = '[right]'

curup module-attribute

curup = '[up]'

delete module-attribute

delete = '[delete]'

drop

drop(*args)

enter module-attribute

enter = '[enter]'

eraseeof module-attribute

eraseeof = '[eraseeof]'

ereof module-attribute

ereof = '[eraseeof]'

extract

extract(*args, wc=None)

home module-attribute

home = '[home]'

index

index(haystack, needle, start=1)

returns the character position of one string, needle, in another, haystack, or returns 0 if the string needle is not found or is a null string. By default the search starts at the first character of haystack (start has the value 1). You can override this by specifying a different start point, which must be a positive whole number.

ins module-attribute

ins = '[insert]'

insert module-attribute

insert = '[insert]'

left

left(string, length, pad=' ')

returns a string of length length, containing the leftmost length characters of string. The string returned is padded with pad characters (or truncated) on the right as needed. The default pad character is a blank. length must be a positive whole number or zero.

length

length(string)

returns the length of string.

logwrt

logwrt(value)

newline module-attribute

newline = '[newline]'

nl module-attribute

nl = '[newline]'

num module-attribute

num = num

numvalue

numvalue(name, trace=None)

pa1 module-attribute

pa1 = '[pa1]'

pa2 module-attribute

pa2 = '[pa2]'

pa3 module-attribute

pa3 = '[pa3]'

pf01 module-attribute

pf01 = '[pf01]'

pf02 module-attribute

pf02 = '[pf02]'

pf03 module-attribute

pf03 = '[pf03]'

pf04 module-attribute

pf04 = '[pf04]'

pf05 module-attribute

pf05 = '[pf05]'

pf06 module-attribute

pf06 = '[pf06]'

pf07 module-attribute

pf07 = '[pf07]'

pf08 module-attribute

pf08 = '[pf08]'

pf09 module-attribute

pf09 = '[pf09]'

pf1 module-attribute

pf1 = '[pf1]'

pf10 module-attribute

pf10 = '[pf10]'

pf11 module-attribute

pf11 = '[pf11]'

pf12 module-attribute

pf12 = '[pf12]'

pf13 module-attribute

pf13 = '[pf13]'

pf14 module-attribute

pf14 = '[pf14]'

pf15 module-attribute

pf15 = '[pf15]'

pf16 module-attribute

pf16 = '[pf16]'

pf17 module-attribute

pf17 = '[pf17]'

pf18 module-attribute

pf18 = '[pf18]'

pf19 module-attribute

pf19 = '[pf19]'

pf2 module-attribute

pf2 = '[pf2]'

pf20 module-attribute

pf20 = '[pf20]'

pf21 module-attribute

pf21 = '[pf21]'

pf22 module-attribute

pf22 = '[pf22]'

pf23 module-attribute

pf23 = '[pf23]'

pf24 module-attribute

pf24 = '[pf24]'

pf3 module-attribute

pf3 = '[pf3]'

pf4 module-attribute

pf4 = '[pf4]'

pf5 module-attribute

pf5 = '[pf5]'

pf6 module-attribute

pf6 = '[pf6]'

pf7 module-attribute

pf7 = '[pf7]'

pf8 module-attribute

pf8 = '[pf8]'

pf9 module-attribute

pf9 = '[pf9]'

rename

rename(name)

reset module-attribute

reset = '[reset]'

right

right(string, length, pad=' ')

returns a string of length length containing the rightmost length characters of string. The string returned is padded with pad characters (or truncated) on the left as needed. The default pad character is a blank. The length must be a positive whole number or zero.

say

say(value)

scrcomp

scrcomp(value)

scrhas

scrhas(*args, wc=None)

send

send(*args)

set

set(name, value, xtern=True, trace=None)

share

share(*args)

strip

strip(string, option='B', char=' ')

returns string with leading or trailing characters or both removed, based on the option you specify. The following are valid options. (Only the capitalized letter is needed; all characters following it are ignored.)

Both removes both leading and trailing characters from string. This is the default.

Leading removes leading characters from string.

Trailing removes trailing characters from string.

The third argument, char, specifies the character to be removed, and the default is a blank. With rexx, if you specify char, it must be exactly one character long. With this function, all characters specified in the char string are considered for removal from string.

Here are some examples:

strip(' ab c ') -> 'ab c' strip(' ab c ','L') -> 'ab c ' strip(' ab c ','t') -> ' ab c' strip('12.7000',char='0') -> '12.7' strip('0012.700',char='0') -> '12.7'

stripl module-attribute

stripl = lstrip

stript module-attribute

stript = rstrip

substr

substr(string, idx, length=None, pad=' ')

returns the substring of string that begins at the idx'th character and is of length length, padded with pad if necessary.

In rexx, idx must be a positive whole number. In this function, idx can also be negative. When idx is negative, the begining of the substring is relative to the end of string like in python. For example, -1 refers to the last chararacter in string and -2 refers to the second to last character in string and so on.

In this function, length can be negative. A negative length means that idx refers to the last character in the substring instead of the first. The length of the returned substring is always abs(length).

If you omit length, the rest of the string is returned. The default pad character is a blank.

Here are some examples:

substr('abc',2) -> 'bc' substr('abc',2,4) -> 'bc ' substr('abc',2,6,'.') -> 'bc....'

See also the 'left' and 'right' functions.

tab module-attribute

tab = '[tab]'

upper module-attribute

upper = upper

value

value(name, trace=None)

wait

wait(*args)

when

when(*args)

word

word(string, wpos)

returns the nth blank-delimited word in string or returns the null string if fewer than n words are in string. The n must be a positive whole number. This function is exactly equivalent to subword(string,n,1).

words

words(sentence)

returns the number of blank-delimited words in string.