Obviously sending a ZTERM escape sequence to a terminal or emulator other than ZTERM will cause problems. You therefore need to be able to find out if the terminal on the "other end" of your connection is ZTERM or not. If it's ZTERM you can use all these cool functions, but if not, you really don't want to risk locking up the terminal or crashing other terminal emulators.
The AM6x and AM72/75 series of terminal support an escape sequence <ESC>? which returns to the host system the current cursor position as two characters. The two characters returned will be the current screen row and column in an encoded format. AM6x and AM72/AM75 terminals, plus AlphaLAN, PC Vision™ always respond with the correct sequence.
ZTERM on the other hand will normally return the same sequence, EXCEPT when three of these escape sequences are sent back to back, i.e. without any other escape sequences in between. When this happens, ZTERM sends back ZT.
In build 74 and later, if a forth ESC ? is sent to ZTERM, the version number of ZTERM will be sent to the host system, terminated with a CR.
Remember that only two characters come back after this escape sequence, so you can't use an input statement - you need to use your favorite "give me a single character" XCALL.
Examples
In this example, I use ACCEPT.SBR from the AlphaACCOUNTING suite. These XCALLs are included with most modern versions of AMOS.
MAP1 VERSION,S,10,"Unknown"
MAP1 TRUE,F,,1
MAP1 FALSE,F,,0
MAP1 ZTERM,F,,FALSE
MAP1 A,F
MAP1 B,F
!Set image mode on so that ACCEPT works
XCALL NOECHO
!Send three ESC ? characters back to back. Normally sends the row/col
PRINT CHR$(27);"?";
XCALL ACCEPT,A : XCALL ACCEPT,B
PRINT CHR$(27);"?";
XCALL ACCEPT,A : XCALL ACCEPT,B
PRINT CHR$(27);"?";
XCALL ACCEPT,A : XCALL ACCEPT,B
!ZTERM sends "ZT" back on the third - non-ZTERM terminals and emulators
!send the row and column again
IF A=ASC("Z") AND B=ASC("T") THEN ZTERM=TRUE ELSE GOTO DONE
!Send ESC ? a forth time - if it's ZTERM build 74 and later, the version
!will be sent prefixed with ZV
PRINT CHR$(27);"?";
XCALL ACCEPT,A : XCALL ACCEPT,B
IF A#ASC("Z") OR B#ASC("V") THEN GOTO DONE
!We do have build 74, so back to non-image mode so we can use INPUT to
!get the version (terminated with a CR)
XCALL ECHO
INPUT "";VERSION
DONE:
XCALL ECHO
IF ZTERM=FALSE THEN PRINT "Not ZTERM" : END
PRINT "Running ZTERM version: ";VERSION
END