-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- PCM Online November 1994 FEATURES Contents: [] Truchet Tilings: Computerized patterns -- before fractals, there were Truchet tiles. [] Print Listings the Easy Way: Neat, organized printouts of all your program's modules. [] Teed Off: Tests your intelligence (or perseverance). [] Alternate Operating Systems: Does Microsoft Have It Right With Windows NT? Entire contents copyright 1994 by Falsoft, Inc. PCM -- The Premier Personal Computer Magazine is intended for the private use and pleasure of its subscribers, and reproduction by any means is prohibited. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Truchet Tilings ~~~~~~~~~~~~~~~ What you need to run the program: MS-DOS, VGA, QBASIC or QuickBASIC "Computerized patterns: before fractals, there were Truchet tiles" TRUCHET TILINGS by Scott Edwards In the 1700s, when European monk Sebastien Truchet was exploring tile patterns, your PC would have seemed like magic. Truchet would be happy to know that in 1994 his tile patterns, rendered in vivid color on a VGA monitor, are still magical. What Truchet discovered was that square tiles, decorated with lines or arcs connecting the midpoints of two adjacent sides, could be laid out randomly to form intriguing patterns. The accompanying program, TRUCHET.BAS, generates these tiles and then animates them by randomly flooding them with color. The program begins by declaring the subroutines that generate the tiles. Next it dimensions a pair of integer variables to hold the coordinates of the upper-left corner of each tile to be drawn. The DIM SHARED statement allows all subroutines access to these variables. Without it, each subroutine must contain its own SHARED statement. The constants (CONST) set the color and size of the tiles. Feel free to change these values to your taste. Valid entries for theColor are O to 15. The display looks best when TileSize is in the range of 3 to 3O. Because all the routines that depend on these values adjust themselves relative to the constants, your experimentation won't introduce bugs. That's the benefit of using CONST to declare certain universal values at the beginning of the program. Constants are accessible to all subroutines in QBASIC. The program uses SCREEN 12, the 16-color VGA mode with 640-by-480 resolution. After clearing the screen, the program seeds the random-number generator with the contents of the timer to ensure that you see new patterns every time you run the program. Next a pair of FOR/NEXT loops lay tile outlines across the 640-by-480 screen. Tiles are chosen with the QBASIC equivalent of a coin toss. RND returns a value between O and 1. If it's less than O.5, Tile1 is drawn; more than O.5, and Tile2 is drawn. This is repeated until the screen is filled. Note that you can substitute an alternative pair of tile routines, Tile3 and Tile4, in the IF/THEN/ELSE line. Tile3 and Tile4 generate straight, maze-like patterns. You can even mix routines, such as Tile1 and Tile3, to produce odd hybrid patterns. The next section of the program is a DO/WHILE loop that begins by selecting a random point on the screen and a random color. If the random color is the same as the tile outline, the program throws it back. The PAINT command colors between boundaries set by the tile outlines. If the screen were flooded with this color, it would obliterate the outlines. Eventually the entire screen would become filled with the outline color. If the user presses any key while the program is running, execution stops as soon as the PAINT command has finished. At the end of the program listing are the tile subroutines. These connect the mid-points of adjacent sides of an imaginary square with arcs (Tile1 and Tile2) or straight lines (Tile3 and Tile4). Tile2 is Tile1 rotated 90 degrees; Tile4 is Tile3 rotated 90 degrees. One aspect of the CIRCLE command (used in Tile1 and Tile2) is worth a little explanation. CIRCLE can draw circles, arcs, pie slices or ellipses. In this case it draws arcs. To do so, it requires the center point of the arc, radius, color, and starting and ending angles. These angles are in radians instead of the more familiar degrees. Degrees are generally expressed in compass terms, with zero degrees corresponding to north. A compass marked in radians would have zero due east, pi/2 (1.57) north, pi (3.14) west, and 3*pi/2 (4.71) south. The CIRCLE command also draws an arc for zero to pi/2 different from that for pi/2 to zero. In the first case the belly of the arc points up and to the right; in the second it's down and to the left. The program's ripe for further experimentation. Try different values for TileSize. How about using SELECT CASE to pick from all four tile subroutines based on the value of RND? Can you predict how that would look? If you're really feeling adventurous, you might even write your own tile subroutines. If you'd like to read more about Truchet tilings and other graphical curiosities, see the book *Computers, Patterns, Chaos and Beauty* by Clifford Pickover. It's full of inspiring ideas for BASIC programmers, although it presents only concepts and algorithms -- not actual programs. A designer of electronic kits, toys and educational devices, Scott Edwards programs in BASIC to simulate projects under development -- and just for fun. -=*=- A designer of electronic kits, toys and educational devices, Scott Edwards programs in BASIC to simulate projects under develop- ment -- and just for fun. -=-------------- -=*=- -=*=- -=*=- --------------=- Print Listings the Easy Way ~~~~~~~~~~~~~~~~~~~~~~~~~~~ What you need to use this program: MS-DOS, QBASIC or QuickBASIC "Programmers, use this program to print your listings from DOS: it tracks down and prints all modules neatly in one step" PRINT LISTINGS THE EASY WAY by Henry Green Recently I wrote a large application program in Turbo BASIC. As you would expect, it was constructed of numerous procedures and other modules -- enough to fill a notebook, in fact. As the program evolved, keeping track of its many components became increasingly difficult. Printing updated listings was time-consuming and required entry of many separate commands. I finally solved the problem by developing EasyList, a program that lets me list one or many modules in a neatly formatted way and with no more effort than invoking a single batch file. Unlike other program listers, EasyList can be executed from DOS and permits the use of command-line parameters. Thus it can be called from a batch file. The first line of the listing is printed in boldface type and serves as the title of the listing. The system date is included in the file. The pages are numbered, and each page bears the same title and date. A margin is left at the top and bottom of each page, and a form feed is executed at the end of the printout. About the Program While I wrote EasyList in Turbo BASIC, it should be simple to convert to QuickBASIC or even conventional BASIC. (Editor's note: In order to enable the program to run in QBASIC, we changed the statement INCR I to I =I + 1 and the statement INCR page to page = page + 1. You can also compile this program listing in QuickBASIC for faster operation.) It begins with an error trap that warns the user if he has entered a filename nonexistent in the current or specified directory. The main program, consisting of a self-explanatory IF/THEN routine, follows. Two procedures are used. PRINTIT prints the file, counting the lines and pages and adding the date. Note that when the line counter reaches 51, a form feed is executed and the line counter reset. The variable TITLE is merely a flag to indicate whether the first line of the program has been copied into the variable TITLE$. The INSTRUCTIONS procedure prints instructions if the user fails to provide a filename or provides one that is unavailable. The printer codes used for turning on and off boldface characters are commonly ESC "E" and ESC "F", respectively. These codes are used by Epson, Panasonic and many other printers. If your printer is another brand, however, changing these codes is simple. Using the Program EasyList can be used by itself to perform a printout of any ASCII-saved file. This can be a Turbo BASIC, Pascal or other language batch or document file. The syntax is EASYLIST FILENAME.EXT if the file is in your current directory -- or EASYLIST C:\DIRNAME\FILENAME.EXT if it's in another directory or on another drive. The program is most effective when used in a batch file with replaceable parameters. It can then be used to list all files fulfilling specific criteria. (This might be all files within a specific subdirectory, all files with a certain extension, etc.) The batch file I use is: CLS PAUSE THIS PRINTS ALL FILES WITH THE .INC EXTENSION FOR %%F IN (*.INC) DO EASYLIST %%F This small batch file prints all the files in my $INCLUDE list, since they all have the extension .INC. -=*=- Henry Green is a cardiologist who writes programs for medical applications. His work has appeared in numerous medical and technical publications. He can be reached at 22250 Providence Drive, #600, Southfield, MI 48075. -=-------------- -=*=- -=*=- -=*=- --------------=- Jump ~~~~ What you need to run the program: MS-DOS, BASIC or QBASIC, EGA or VGA "Tests your intelligence (or perseverance)" TEED OFF by Dennis Magee, Sr. Jump is based on a game I first encountered while traveling with my father. We stopped at a roadside restaurant, and I began playing a game I found on the table. It was a triangular block of wood with 15 holes drilled into it in five rows. In all the holes but one was a golf tee. The object of the game was to try to eliminate as many tees as possible by jumping across each into empty holes directly next to them. The "down home" standards printed on the game read: Leave only one, and you're a genius. Leave two, and you're purty smart. Leave three, and you're just plain dumb. Leave four or more, and you're an "ig-no-ra-moose." How to Play When you start Jump, the playing board appears with 14 tees in place. The center hole is left empty -- believe me, this is the only way you can get down to one tee! An arrow appears under the upper-left tee. Use the cursor keys to move the arrow below the tee with which you want to jump, and press ENTER. The tee you've just selected is now outlined. Now move the arrow below the hole into which you want to jump, and again press ENTER. If your selection is a legal choice, your tee moves into the hole you've chosen and the tee it jumped is removed. Illegal moves are announced across the top of the screen. If you change your mind after a move, position the arrow under the tee you selected, press ENTER, and then select another tee. When you have eliminated all the tees you can jump, you can press N to play another game. Your status is displayed at the top of the screen, the screen clears, and a new game appears. To quit the game at any time, press ESC. How the Program Works I wrote Jump for Tandy Graphics mode, but it works with EGA or VGA graphics when the screen mode in Line 90 is changed to SCREEN 7 and the CLEAR statement is removed. (Editor's note: we've made this change for you. You Tandy 1000 users, who need the Tandy Graphics mode, edit Line 90 to look like this: 90 KEY OFF:CLEAR,,,32768!:SCREEN 5:COLOR 7,0:CLS) Lines 90 through 350 go on to set up the dimensions and variables and then draw the game board onscreen. Lines 360 through 460 contain the main-program routine. Line 360 waits for keyboard input from the player. If the player presses ENTER, the program branches to Line 1610, where the arrow location is checked. If the arrow is under the first tee selected, the tee is outlined by a red box. If it points to a hole into which to jump, the first tee and the jumped tee are both erased, and the original tee moves into the hole. Play then returns to the main program, where the number of tees left is updated. When the player presses any cursor key, the program branches to the appropriate line to update the arrow location. Pressing the N key results in the program's branching to Line 2310, where the player's status is displayed at the top of the screen for about five seconds. Then Jump branches to Line 110 to start the game again. -=*=- Dennis Magee is a Sergeant First Class in the U.S. Army. He programs in BASIC for fun and experience. He can be reached at 5067-B Hammond Heights., Fort Campbell, KY 42223. -=-------------- -=*=- -=*=- -=*=- --------------=- Alternate Operating Systems ~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Exploring the *Corporate* side of Microsoft Windows' strategy" DOES MICROSOFT HAVE IT RIGHT WITH WINDOWS NT? by Emmett Dulaney Microsoft has mapped an operating system strategy that allows users' capabilities to grow with their needs and demands. The first rung of the ladder is DOS. Beginning users fumble around and learn how to copy files, delete them, make directories and grumble, "This thing makes no sense," while reading the latest edition of DOS For Dummies. Shortly thereafter, if they stick to the Microsoft plan, they install Windows on their machines. Windows requires an investment in time to master both the concept and the interface, but the benefits are enormous. While space does not permit discussing the benefits of Windows applications over stand-alone DOS, suffice it to say that integrating operations in a graphical interface enhances usability. Once a user outgrows Windows, the next step is to install Windows for Workgroups. Using the same interface as regular Windows, this product adds the ability to incorporate peer-to-peer networking. Databases and peripherals can be shared between users, as well as electronic mail and a handful of other features. The interface looks so much like regular Windows, and the operations and features mirror other applications so much, that the time to learn the product is virtually nil. While good products, the one flaw of Windows and Windows for Workgroups is the fact that they are layered on top of regular DOS and are not operating systems in their own right. This is where Windows NT comes into the picture. Windows NT is the next step from Windows for Workgroups and is an operating system independent of DOS. Using an interface parallel to regular Windows, once again it is possible to move to the next performance level without the necessity of retraining. Thus, with Microsoft's strategy, users devote the time to learning everything they can about Windows and are then able to grow and upgrade their systems without the need for further training. Similar interfaces between the DOS version and the Windows NT operating system, however, should not be construed as signifying the products are similar. Quite the contrary. Windows NT (New Technology) is a true 32-bit operating system with file and system security and networking capabilities built in. The current version, 3.1, is the first release, but so numbered to be in line with regular Windows. History When IBM released the first mass-acceptance personal computer, it commissioned Microsoft to provide the operating system, and Microsoft came up with DOS. While several competitors were in the market, the one that was generally recognized as a threat was Apple Computers. While DOS allowed you to type cryptic commands to get desired answers (you hoped), Apple's computers used a graphic interface to represent the same tasks to make the operation more understandable. IBM approached Microsoft about coming up with a graphical operating system for its product line -- this would be the second operating system for IBM and thus was called OS/2 -- as in Operating System number 2. Microsoft agreed wholeheartedly that graphics were the way to go and began work on OS/2. At the same time, however, much to IBM's displeasure, Microsoft began working on a graphic interface to go with the existing DOS operating system -- Windows. To make a long soap opera story short, IBM argued with Microsoft -- accusing Microsoft of giving higher priority to Windows over OS/2, and IBM finally took OS/2 to work on themselves. Microsoft developed and released Windows and was sued by Apple for copying its ideas. Apple lost the lawsuit because Microsoft did not pilfer ideas from the Macintosh interface, but actually stole them from Xerox -- the same place Apple had originally misappropriated its designs. In the meantime, PCs became more robust and able to handle more complex operating systems. Novell owned most of the networking market, and more experienced users began experimenting with UNIX on their computers (since UNIX is a true 32-bit operating system with more than 25 years of development behind it). Novell bought Unix System Laboratories and looked as if it could actually go somewhere with it. To counter, Microsoft turned Windows into an operating system resembling UNIX but offering the friendliness that UNIX never had. And Paul asked Cricket to the dance, but she still loves Danny. Strengths Windows NT is incredibly easy to install, and there are only two package types from which to chose: CD-ROM and disks. I highly recommend the CD-ROM because it is the wave of the future. As cruel as it may sound, you are not ready to consider Windows NT if you do not have a CD-ROM drive available. Windows NT is a true 32-bit operating system capable of executing instructions faster than its slower 16-bit DOS and Windows counterparts. It is a truly secure system (meeting government C2 standards) -- requiring users to give a login name and password each time they start a session, and logoff when they finish. As with most login and password processes, the login name is a known variable such as Emmett or Karen. All users on the system know that I login using Emmett, thus if they want to send mail to me, they use the login name to do so. The password, on the other hand, is encrypted and known only by the user with the matching name. Aging allows passwords to expire and requires the user to enter another one -- providing a stumbling block for those trying to gain entry by guessing passwords. Multitasking allows multiple users to log into the operating system at the same time. When logged in, each can run multiple processes as well. Multithreading allows a processing job to be broken into components, with each component executing concurrently -- significantly reducing the amount of time it takes for a job to run, particularly background jobs. While being a separate operating system, Windows NT also has the ability to run DOS and 16-bit Windows applications that you may already own. While not capable of running these applications as fast as their native environments, Windows NT's decrease in speed is minimal. It is worth pointing out that regular Windows allows you to open multiple applications, but DOS was never designed for such. Thus when one window crashes, it usually crashes the others along with it. With Windows NT, when one window crashes, it affects only that window and no other. Multiple commands can be given on the command line by separating each with an ampersand (&). Additionally, Boolean logic can be incorporated into the command line as well. Separating commands with two ampersands (&&) causes the second part of the command to execute only if the first part successfully completed. Replacing the ampersands with two vertical bars (||) allows the second part of the command to execute only if the first part did not successfully complete. Networking capabilities are built into the operating system, with two different versions on the market. The first, standard Windows NT, supports all of the features described thus far and peer-to-peer networking (borrowed, if you will, from Windows for Workgroups). The second, Windows NT Advanced Server (which should be released by the time you read this article), adds the ability to store large quantities of data, as well as to create enterprise-wide networks surpassing the limits of individual servers. This puts Windows NT in the same dedicated server, enterprise network arena as Novell's NetWare. Weaknesses The first key weakness is a discrepancy between the lines separating the Windows hierarchy. How do users know when to use Windows NT versus regular Windows running on DOS? Which application is best for their needs? Add to this the fact that a new version of Windows has been promised for release in late 1994. Code-named Chicago, Windows 4.0 will be a stand- alone (not needing DOS) 32-bit operating system in its own right. There is even discussion that the graphical interface will differ slightly from the current product in favor of closer emulation of OS/2's Presentation Manager. With the release of this product, the lines of differentiation between Windows and Windows NT will blur even further. Windows 4.0 will also possess multitasking and multithreading capabilities, and supposedly run Windows 3.1 applications as quickly as in their native environment. Not only is there another version of Windows slated for release, but also of Windows NT. The next release, code-named Cairo, will feature object orientation -- an efficiency tool missing from the current release. Given these components, it is no wonder sales of Windows NT are not as good as they might be as many corporations hold off until the next release of both products before deciding which one to use. There is a huge resource requirement necessary to run Windows NT -- 75MB of hard-drive space and 12MB of memory are the minimums. In the real world, however, Windows NT crawls with only 12MB of memory -- 16MB of memory is a more realistic figure. (Windows 4.0, as now planned, will require only 4MB of memory). On the hard-drive side, 100MB is a more practical figure, and then you need room for applications. Another key weakness is the fact that while Windows NT tries to fill the shoes of UNIX, it is not UNIX. More than 25 years' worth of development have brought UNIX to where it is now, while Windows NT is still in its first release. Additionally, UNIX is portable to almost any platform, while Windows NT currently runs on only a limited number of platforms. At the present time Windows NT is still a fairly new player in the operating system arena and there are not a lot of applications written specifically for it. Yes, it will run programs written for others, such as regular Windows, but it runs them more slowly. Applications written specifically for Windows NT fly along at breakneck speed, but it is a trickling process by which vendors adapt existing programs. Favorite Feature Gone is the limitation on filename length, by which DOS so long held the world. When you created files in the past, you were confined to filenames of between one and eight characters in length. In addition, an extension could be applied of up to three characters. This allowed 11 characters to identify a file. With a handful of files on a system, identification is possible. When a computer user has been creating files for years, however, such as letters to customers, it becomes more and more difficult to distinguish one from another by the 11 characters. For example, consider the restrictions of DOS. Suppose there is a good customer with whom a great deal of correspondence takes place on a regular basis: we'll call the customer Bill Steen. With this much correspondence, a subdirectory can be created to hold the documents: C:\LETTERS\BSTEEN Beneath that subdirectory, an attempt is made to make the documents recognizable by their content: WARRANTY.DOC APOLOGY1.DOC APOLOGY2.DOC NEW--ADDR.DOC RENEWAL.DOC RENEWAL.LET RENEWAL2.DOC The date and time of which each file was modified also adds some clues as to the content, but still there is very slim information to go on when attempting to locate a letter that was written years ago. A better solution, available in Windows NT, is to expand filenames to a maximum of 256 characters -- including spaces and upper- and lowercase characters: Warranty on GE refrigerator Apology for failure to notify of increased premium Apology for running over yard ornaments on last home visit New address for home office Renewal of refrigerator warranty Letter of soon to expire warranty Second refrigerator renewal Proper names can even be incorporated directly into the filenames, eliminating the need to create separate subdirectories for each client. This is something that has been needed since the inception of DOS. Least Favorite Feature Even though graphically based, Windows NT does feature a command line mode. While there are a few discrepancies, such as CMD.EXE replacing COMMAND.COM, the command mode is essentially a mirror of DOS (CLS, DIR, etc.). The problem is that even though it is new, Windows NT is based on DOS 5.0 commands -- lacking are all the new features added with DOS 6. These include CHOICE, INTERLNK, MSAV, NUMLOCK, POWER, and VSAFE. Suggested Reading For additional reading on Windows NT, I highly recommend Inside Windows NT by John Stoddard (New Riders Press, $39.95) and Forrest Houlette's 7 Keys to Learning Windows NT (New Riders Press, $12.95). The first is a reference, much like the manual, but more thought out and understandable. The second book uses a task-oriented approach to presenting the things you need to know to effectively use Windows NT. Speaking of the manual, one of the things I found most enjoyable is that the last chapter covers installation -- "Things You Need to Know Before Running Setup," "Preparing the Computer for Windows NT," etc. I was always under the impression that installation chapters should be first and not last. I certainly hope no one reads 500 pages from cover to cover before getting to the things they need to know. Summary On the plus side, 32-bit Windows NT features a familiar interface, boots and runs without DOS, supports both multitasking and multithreading, has built-in networking, and a full line of security features. On the minus side, it requires a sizable system, runs on a limited platform and lacks object orientation. Add to that the fact that new versions of Windows and Windows NT are both on the calendar for release. Windows NT: Microsoft Corp., One Microsoft Way, Redmond, WA 98052-6399, (800) 426-9400; $495, Advanced Server $1495. REQUIRES: 386+ CPU, 12MB RAM, VGA, and a hard drive with 75MB minimum. -=*=- Windows NT breaks away from the 11-character filename restriction that has so long plagued DOS and Windows. For the most part in those operating systems, there has been no pattern to naming conventions, with a few exceptions. Following is an explanation of the few defined extensions in those systems: DOS $$$ Temporary files created by a pipe (|) operation. Under normal circumstances, these are created and removed in operations invisible to the user. Should the system or operation fail during a procedure, however, the files are left on the drive. Two sequentially numbered files are created for each pipe used on the command line. ASC ASCII document files that can be viewed with TYPE or MORE. BAK Backup files. BAS BASIC language programs for GW BASIC or QBASIC. BAT Executable batch files -- ASCII format. CHK Lost allocation files created in the root directory by CHKDSK. COM Command (executable) files (under 64K in size). CPI Code page information files. EXE Executable files not restricted in size. SYS Device drivers. TXT ASCII document (text) files. This is the default extension used by EDIT. Windows 386 Enhanced mode drivers. BMP Bitmap graphic files. CUR Cursor files. DLL Dynamic link libraries. DRV Device drivers. FON Character set font files. GRP Program Manager group files. HLP Help files. ICO Icons. INI Startup (initialization) files. MID Sound files (Music Instrument Digital). PIF Program Information Files for DOS applications. PCX Graphic files. REC Recorder files. VXD Virtual device drivers. WAV Sound Files. -=*=- Emmett Dulaney is the author of several computer books, including *Voodoo NetWare*. He can be reached at P.O. Box 353, Muncie, IN 47308, or on America Online, username EDULANEY. -=------------=- T-H-E E-N-D F-O-R N-O-W -=-------------=-