WIN32FOR.NEW New Stuff in Win32Forth by Tom Zimmer Complete list of Win32Forth demo programs; Name Subject HELLO.F Windows interfacing without objects WINBROWS.F File handling and window scrolling WINDEMO.F Graphics operations in a window WINDILOG.F User designed dialog box WINHELLO.F Windows interfacing with objects WINPAR.F Simple parallel port output WINSER.F Simple serial communications program WINVIEW.F Complete multi-file macro editor Help on ANS definitions is now available while editing in WinView by clicking the mouse on an ANS word, then press the F1 key. The ANS definition of the word will be displayed. ************************************************************************ ********************** Win32Forth Change History *********************** ************************************************************************ ************************ Version 3.1 Released ************************ March 28th, 1996 - 9:38 tjz Version 3.1 Release Updated Win32For.FAQ to the most recent status of Win32Forth 3.1. March 26th, 1996 - 10:45 tjz Winfried Clemens reported a bug in FILE-STATUS. FIXED Fixed a problem in FSAVE that when an FSAVE creates a single executable file, it doesn't run on Win32s under Windows 3.1 or OS/2. It seems the image resource is not readable for some reason. So now Win32Forth is shipped with a separate .IMG file so it will initially run on any platform. If an FSAVE is done on WindowsNT, then a single executable is created unless the FSAVE is prefixed with the directive WITH-IMG, which will force FSAVE to create the .IMG file. Steve Brault reported that I broke +CELLS when I installed the suggested changes. FIXED March 25th, 1996 - 9:18 tjz Martin Laeuter noticed that NEEDS wasn't working properly. FIXED Single file executable when programs are saved under WindowsNT. Windows95 and Win32s versions still need to save a .IMG file, since runtime resource modification is only supported under WindowsNT. March 21st, 1996 - 11:01 tjz Pedro Gomes noticed that the Save-Forth menuitem and function didn't work properly. FIXED Updated WinDilog.F and various Classes to allow messages from user defined buttons to be passed back and detected by the window containing the buttons. March 20th, 1996 - 17:39 tjz Added .POINTERS to display the names and allocation status of all "Pointers" in Win32Forth. March 19th, 1996 - 13:59 tjz Version 3.1B5 Thnk you to R. C. Philbrick for providing several small enhancements to kernel code words C@, CELLS, CELLS+, +CELLS and -CELLS. FIXED M. O. Maksimov reported bugs in WINVIEW, crashing when there was nothing to paste, WINDILOG, the dialog button not working and WINDEMO stack underflow caused by not using the local variable I defined. FIXED March 18th, 1996 - 11:22 tjz Version 3.1B4 Andrew found a bug that I introduced that was causing Win32Forth to fail to cell align code compiled into the application dictionary. This resulted in upto a 50% reduction in performance. This has been corrected along with a couple of other minor bugs that were effecting performance. Robert Smith reported a bug in DC.F that was causing printing of very long lines to fail to print properly. This has been fixed, though the fix still just truncates very long lines. Pedro Gomes reported that WinView was creating new files in browse mode if you were in browse mode when you create the file. He also reported an error in ?WIN-ERROR that was causing some console I/O parameters not to be reset properly after an error. FIXED March 13th, 1996 - 15:27 tjz Version 3.1B4 Major rework in the way program termination is done. You should always call BYE from within the application to exit the program. This will assure that all cleanup gets done correctly. Part of what Bye does is call back into Forth using the UNLOAD_FORTH function which executes the UNLOAD-CHAIN to allow the application to unload or release any memory or objects it has allocated. The most significant way this effects a program, is in how it deals with WM_CLOSE. The sample programs used to call EXIT_STUFF (now renamed to UNLOAD_FORTH) directly and then destroy the application window. This is now changes, so that WM_CLOSE just does a Bye and an additional function is added (with CHAIN-ADD-BEFORE) to the UNLOAD-CHAIN to destroy the application window. While this probably seems more complicated, it is important to do it this way so the window gets destroyed in a way to make Windows happy. All of this came about because I was trying to create a DLL to use with Visual Basic 4.0. It seems that Visual Basic 4.0 was trying to close an applicaiton window that was created by the DLL after the DLL memory had been released, causing an exception. So to fix this, I had to close the application window as part of the "unload" that got done when Visual Basic released the DLL. Another side effect of the above work, Is that you can now ONLY CREATE A DLL IF YOU HAVE VISUAL C++!!. The FORTHDLL.DLL wrapper that gets invoked by the external program needing the functionality of the DLL, needs to load the .IMG file from someplace. I was not able to figure out how to tell the DLL to load the .IMG file except by hard coding it into the source of the DLL. Since I didn't want to do this, I chose the second best approach, which is to include the .IMG file into the DLL as a resource. To do this you need Visual C++. The current example FORTHDLL.C files and project use this approach. If you need to create a DLL, go buy the tools. Maksimov requested Control Delete, Shift Insert and Control Insert in WinView conform to the standard way Microsoft programs work. FIXED Enchanced the debugger to detect messages being sent to NULL objects and display Method: NULL instead of just crashing with a windows exception. March 11th, 1996 - 11:01 tjz Version 3.1B3 Fixed a bug reported by Wolfbang Engler, that the console window sould always unmaximize when an error occured in the console. Added SIZESTATE that returns the size flag of the last WM_SIZE message to the console. The flag will have the value SIZE_MINIMIZED, SIZE_MAXIMIZED or SIZE_RESTORED. Fixed a bug reported by Steve Brault, that Win32Forth wasn't unlinking forgotten procedures from the procedure chain during a forget. FIXED March 8th, 1996 - 9:36 tjz Version 3.1B3 Added and updated the Win32For FAQ to the Help menu of Win32Forth. Added a new version of TRANSIT.F from Steve Brault to Win32Forth. He modified it to work properly with the dual dictionary structure. Thank you steve. Fixed the double screen update mentioned by Robert Smith in WinView during WinView startup. FIXED Fixed a bug in (FORGET). When I inserted the NFORGET.F into Win32Forth, I inadvertantly introduced a bug that prevented TRIM-CHAINS from being executed to cleanup any forgotten words on any chains. FIXED March 7th, 1996 - 11:03 tjz Version 3.1B2 Found that when running under OS/2, shared memory doesn't work, so I have made changes to Win32Forth to allow it to function even if shared memory isn't available. Unfortunately you can't use the linkage between Forth and WinView for source level debugging, but at least it doesn't crash. Found another bug in the memory allocation, it seems you need to "unreserve" memory under OS/2-Win32s or the memory doesn't get released even if the program is terminated. This is probably the same as Win32s under Windows 3.1, but the dual dictionary mechanism I added a while back really made this problem show up. Modified "unload" in Forth.c to unreserve the entire area of memory reserved when shutting down the application. This seems to have helped a lot. March 6th, 1996 - 20:13 tjz Worked all day, and found a bug in the code that allocates memory for the Forth application and system images. Under OS/2, when you ask for a virtual allocate of memory at a specific address, you may not get back the address you requested, and yet the call doesn't fail. WOOOOHHH!. I have reworked the code to "reserve" all the memory I will need, then I allocate it. This seems to work at least partially. OS/2 still crashes if I try to run more than one instance of a Forth program. I don't see how any version of Win32Forth ever released could have worked on OS/2, since I expected the virtual memory allocator to return the starting address of the area I requested at the same address as I requested it at. Received requests from Stephen Brault for some minor corrections which have been implemented as follows; 1. Modified Local variables to use ?UPPERCASE instead of UPPER, to allow them to be made case sensitive. 2. Modified the NEXT macro to save and set the prefix state, so the macro will always work properly. 3. Added a compiletime execution of INIT-SHARED-EDIT, incase a compile error occurs and Forht tries to access the shared memory area. It needs to be initialized. 4. Stephen requested ten (10) local variables instead of the eight I current have. There are now ten local variables. Also re-verified and renamed the project file for Symantec C++ Version 7.2. The project still compiles under Symantec C++ and seems to be completely compatible with Microsoft Visual C++. March 5th, 1996 - 14:40 tjz Modified the WinView editor to call up the DPANS94 help on a ANS word when the edit cursor is on an ANS word and you press the F1 key. Also modified WinView to allow it to hypertext compile the ANS document to create the needed HELP.NDX file so F1 can find the ANS words. The change to WinView was to modify the command line argument /INDEX so it accepts an argument which is the name of the .CFG file to read, and the .NDX file to write. The commandline to rebuild the ANS index file appears as; WINVIEW /INDEX HELP.CFG Since the ANS document isn't changing, this shouldn't have to be rebuilt. WinView was then changed to look in HELP.NDX when you press the F1 key. March 4th, 1996 - 14:18 tjz Added MESSAGES.F and updated MAKEDLL.F to better support the creation of a DLL using Win32Forth. Read the internal documentation in these two files for more details of making a DLL or passing broadcast messages to Win32Forth. Fixed a bug in TERM.C, that was preventing Win32Forth from printing under Windows95. Apparently this bug has been in Win32Forth since its first release as version 1.6. A document structure was not fully initialized before its use, in such a way that it the uninitialized fields were important to Windows95 only. WindowsNT and Win32s didn't care about those particular fields. Here is the offending function; ENTRY startprint (void) // start a printing session { DOCINFO di; if (ghdc == NULL) { if (!initprint()) return 0; } di.cbSize = sizeof(DOCINFO); di.lpszDocName = "Document"; di.lpszOutput = NULL; \ March 4th, 1996 - 14:22 tjz the following two lines were added. di.lpszDatatype = ""; di.fwType = 0; StartDoc (ghdc, &di); StartPage (ghdc); return 0; } An interesting thing about this bug, is that the documentation for StartDOC()'s DOCINFO structure used to only show an item for the MFC, but Visual C++ 2.2 now has an entry for the Win32API, which documents the additional fields that I wasn't initializing. In other words, they slipped this in under the door, and I missed it. By the way, the extra two fields are documented to be ignored by WindowsNT. February 23rd, 1996 - 16:29 tjz I removed keyboard macros in version 2.0, and Joerg Staben asked for them to be put back in, so I reworked keyboard macros to use the same mechanism that WinView used, and they are no available in the console window just like they are in WinView. Either with menu operations, or simple macros can be created with keyboard key combinations as follows; Control-Shift-S Starts or stops the creation of a keyboard macro. Control-Shift-M Executes the keyboard macro you created. Control-Shift-R Repeats a used specified times the keyboard macro you created. Also generalized the line editor keyboard interpretation somewhat. There is now a chain called LEDIT-CHAIN that you can attach keyboard interpreters to that will allow you to handle specific keys in a special way. here is an example of the existing code from the file MENU.F for recognizing the F1 key, and making it startup the editor on the file STARTUP.TXT. : F1-HELP ( -- ) \ F1 starts up the initial help file 0 c" STARTUP.TXT" $EDIT ; : ?F1-HELP ( char flag -- char flag ) dup ?EXIT \ EXIT if flag is already TRUE over K_F1 = if 0= F1-HELP then ; LEDIT-CHAIN CHAIN-ADD ?F1-HELP \ help key recognition The word ?F!-HELP tests "char" for a value of K_F1. If the char matches, then "flag" is inverted to tell other words on the chain that the key has been handled, and the function F1-HELP is performed. Since a key handler is already defined for the F1 key, you could over-ride the existing handler by creating another handler like the one above, then link it into the LEDIT-CHAIN using CHAIN-ADD-BEFORE instead of CHAIN-ADD. February 22nd, 1996 - 9:55 tjz Fixed a bug reported by Joerg Staben in ?MessageBox. It seems that when I moved several of the message box words together recently, I managed to break them all by incompletely improving them. This was causing stack underflow errors when a TRUE flag was passed to any of; ?MessageBox, ?ErrorBox, or ?TerminaeBox. FIXED Enhanded the source level debugger to highlight the specific word that the debugger is waiting to execute, rather than the entire source line. February 20th, 1996 - 14:15 tjz Enhanced the source level debugging capability of Win32Forth, to include highlighting the source line in the definition where the debugger is currently debugging. The directive WITH-SOURCE must have been used to enable the saving of source pointer information into the WIN32FOR.DBG file during the application compile, so it can later, be passed to WinView during debugging. February 14th, 1996 - 9:44 tjz Fixed a bug in ?NAME reported by Stephen Brault. IT wasn't able to properly detect that a CFA was passed to it and just return it instead of returning the CFA below the one passed in. FIXED Stephen also reported that an exception occuring during an FLOAD left the file open. FIXED ************************ Version 3.0 Released ************************ February 12th, 1996 - 13:15 tjz Added two example programs called WINSER.F a serial communications example of a simple terminal program and WINPAR a simple parallel port text output example. February 9th, 1996 - 11:29 tjz Fixed a bug in BUTTON.F reported by Joerg Staben, where tooltips wouldn't come up when running under Win32s. I had changed the timer message constants to a value greater than 64k, and this was recognized as a zero timer, which is no timer. Added additional error checking to TURNKEY, IS, POINTER, NEW-CHAIN, CHAIN-ADD and CHAIN-ADD-BEFORE to detect attempts to use system words in an application. Getting these warnings may be irritating, but they will help prevent the creation of turnkeyed applications that try to execute system words that are not present in memory at program runtime. If you don't want any of these warnings, just put SYS-WARNING-OFF at the top of your source file, and they won't occur. Fixed a bug in ?SYS-ADDRESS that could cause a crash under some conditions. Fixed a bug in _HEADER in the kernel that would not allow it to create a valid header in system space. Fixed TRIM-POINTERS per Stephen M. Brault, it needed to be updated to match the other changes to the FORGET system. February 6th, 1996 - 13:48 tjz Replace FORGET.F with the file NFORGET.F from Stephen M. Brault. He reworked forget to function in the dual dictionary environment. Thanks Steve! Fixed a bug in FLOAT.F that was allowing a word that should have been undefined (specifically '0DECR') to pass through as a valid floating point number. It was being confused by an optimization that was supposed to detect a floating point zero, and bypass further operations. Unfortunately it also wasn't fully checking to see if the string was really a floating point number either. Found by Brad Eckert. Thanks Brad! Fixed a bug in FLOAT.F, that was leaving a floating point zero on the floating point stack when it was trying to display the number. Also, added two sample programs; HELLO.F from Andrew Mckewan, which creates a sample hello world window. WINHELLO.F from Tom Zimmer, which does the same thing with objects. January 30th, 1996 - 11:14 tjz Modified the debugger to automatically startup the WinView editor when debugging a word. WinView will automatically track the first source line of any word you nest into or unnest out to. This feature can be turned on and off with the WITH-SOURCE and WITHOUT-SOURCE commands. The default is WITH-SOURCE. Added WITH-ADDRESS as a parameter to WORDS, that causes WORDS to display addresses with each word displayed. It is used in the form; WITH-ADDRESS WORDS HEX address are displayed with each name, and SYSTEM words are displayed in bold, preceeded by a '+' character. January 26th, 1996 - 17:34 tjz Thanks to Steve Brault for the following bug reports and fixes; Occurances of GOTOXY and GETXY needed to be changed to _LEGOTOXY and _LEGETXY. FIXED In WinView, pasting when nothing had been copied of cut, would crash the editor. FIXED NEXT in the assembler was different from NEXT in the kernel. FIXED He also reports that CLEAR-TRANSIENT crashes Forth sometimes, in the case where a non-transient word hashes to the same thread as a transient word. I have not been able to duplicate this as yet, thoughI'm sure it is probably a bug. January 24th, 1996 - 18:13 tjz Eliminated NEW$, in favor of a new facility called " localAlloc: " which can be used inside definitions that are using local variable. It works like this; : show-string { adr len \ local$ -- } 64 localAlloc: local$ \ allocate 64 bytes return stack \ to the local variable "local$" s" [" local$ place \ start with left bracket adr len local$ +place \ append string passed in s" ]" local$ +place \ append a right bracket local$ count type \ show the bracketed string ; \ local$ space is released here This method is fully reentrant, and recursive, though you will want to be careful about recursion, since the return stack is only 16k in forth, and less than 4k in a callback. January 23rd, 1996 - 9:24 tjz Fixed the bug in CLEAR-EXCEPTION which was using "9 CELLS OFF" instead of "9 +ORIGIN OFF" to clear any previous exception that had occured. Thank you Stephen Brault for that report. January 19th, 1996 - 14:51 tjz Added words to MAPFILE.F to allow sharing an area of memory with another program running under Win32s, Windows95 or WindowsNT. This facility is currently being used in UTILS.F about line 550, to create an interface between Forth and WinView, so Forth can tell WinView to open a new file without having to startup another copy of WinView. This is very valuble, since it helps keeps you from accidently editing multiple copies of the same file. : open-share ( z"name" length -- memory_pointer handle ) The Z"NAME" in OPEN-SHARE is a string that eash program that wants to access the shared memory uses top identify the name of the area of memory to access. LENGTH is the size in bytes of the size of the shared memory area. MEMORY_POINTER and HANDLE need to be saved and passed to CLOSE-SHARE when access to the shared memory area is finished. MEMORY_POINTER is used to access the memory area for both read and write operations. Any internal structure you may need for your application, you will have to create. : close-share ( memory_pointer handle -- ) Closes the shared memory area described by; MEMORY_POINTER and HANDLE. Also added a "Windows" menu to WinView, to allow selection of one of the first eight files you open during an edit session. January 17th, 1996 - 15:14 tjz Fixed a bugs in UNHASH and ?UNHASH that should have been using LINK> instead of the CELL+ they were using. This was preventing the decompiler from being able to decompile method names inside other methods. January 15th, 1996 - 13:55 tjz Removed the Whats New menu, and moved its item to the Help menu. Added an additional item to the Help menu for "Utilities in Win32Forth". January 12th, 1996 - 16:33 tjz **** Version 3.0001 **** Added WINBROWS.F a much simpler text file browse example to Win32Forth. This is essentially the simple file viewer that WinView evolved from. WinView is now so complex that it would be hard for anyone to understand it, while WinBrowse consists of only about 500 lines of source. January 11th, 1996 - 10:13 tjz Added timed auto save changes to WinView in the editor preferences dialog box. Fixed a bug in WinDemo. It was trying to create new color pens each time it decided to switch line colors when drawing in the bit window. Unfortunately it wasn't de-selecting the previous color pen out of the Device Context before trying to delete the previous pen. This error was not reported by Windows95, but did result in Windows95 running out of handles, since it would refuse to delete a pen that is currently being used. January 10th, 1996 - 8:57 tjz Generalized Window Controls to allow the definition of a new set of controls for easy creation by the user of windows, dialogs, and various types of buttons. Added the file CONTROLS.F, derived from the work of Freidrick Prinz that adds low level windows controls and an example dialog box. renamed GET-MOUSE-POSITION to GET-MOUSE-XY, since its stack parameters changed. GET-MOUSE-XY takes a window handle and returns the current mouse position relative to within the window. Also renamed CENTER-BUTTON? to IN-BUTTON? which takes an X & Y position, a button window Handle, and determines if the x&y position is within the button. December 15th, 1995 - 14:09 tjz Added the commandline capability to WinView to open multiple files in the form; " WINVIEW *.F *.TXT ". Only the first 128 files will be opened, but I think thats enough Fixed a minor bug that was keeping Winview from interrupting immediately when you were performing a long multiple file search for text and told it to stop. Modified the highlight display code so it will display an extra character highlighted at the end of any line that is completely highlighted. the extra character shows up as a black box (CR char), but it is now very obvious when an entire display line is highlighted, even the empty lines display as highlighted. So don't report this as a bug, it is a feature. REALLY! Open file operations in Winview now push other open files above ti in the file list up, rather than overwriting as used to be the case. And of course close file compresses out the file just closed from the file list. Shift End and Shift Home highlight to the end and beginning of the line respectively, and Control Delete does a word forward delete like a Control 'T'. December 14th, 1995 - 16:20 tjz Reworked the way number conversion works. Inserted a chain into NUMBER, so it can be extended to include the various types of number conversions that are needed. For example, currently included is normal 1234 number conversion, 'A' ascii conversion, 0x000 number conversion, and 1.242E4 floating point number conversion. Windows Constants are now stored in a dynamically allocated array, rather than in the Forth dictionary. A new number?-chain word called: WINCON-NUMBER? has been added to the number conversion chain that looks through the array and converts the constant string name to a value that is returned by NUMBER. The only side effects are that you cannot tick '"' a windows constant, and you need to have the file WINCON.F available in your FPATH while compiling code that uses Windows Constants. The later part of WINCON.F is loaded automatically the first time an attempt is made to look up a string that is not in the dictionary. Note this will cause a small delay (of about a second) the first time it occurs after Win32Forth is started up. Added a Tab Size preference setting to the WinView Editor Preferences Dialog box. The initial default is 8 spaces, but you can set it to any value between 2 and 32. It will be preserved across edit sessions. Note that WinView keeps a separate set of preferences in the registry for each directory you edit in. December 13th, 1995 - 14:47 tjz Re-wrote the Windows Procedure Library interface. At andrews suggestion, I haave modified the library interface so that the library procedures don't have to be pre-declared. Only the libraries that are going to be used need to be declared, and the PROC word looks through all the previously declared libraries to find the procedure you are looking for. Removed MARKUSED.F it is no longer needed. Added PIPES.F a simple implementation of Named Pipes. Only works on WindowsNT, since only WindowsNT supports creating a Named Pipe. ************************ Version 2.0 Starts Here ************************