Function KEY Strings Retained After CHAIN in QuickBasic 4.x (41151)






This article was previously published under Q41151

SUMMARY

If you define strings to be returned by function keys F1 through F10 (using KEY n,"<string>"), and then CHAIN to another program, these function key strings are retained unless the programs are compiled as stand alone. This behavior applies to Microsoft QuickBasic Versions 4.00, 4.00b, and 4.50, Microsoft Basic Compiler Versions 6.00 and 6.00b, and Microsoft Basic PDS Version 7.00.

In QuickBasic Versions 3.00 and earlier, the function key strings are not retained after CHAINing.

MORE INFORMATION

When CHAINing between programs, unnamed COMMON blocks and open files are preserved from the CHAINing program to the CHAINed-to program only if the programs are compiled without the /O (stand-alone EXE) option.

If the two programs below are compiled with QuickBasic Version 3.00 using no options, the KEY list is destroyed after the CHAIN. However, if the same programs are compiled using no /O option under a later version of QuickBasic or Microsoft Basic Compiler Version 6.00 or 6.00b, or Basic PDS 7.00, the KEY list is retained in the second program.

The following is a code example:
'** KEY1.BAS
FOR t=1 TO 10
  KEY t,"*****"
NEXT t
KEY LIST
INPUT "Press any function key F1 - F10 and hit RETURN",X$
CHAIN "key2"


'** KEY2.BAS
CLEAR
KEY LIST
INPUT "Press any function key F1 - F10 and hit RETURN",X$
PRINT "End of programs."
END
				

Modification Type: Minor Last Reviewed: 1/8/2003
Keywords: KB41151