Displaying Separate Queries to the Same Output Window Summary: Querying to a window is a common way to view data. Unfortunately, if you use only the SELECT command, there is no way to APPEND to an output window so that multiple queries output to the same window. This technote shows you a method you can use to output multiple queries to the same window. You should be familiar with SBL and the SELECT command. Displaying multiple queries If you were to run Program 1 below, you would expect the query output from both queries to output to "WINDOW1". However, with the way the SELECT command functions, a new window is opened for each query even if you specify the same window name in the TO clause of the SELECT statement. Program 1 REM First Query OPEN FILE "c:\sb4w\samples\stock\customer" SELECT Name.Customer,City.Customer TO WINDOW "WINDOW1" END SELECT REM Second Query OPEN FILE "c:\sb4w\samples\stock\video" SELECT Title.Video,Category.Video TO WINDOW "WINDOW1" END SELECT In order to output multiple queries to the same window, you must use the OPEN WINDOW "windowname" SBL command. The trick is to first open a window for output, then perform the queries using the SELECT command. The SELECT command should not include a TO statement. Program 2 below demonstrates the use of the OPEN WINDOW "windowname" command to output two queries to the same window. The example could be carried further to output any number of queries to the same window. Program 2 REM Program to demonstrate how to append query REM Output to an Open Window. SUB main() OPEN FILE "c:\sb4w\samples\stock\video" OPEN FILE "c:\sb4w\samples\stock\customer" CALL PrnWindow() END SUB SUB PrnWindow() OPEN WINDOW "WINDOW1"' Open the Window for Output REM Output First Query HEADING ? "***** List of Some Customers From The CUSTOMER File *****" ? END HEADING SELECT Name.Customer,City.Customer WHERE CustomerNo.Customer < "00010" END SELECT REM Open same window again and output second query OPEN WINDOW "WINDOW1"' Open same window for append FILE "video" HEADING ? "***** List of Some Video Titles From The VIDEO File *****" ? END HEADING SELECT Title.Video,Category.Video WHERE VideoCode < "P0015" END SELECT END SUB It is important to note that window names are case sensitive. Therefore, if you OPEN "WINDOW1" FOR OUTPUT for the first query and you OPEN "Window1" FOR OUTPUT for the next query, the query output appears in two separate windows. Program: Superbase Versions: 2.0 Date: April 22, 1993