WIN32FOR.NEW New Stuff in Win32Forth by Tom Zimmer Complete list of Win32Forth demo programs; Name Subject FILEDUMP.F A File Dump program contributed by Jih-tung Pai HELLO.F Windows interfacing without objects by Andrew McKewan 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 *********************** ************************************************************************ July 26th, 1996 - 12:00 ********************* Release Version 3.2 ********************* July 23rd, 1996 - 17:04 tjz Found and fixed a bug in WinView that would cause a crash when opening binary files. Seems I was using the wrong polarity conditonal on the test that was used to expand the line pointer table size. This resulted in more or less continuous pointer table expansion until all computer memory was used up. Not good! FIXED July 22nd, 1996 - 16:47 tjz Tested compiling the wrapper in Microsoft Visual C++ 4.0b2. It seems to work without any changes. July 19th, 1996 - 9:10 tjz Received a bug report from Jih-tung Pai, that there was a stack error in the word UNLINK-MALLOC, which is used by FREE. He was correct, it has been corrected. Thank you Jih-tung Pai. July 18th, 1996 - 10:46 tjz Modified "FSAVE, so it won't allow saving to the currently executing program. Even though you could try to do this before, it would fail. Now it fails, but warns that you shouldn't even try to do that. Improved the implementation for C+PLACE. Suggested by Mihail Maksimov. July 16th, 1996 - 9:04 tjz Bernd reported that s" could only be used once interpretively, and if it was used a second time, would overwrite the first string. I added a a defered word NEW$ that allows forward referencing the NEW$ semi-static buffers implemented in POINTER.F. Modified S", C" and Z" to use NEW$ when interpreting. July 12th, 1996 - 9:40 tjz Moved CurrentMenu and CurrentPopup into the Window Class, making them local to each window, rather than having them be global. This was needed so that an application could have more than one window, and have a separate menubar and right mouse popup menu for each window defined in an application. This change will require an application change as shown in the following code segment. -------------------------- SETTING POPUPBAR --------------------------- The following lines were extracted from WINDEMO.F. NOTE: that several lines not relavent to this illustration have been removed to simplify the example code. ------------------------------------------------------------------------- :M Classinit: ( -- ) ClassInit: super \ self to CurrentWindow \ COMMENT OUT THIS LINE \ Demo-popup-Bar to CurrentPopup \ COMMENT OUT THIS LINE ;M :M On_Init: ( -- ) On_Init: super 2 SetId: vga-bit-window self Start: vga-bit-window \ self Start: CurrentPopup \ COMMENT OUT THIS LINE Demo-popup-Bar SetPopupBar: vga-bit-window \ ADD THIS LINE ;M ------------------------------------------------------------------------- MORE NOTES: WinDemo is an example of an application that has a window that contains a child window. The child window is the window into which drawing is done. When the right mouse button is pressed, it is located within the area of this vga-bit-window, so the SetPopupBar: method must be performed on the child window vga-bit-window. In an application that has several child windows, a separate right mouse popup menu can be installed for each child window in the application. This results in a much more flexible implementation. Moved several facilities into WINDOW.F; SetPopupBar: SetMenuBar: LoadMenu: Added to ClassInit: self to CurrentWindow Added to On_Close: Close: CurrentMenu These changes simplify applications that use menus and right mouse popup menus. All example programs that use these facilities have been updated; WINVIEW, WINDEMO ------------------------------------------------------------------------- July 11th, 1996 - 15:46 tjz Included a new version of Jim's assembler 486ASM.F, version 1.24. Jim fixed a couple of bugs. Made some modifications to the hyper text compiler to change the file recognition character from 249 to a TAB. The 249 character was causing problems with the extended character set support. Also enhanced the code to exclude comments in source from being hyper text compiled. Modified all occurances of 'MessageBox' in Win32Forth to put up a message dialog that is application modal. It was just too easy to attempt to invoke multiple instances of the same message dialog, which would then cause a crash when they were closed, because the message box handle would already be NULL. The only significant difference you will see, is that message dialogs now appear in the center of the screen instead of in the center of the application window. July 10th, 1996 - 14:41 tjz Made changes suggested by Marcos Cruz to allow extended character sets to be used with Win32Forth and WinView. I don't know if they are complete, or even absolutely functional, since I don't use anything other than American English, but I'm sure someone will tell me if there is a problem. Also added UPPER-CASE and new LOWER-CASE functions to WinView to use the Win32API calls CharUpperBuff and CharLowerBuff for case conversion. These should work properly for all countries. At least in theory. July 1st, 1996 - 11:12 tjz Made some minor adjustments to DC.F and WINVIEW.F to correct problems with the way WinView printed text containing underscores on A4 (A5?) paper. It was truncating them, making them invisible. Not good. FIXED I think. June 28th, 1996 - 12:14 tjz Corrected a bug in OPTIMIZE, in file OPTIMIZE.F. I was optimizing away 'POP EBX' followed by 'PUSH EBX'. This is bad! Need to replace them with the instruction; 'MOV EBX, 0 [ESP]'. FIXED June 27th, 1996 - 10:51 tjz Renamed MAKEDLL.F to FORTHDLL.F to be more consistent with the other example files used in the FORTHDLL. Updates several of these files and added some new one. The list is something like this; --- Forth FORTHDLL.DLL Application Creation Files --- MESSAGES.F loaded first onto Win32Forth, defines message support, and the facility to define callable DLL subfunctions. FORTHDLL.F loaded after your application. Saves the Forth Image as a resource in FORTHDLL.DLL, and automatically builds MESSAGES.H and MESSAGES.BAS which are used to interface to the FORTHDLL.DLL from Visual C or Visual Basic. --- Visual C FORTHDLL.DLL Wrapper Project Files --- FORTHDLL.MAK Visual C project file to build the DLL wrapper. You must compile this with Visual C before doing anything with Win32Forth to make a DLL. FORTHDLL.DEF File needed to build FORTHDLL.DLL FORTHDLL.RC File needed to build FORTHDLL.DLL FORTH.C File needed to build FORTHDLL.DLL TERM.C File needed to build FORTHDLL.DLL FORTH.ICO File needed to build FORTHDLL.DLL ICON1.C File needed to build FORTHDLL.DLL FORTH.H File needed to build FORTHDLL.DLL TERM.H File needed to build FORTHDLL.DLL --- Visual C FORTHDLL.DLL Access Files --- FORTHDLL.H The automatically generated message constant file that would be included in a Visual C project file that wanted to access the FORTHDLL.DLL. No project for Visual C is provided, only the following Visual Basic demo program following. --- Visual Basic FORTHDLL.DLL Access Files --- FORTHDLL.VBP Visual Basic project file to demonstrate calling FORTHDLL.DLL. MESSAGES.BAS The automatically generated message constant file that must be included in your Visual Basic project file. FORTHDLL.BAS Demonstration Visual Basic source file that contains the interface to the FORTHDLL entry point. Making a DLL requires the following steps; 1. Build the FORTHDLL.DLL with Visual C. 2. Edit and compile your DLL application including MESSAGES.F at the beginning nd FORTHDLL.F at the end. DLL entry points are defined with the :DLLFunc subfunction defining word. After compiling FORTHDLL.F, the DLL FORTHDLL.DLL will have been updated with your applications Forth Image. 3. Edit and compile the Visual Basic FORTHDLL.BAS file to include the :DLLFunc subfunctions you added to FORTHDLL.DLL. 4. Debug and iterate on steps 2 through 4 until you application works the way you want it to. 5. Save the compiled Visual Basic program as an EXE. 6. Run the Visual Basic EXE, and you are done. 7. Distribute the DLL. Added another form of optimizing to OPTIMIZE.F. It code compiles inline any simple colon definitions is finds while optimizing. That is it looks inside any colon definition it finds, and if the colon definition contains only optimizable words, then the definition is inlined with optimization rather than switching back to high level code and compiling a threaded call. June 26th, 1996 - 10:54 tjz Added additional word documentation to FKERNEL.F. June 25th, 1996 - 12:46 tjz Several people found that there were open file problems when starting WinView with the "reopen same file as last session" button option selected. This was caused by a bug in the Registry Get Key function. I was using a local string buffer that was getting deallocated before it was being used. FIXED Also fixed some problems related to automatically saving edit changes. June 24th, 1996 - 14:55 tjz Added additional optimizations as suggested by; "Maksimov M.O." mak@xperts.rtc.neva.ru He found that a bunch of kernel code words begin with "PUSH EBX" and end with "POP EBX". These pairs can be optimized out of existence. June 10th, 1996 - 11:20 tjz Got rid of the EXCEPTIONS vocabulary, moved its few words into HIDDEN. Moved Registry support lower in the load order. June 7th, 1996 - 11:22 tjz Added several Pinhole optimizers to OPTIMIZE.F. It now looks for literals to preceed words like +, -, AND, OR, XOR, !, +!, C!, C+!, LSHIFT, RSHIFT and +TO. When these are found, it compiles an instruction that contains the preceeding literal, saving several bytes. These optimizers recover most of the extra space consumed by simply turning on the optimizer and laying code down inline right out of the kernel. June 5th, 1996 - 9:47 tjz Fixed several bugs in OPTIMIZE.F. I have been able to compile the entire WinView Editor in optimize mode, and have the resulting executable runable. This is not however something I would normally want to do, since the resulting program is about twice as big as the un-optimized program. The optimizer is for speed, and as such should only be used on program code sections that need to be faster, not entire programs. Also received a bug report from Ribert Smith. He found that the print dialog in WinView wouldn't come up for user selection after the first time you printed. This was a bug in the wrapper relating to the way I was initializing the printer. FIXED NOTE: The Print button in Winview is designed to display the print dialog only the first time you go to print. If you have already printed at least one page, then the printer button on the toolbar just goes ahead and prints. If you want to select parameters other than the ones used last time you printed, then you need to use the "Print File..." menu item under the File menu. At the suggestion of Robert Smith, I also added an option in the WinView preverences dialog to turn off the printing of page borders. Currently this also diables the printing of the footer date, and page numbers. Munroe C. Clayton and others reported a bug in F** and FEXP in the floating point. I passed the report on to Robert Smith, and he supplied information that his original testing was done on another assembler. Subsequent testing determined that the code generated by the earlier assembler for the instructions FSUB and FSUBR was reversed. This was effecting the assembly functions FEXP and FEXPM1. These are used in various floating point operators. I determined with Andrew's help that Jim's assembler was generating correct instructions, but the floating point code had been adjusted to produce correct code with the previous assemblers reversed instructions. I corrected FLOAT.F to account for Jim's assembler being correct. I hope this fixes the problems, but I will have to wait for further feedback and verification. June 3rd, 1996 - 13:46 tjz Made TempRect into an object of class Rectangle. This will have a significant impact on any application code that uses the word TempRect. The new object TempRect is defined at the end of CLASS.F, and provides methods for setting, erasing and displaying the fields of the rectangle. Usage of TempRect is much cleaner than before, but it is quite different, so you will want to look as how it is used in the various places in Win32Forth for examples of how it is now used. Here is an overview; Old way \ init TempRect and return x y 'x 'y TempRect dup>r \ its address r@ hdc Call GetClientRect ?win-error \ call windows with rect r@ 2 cells+ @ ( -- n1 ) \ get the "right" field of rect r> DeleteRect \ erase TempRect after use New Way x y 'x 'y SetRect: TempRect \ init TempRect TempRect.AddrOf hdc Call GetClientRect \ call window with rect TempRect.Right ( -- n1 ) \ get the "right" field of rect EraseRect: TempRect \ erase TempRect after use As you can see it certainly is quite different. I think it is also much more readable than before. While the Old way appears to have been reentrant, in reality there was really only one TempBuf, which was re-used each time TempRect was referenced. WARNING: I have found that the DOTTED '.' notation cannot be used on dynamically created objects. This is because there is no way currently to determine at compile-time which class the object refers to. This is inconvenient in the cases similar to the above where you might like to create a rectangle dynamically and then dispose of it after use. May 31st, 1996 - 13:24 tjz Modified the way the menu and toolbar words work. Added a new word that must be used to complete the definitions of any of the "BAR" words, such as MENUBAR, TOOLBAR, POPUPBAR etc.. All of these bar defining words should be completed with the word ENDBAR. This change allows the lower level utility words that are used in building the various bars to be hidden except when they are needed, reducing the number of functions dumped in the Forth vocabulary by a significant number. Here is an extract from the example program WINDEMO.F that illustrates the use of ENDBAR. POPUPBAR Demo-Popup-bar POPUP " " MENUITEM "Open File..." 'O' +k_control pushkey ; MENUSEPARATOR MENUITEM "Print File..." 'P' +k_control pushkey ; MENUSEPARATOR MENUITEM "Exit" bye ; ENDBAR May 30th, 1996 - 18:09 tjz Added a file MODULE.F to Win32Forth. A simple implementation for function scoping, used in the form; INTERNAL \ internal definitions start here ... define the internal definitions ... EXTERNAL \ externally available definitions start here ... define the definitions you want to be available externally ... MODULE \ finish up the module. There are other implementations, but this was one I liked from way back. Internal definitions are automatically placed in the HIDDEN vocabulary, so they can be obtained later if needed. May 29th, 1996 - 10:05 tjz Moved CLASS.F down lower in the load order to make OOP available earlier in the extend process. May 24th, 1996 - 12:10 tjz Moved the local variable support down into the kernel. No support by the meta compiler, but at least local variables can now be used as soon as the kernel starts up. May 23rd, 1996 - 15:48 tjz Modified the Control-L (load highlighted text) command in WinView to feed the highlighted text through the Win32Forth keyboard macro mechanism rather than feeding it through a file called TEMP.F. The way it now works, is WinView simply does a text copy to the clipboard of the highlighted text, then tells forth to perform a paste and load, which causes the text in the clipboard to be entered through the keyboard. Also added a Paste function in the new Edit menu to Win32Forth. May 22nd, 1996 - 14:47 tjz Added some more instructional sections about objects to STARTUP.TXT. Re-inserted 'DINT' as an object data type, so it could be used in the directory continguous data structure example in STARTUP.TXT. May 21st, 1996 - 9:19 tjz Added the words to support dynamic objects as follows; HEAP> ( -- ) allocate and init an object of "classname" NEW> ( -- ) synonym for HEAP>, more C++ like DISPOSE ( a1 -- ) dispose of object a1 after executing the default distructor method "~:" ~: the default object destructor method Dynamically allocated objects are initialized using the ClassInit: method, just like any other instance of a class. When you are done using the object, you can dispose of its instance by passing its address to DISPOSE, which will execute the destructor method "~:" and then release the memory space used by the object. Moved the hashed dictionary code out of PRIMUTIL, down into the kernel and meta compiler. Moved N(FIND) down into the kernel, and renamed it to (FIND), eliminating the old (FIND) from the kernel. There used to be a word called HASH, that was only used by the Object code, and another word called "#HASH that was used by the Forth system for headers and dictionary searches. I have renamed HASH to METHOD-HASH, to avoid someone thinking the two hashes are the same, they are not. May 20th, 1996 - 15:02 tjz Revamped memory allocation and deallocaton. Dynamic memory that is allocated by a program will now automatically get released, even if you don't release it. This functionality is built into ALLOCATE, MALLOC, FREE, REALLOC, RELEASE, and RESIZE, as well as POINTERs. A side effect of this modification, is that FREE which previously returned a dummy FLASE flag, because no FREE could fail, now validates the pointer about to be freed, and will return a TRUE (failure) flag if the pointer isn't on the list of valid memory pointers. The word RELEASE which used to just discard the dummy flag, now checks the flag, and performs an abort if the FREE fails. The side effect of this, is that you need to use FREE instead of RELEASE if you want to handle errors yourself. May 17th, 1996 - 14:44 tjz Additional changes to CLASS.F, to add a pair of words RECORD: and ;RECORD to tell the compiler to force all data objects defined INSIDE A CLASS between these words to be contiguous, and to define a data object that doesn't consume any space, but returns the address of the start of the record. They are used as follows; :Class Point \TEMP.F and then WinView tells Win32Forth to perform an FLOAD \TEMP.F. NOTE: Due to thread prioprity problems, you may need to move the mouse over the Win32Forth console window to allow it to get some execution priority so the highlighted text will actually be loaded. Adde the additional debugger commands to the Edit menu as; Control+B set breakpoint and open debug window Control+D just open the debug window April 30th, 1996 - 14:28 tjz Enhanced the debugger interface from the WinView editor. WinView's debug window now displays the current stack contents. Added an experimental modification to _msgFind, that allows object data to be accessed directly without having to use the Get: method. You just use the format "Objectname.Dataname" in your source, and it just works. There are some restrictions, for example you can't name any objects starting with a number, for example; "345.dataname" won't work, since 345 must be treated as a number if used by itself. April 29th, 1996 - 15:51 tjz With Andrew's assistance, We have added DOT notation to classes. It is now possible to access the instance variables for a class or object using the Get:, Put: and Add: methods; :Class DiskDrive SequentialState: theprinter SetPage: theprinter SetPage number requires "SequentialState:" to be set TRUE. April 18th, 1996 - 13:58 tjz Martin Laeuter provided some changes to make decompiling handle local variables better, and to cleanup the debugger when displaying conditionals. Michael Schroeder requested that I switch the dialog template length count from being a WORD to being a LONG. FIXED April 16th, 1996 - 17:05 tjz Added CELL-SORT and BYTE-SORT to the kernel, to perform a sort of an array of cells or bytes. Removed FLOOK, now that multiple file search is in WinView, it isn't needed. Added SKIP'C' to the kernel, to allow 's' to put a lowercase 's' on the stack instead of an uppercase 'S'. Fixed a bug in DIR that caused it to leave junk on the data stack if the DIR was terminated early. Added optimizers for CONSTANT, VARIABLE, CREATE, VALUE and TO VALUE to OPTIMIZE.F. April 12th, 1996 - 16:40 tjz Added an optimizer to Win32Forth, that allows sections of function or entire functions to be converted into inline assembly language. This is accomplished by copying any code primitives used directly inline into the colon definition being created. The overall result is that calls to NEXT are eliminated, often resulting in much faster execution for inner loops. Of course code expands significantly, so it would be wasteful of program .emory to optimize an entire program. The file OPTIMIZE.F contains the words used to perform optimization, but it can be simply used as follows; : test ( -- ) OPT[ buffer count bounds do i c@ 0x5F and i c! loop ]OPT ; Not all words will be optimized, but the optimizer will automatically turn optimization off for those sections of code that it can't optimize, so the above will work. Actually though a better definition for the above function would be; : test ( -- ) string count bounds do OPT[ i c@ 0x5F and i c! ]OPT loop ; This is because most of the execution time is spent inside the loop running the sequence: "i c@ upc i c!" over and over again. The above compiles to the following; : TEST STRING COUNT BOUNDS DO 303C0h IS CODE push ebx \ 303C4 53 mov ebx , 0 [ebp] \ 303C5 8B5D00 add ebx , 4 [ebp] \ 303C8 035D04 mov bl , [ebx] [edi] \ 303CB 8A1C3B and ebx , # FF \ 303CE 81E3FF000000 push ebx \ 303D4 53 mov ebx , # 5F \ 303D5 C7C35F000000 pop eax \ 303DB 58 and ebx , eax \ 303DC 23D8 push ebx \ 303DE 53 mov ebx , 0 [ebp] \ 303DF 8B5D00 add ebx , 4 [ebp] \ 303E2 035D04 pop eax \ 303E5 58 mov [ebx] [edi] , al \ 303E6 88043B pop ebx \ 303E9 5B mov esi , 0 [esi] \ 303EA 8B36 add esi , edi \ 303EC 03F7 \ NEXT, MACRO mov eax , 0 [esi] \ 303EE 8B06 add esi , # 4 \ 303F0 83C604 mov ecx , [eax] [edi] \ 303F3 8B0C38 add ecx , edi \ 303F6 03CF jmp ecx \ 303F8 FFE1 END-CODE LOOP ; Not the most optimium assembly language that can be generated, but all the extra executions of NEXT have been removed, which in this case will make the inner part of the loop run about three times faster. Later improvements to the optimizer may add pinhole optimization to improve the quality of the generated code. April 5th, 1996 - 10:39 tjz Wolfgang Engler noted that after debugging under some conditions, the console menus didn't work. FIXED April 3rd, 1996 - 10:51 tjz Spent a couple of days working on the memory allocation code, to get it to work right under OS/2. Finally determined that the free memory number displayed in the WIN-OS/2 About box is either not telling me the truth, or OS/2 is broken with respect to freeing memory. I reached this conclusion because when I tried Win32Forth under Windows 3.1 with the same version of Win32s, it reported that memory was being freed properly. Modified CFA-WATCH, the debuggers source view linkage to bring the Win32Forth console window back to the front when starting a debug session. March 28th, 1996 - 17:17 tjz Updated OPEN-SHARE to hopefully be compatible with Win32s. ************************ 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 compile time execution of INIT-SHARED-EDIT, in case 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 ************************ December 11th, 1995 - 11:37 tjz Received the Meta compiled kernel from Andrew and began its integration into Win32Forth as a replacement for FKERNEL.ASM. Andrew took great care to make the new Forth kernel almost identical with the old .ASM kernel. It is much more readable and modifyable than the .ASM kernel, so some changes to the kernel will probably be occuring over the next few months. Removed MAKE.BAT which used to assemble FKERNEL.ASM, the kernel used with TASM32, also removed FKERNEL.ASM and KVIEW.F from the installation file. KVIEW.F is no longer needed since the meta compiler builds the view fields properly. Added META.BAT which meta-compiles the new Forth kernel. The new files added are META.F and FKERNEL.F. Win32Forth is now a true circular system (excluding the wrapper) that can meta-compile, extend and re-meta-compile itself. Of course this means you can shoot yourself in the foot quite easily, so be sure to back things up before making changes to the kernel. I have to a apologize to Steve Brault for not using the high-level Forth kernel he donated. I can only say that I was holding out for a true meta compiled kernel, and Andrew finally found time to do it. Sorry Steve The meta compiler is very F83ish, being derived from an earlier meta compiler Andrew worked on. December 7th, 1995 - 20:32 tjz Found and corrected several memory leaks that were a problem for Win32s. There still seems to be a small leak associated with the toolbar code that I haven't been able to find, but since it only consumes about 10k from the virtual memory each time the editor is run, I guess we will have to live with it till it gets found. Things are actually much better today in this respect since yesterday, when the editor would have left a couple of hundred kbytes un-recovered. December 6th, 1995 - 11:00 tjz Modified Win32Forth to run again on Win32s. Switched back to a relative address system. One side effect of this, is that when the system is running on Windows95 or WindowsNT, it can create a single file executable. When running on Win32s, it must create a seperate .IMG file since Win32s won't let Win32Forth open the currently running executable to read it in. Also added a file KERNEL.BIN which is a duplicate of FKERNEL.EXE. When FSAVE is done from Win32s, it can't copy the currently executing program file, so I needed another copy of the executable to copy. WIN32S NOTICE: Even though Win32Forth will now run on Win32s, I have found that Win32S has some memory leaks (bugs) that cause it to consume and not release memory from Windows. The result of this is that starting up and shutting down Win32Forth programs gradually uses up all of your memory until windows says there is no more left. You then have to quit windows and re-enter windows again to recover all that space. I have not been able to figure out where the memory leaks are, but if and when they are found, I will fis this problem. On windowsNT this is not a problem, since it keeps track of all memory used by an application and automatically releases it when the program terminates. Under Windows95, the problem may still exist, but to a lesser degree since Windows95 has a better memory manager than Win32s. Fixed a couple of bugs in the registry code that was preventing Win32Forth from being able to save and recover its preferences in the WinView editor when running under Windows95 and Win32s. November 30th, 1995 - 16:53 tjz Fixed a bug in the date formatting word >MONTH,DAY,YEAR" and changed the paste date function in WinView to use this new format as you can see from the dateand time on the line above. Added a file BUILD.F, which contains a new set of defining words to replace BUILDS DOES> (BUILDS and DOES> are still present). They were presented at FORML last week, and appear very interesting with respect to target or meta compiler development. The words are BUILD and DO:, they are used as follows; First, define the BUILDING part of the defining word : CONSTANT ( n1 -- ) build DOCON , ; Later, define the EXECUTION part of the defining word do: DOCON ( a1 -- n1 ) @ ; 2 CONSTANT two The defining word CONSTANT will build a word that will have a runtime behavior set to do whatever the most recent (do: type) definition of DOCON specifies. The runtime behavior (the do: part) must be defined before actually using the defining word, but it need not even be in the same vocabulary as BUILD as long as it is in the search order. Note that you must define the DO: part with 'DO:', and not ':' as do: prepends special runtime code for BUILD to connect to. ************************************************************************* ************************************************************************* ********** FORML 1995 Release Version 1.6, November 24th, 1995 ********** ********** FORML 1995 Release Version 1.6, November 24th, 1995 ********** ********** FORML 1995 Release Version 1.6, November 24th, 1995 ********** ************************************************************************* ************************************************************************* 11/21/95 22:9 tjz Modified the toolbar code in BUTTON.F so the toolbar .BMP file is loaded right into the program image. This is an improvement because it will always be available. Also modified the system to append the forth image to the wrapper, so now a program like WinView only consists of one file, WinView.EXE instead of three files; a .EXE, a .IMG, and a .BMP. The only gotch is that I still need to open the .EXE to load the image portion of the program into memory when the wrapper runs. 11/21/95 11:35 tjz Separated out the code to build a DLL in Forth to MAKEDLL.F. You just make a copy of this file, edit it and load it onto Win32For.EXE after loading your application. It will build an image file called FORTHDLL.IMG to go with the provided file FORTHDLL.DLL. Unfortunately you will need to rebuild FORTHDLL.DLL with visual C++ if you want the name of the image file to be something other than FORTHDLL.IMG, since it had the name of the .IMG file embeded with it. I haven't been able to figure out how to get the DLL to obtain its won name and use that for the name of the image file like Win32Forth does. 11/20/95 13:51 tjz Modified the Win32Forth loader to save console windows position and size. So the console will now come back up wherever you last put it. 11/15/95 20:38 tjz Downloaded Jim Schneider's latest version of the 486ASM Version 1.23. It has a few minor bug fixes as described in the file 486ASM.DOC. ************************************************************************** **** NOTICE ***** The following description of MARKUSED is no longer valid it was removed December 12th, 1995, no longer needed tjz ************************************************************************** A new file MARKUSED.F has been added (it is commented out in EXTEND.F) that allows unused Windows Constants, Windows Procedures, the Assembler and Floating Point to be excluded from applications that don't need them. The way it works, is you add MARKUSED.F back into EXTEND.F, save it with a new name like MYEXTEND.F and make a batch file like the one following; del usage.db \ delete any existing database fkernel fload myextend.f bye \ Build full Win32Forth with database win32for fload winview.f bye \ build full WinView with database dir winview.img \ display the size of the image file fkernel fload myextend.f bye \ build small Win32Forth using database win32for fload winview.f bye \ build small WinView using database dir winview.img \ display the new image size del usage.db \ delete the database we built fkernel fload extend.f bye \ build the full Win32Forth again What is going on? And well you may wonder. USAGE.DB is created and expanded by the first two loads, until it contains a history of all Windows Constants and Windows Procedures used by Win32Forth and WinView. The third lines rebuilds Win32Forth using the database, so only the Windows Constants and Windows Procedures needed are loaded. This saves about a 100k bytes of dictionary space. In addition you will note at the end of WINVIEW.F, the words NO-ASSEMBLER and NO-FLOAT are used. This tells Win32Forth not to load either the assembler or floating point, saving another 100k bytes. A batch file SMALLWV.BAT is like the above included. You will see Win32Forth drop from about 521k for the first version of WinView.IMG down to about 330k for the second. Still too large, but at least it is somewhat smaller. Finally we delete the usage database and rebuild Win32Forth using the normal EXTEND.F file, so it will contain all of the Windows Constants and Windows Procedures in case you want to use them. All this does take time to compile, but at least it only needs to be done before shipping, and it does save a bunch of memory. Be sure to delete the comment lines from the above example before you try to run it, the DEL command doesn't like a backslash on the line. 11/6/95 14:39 tjz Added support in WinView for Drag and Drop of files from the File Manager to WinView. WinView can handle upto 128 files at a time, and if more than that are dropped on it, then it will wrap around and replace files opened earlier with the files opened later. Here is an extract from WinView illustrating the changes (minimal actually) required to allow a file to be dropped onto WinView; \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \ Support for Drag and Drop files from File Manager to WinView \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ :M ExWindowStyle: ( -- ) WS_EX_ACCEPTFILES \ allow files to be dropped on WinView ;M create drop-buf max-path allot :M WM_DROPFILES { hndl message wParam lParam \ cFiles -- res } ?save-text 0= if 0 \ zero buffer length NULL \ NULL buffer pointer -1 \ get count not a file wParam \ HDROP structure Call DragQueryFile to cFiles \ -- count of files dropped cFiles 0 \ loop through files requested ?do 255 \ max allowed string length drop-buf 1+ rel>abs \ string buffer address i \ index of file to get wParam \ the HDROP structure Call DragQueryFile \ return the length of file drop-buf c! \ stuff it into the string buf drop-buf count "+open-text \ and open the file loop \ loop till we have opened all wParam Call DragFinish drop \ close the drag operation then ;M \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 11/3/95 11:25 tjz Modified EXTEND.F to stop creating the DLL version of Win32Forth every time Forth is compiled. The code at the end of EXTEND.F is just commented out, so it can easily be put back in if you need to make a DLL. Even better, copy the code into a file, and load it on top of Win32Forth to make your DLL. I also deleted the FORTHDLL.EXE and FORTHDLL.IMG file from the archive to save a couple hundred kilo-bytes in the install file. Also added the Sort Paragraph function from the NEWZ editor into WinView. 10/27/95 14:59 tjz Andrew and I modified the Win32Forth to use ABSOLUTE addresses instead of relative addresses. We picked the 1 Gigabyte address to minimize the possibility of conflicts with Windows95 and WindowsNT operating system facilities. The Forth kernel can be relocated to another address by re-linking with a different address: TLINK32 /c /n /x /B:3FFF0000 FKERNEL.OBJ Win32Forth is linked to begin execution at at 0x40000000 by passing a link address 64k lower (0x3FFF0000) to the linker. Some day when we get a true Forth kernel, these problems will be a thing of the past. The most significant problem this may create is for those people that want to make DLL's with Win32Forth. While it should work ok to make one DLL, making two DLL's that work together with one program won't work unless one of the Forths is linked to run at an address that doesn't conflict woth the other DLL. So..., You are probably wondering why we have chosen to do this all. Well, we were trying to get OLE working, and the complexity of all the conversions between relative and absolute address in structures containing structures was just too much. We couldn't get it to work. So we are now going to try using absolute addressing to get it to work. A couple of interesting things cropped up in this process, for example; I found some bugs that hadn't shown them selves before related to accidently getching from an uninitialized pointer. Since they normally contain zero the relative Forth worked just fine, but the absolute forth crashes if you try to fetch from zero, since forth starts at address 0x40000000. Hopefully things will be even more robust because of this change, but I guess you can never tell. 10/24/95 15:21 tjz Made the multiple file search box interruptable and more stable. It hopefully wont crash any more. 10/19/95 17:03 tjz The hypertext Compiler is now working in WinView. You can also invoke winview with the /INDEX command line option, to generate a new WINVIEW.NDX file. WinView uses WINVIEW.CFG to specify the parameters for the index file it builds. This compiler doesn't have quite as many esoteric features as HYPER.COM, but it should be sufficient for Win32Forth users. Here is an except from the original HYPER.DOC file on how to use the index compiler: +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ CONFIGURING THE HYPERTEXT COMPILER +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Index Compiler Directives Three index compiler directives are currently supported, they each start with the word "TYPE" followed by a type number and a "string" parameter: 0 "string" Pick up and index the word IMMEDIATELY following string. No space delimiter is required. If you want to space delimit the string, include a space within the quotes. Examples: ": " "CONSTANT " "CODE " etc. This type can pick up words following, as will be the case with the above examples, or you can pick up words starting with a character by not including a space at the end of the string. 1 ":" Pick up and index the word preceeding this symbol. That is index all words that end in a ":" character. Normally used for assembler labels. name: This will include name in the index file. 2 "string " Pick up and index the word at the start of this line preceeding this string. Again this is typically used to include references to the assembler word LABEL as it is used in some assemblers. here is an example: symbol_name LABEL Symbol_name will be included in the index file. 3 "string " Index a matching word at found at the start of a line. Several of the above index commands can be included one per line before the line starting with a ";" character. The index compiler currently supports up to sixteen (64) index compiler commands of the above formats. WINVIEW.CFG, Example lines The following lines can be included in HYPER.NDX tell the compiler to index forth functions, constants and variables. These are only examples of the type of entries that can be included. TYPE 0 "CODE " TYPE 0 "CREATE " TYPE 0 "CONSTANT " TYPE 0 "DEFER " TYPE 0 "VARIABLE " TYPE 0 "VALUE " TYPE 0 "ARRAY " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 10/18/95 18:06 tjz Added paragraph reformat to WinView. Also factored the menus to include a Format menu. The Edit menu was getting too cluttered. 10/1795 15:20 tjz Added a floating list of open files to WinView, making it very quick to flip back and forth between several files. Added simple word wrap to WinView, allowing it to be used for simple note creation. No it is not now a word processor, has never been and will never be a real word processor. Also reworked the way the left margin is managed. It seems to work ok, but there are still a few conditions where the left margin jumps too far to the right. 10/1395 15:42 tjz Added several options to the WinView preferences dialog, which are now saved nto the Windows Registry. These include things like; window position and size, font and point size, auto save flag, save search buffer flag, the search case sensitivity flag, right margin value and flag, and the open file from previous session flag. 10/1195 11:33 tjz Added Registry support to Win32Forth with much of Andrews help. It wasn't ll that difficult, but I seem to have a mental block against figuring out the example provided by Microsoft. The code and a simple test example is in the file REGISTRY.F. The WinView editor now saves many of its default parameters in the registry, hings like case sensitivity of search, multi-file search path and file mask, font, window size, etc. 09/28/95 tjz Win32Forth DLL support is now working. Two Visual C projects have been added, FORTHDLL.MAK and DLLTEST.MAK. DLLTEST.MAK This project is a simple program that loads up the library FORTHDLL.DLL and allows you to issue one line forth commands to the DLL using the F_INTERPRET function number. FORTHDLL.MAK The project builds the Win32Forth wrapper as a DLL. When the DLL is loaded, it reads in FORTHDLL.IMG which is created currently when Win32Forth is extended with EXTEND.F. The user code for handling the DLL functionality is located in CALLBACK.F in the function "DoForthFunc" and the following lines: ------------------------------------------------------------------------- \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \ DLL function entry point support copied from CALLBACK.F \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ fload DLLDEFS.H \ load definitions for Forth DLL functions and messages defer DLLFunctionLink ' 4drop is DLLFunctionLink ' 4drop is-default DLLFunctionLink : DoForthFunc { lParam WParam message function -- return } function F_INTERPRET = \ forth commandline interpretation if lParam abs>rel 255 2dup 0 scan nip - \ z to addr,len 2dup cr type ['] evaluate catch ?dup if console message then else lParam wParam message function DLLFunctionLink then ; 4 callback &DoForthFunc DoForthFunc \ create the callback for DoForthFunc : DoForthFunc-init ( -- ) &DoForthFunc rel>abs ^image 17 cells+ ! ; DoForthFunc-init initialization-chain chain-add DoForthFunc-init ------------------------------------------------------------------------- You can define your own DLL entry points by creating a set of "#define" statements in a header file, similar to "fload DLLDEFS.H" as shown above. Create a function interpreter with a case statement that tests for each of the F_ #defines you created and then performs whatever function you like. Then install your function interpreter into the defered word "DLLFunctionLink". Finally, save your compiled application with the name "FORTHDLL", which will create the files FORTHDLL.EXE and FORTHDLL.IMG. The file FORTHDLL.IMG will be subsequently loaded by FORTHDLL.DLL when it is loaded with a "LoadLibrary" statement in your "C" program. Don't forget to include your unique header file in your "C" project, so you can use the same #defines from "C" when calling your DLL functions. You can debug your program using the FORTHDLL.EXE program, or while the DLL s running. To debug the DLL while it is running, you will need to put a debug statement like "DEBUG MYWORD" in your source code which will be set while compiling. Then later when the code is run, Forth will break into the debugger. While this may all seem very complicated, be assured that it is! There are ome advantages to using DLL's, like being able to use a common body of code from several programs. Of course it also allows Forth programs to be called from "C", which might allow you to get some Forth code accepted in an otherwise "C" project. 09/26/95 tjz Started working on DLL support for Win32Forth. 09/22/95 tjz Many modifications and enhancements have been completed in WinView. It is ow a full editor. It isn't up to the level of NEWZ, but it is a functional replacement. I have switched the system over to use WinView instead of NEWZ. WARNING: WinView is very new, and may be (most certainly is) buggy, so use it ith care. You may want to switch back to NEWZ or to your own editor until WinView stablizes. That is up to you. You do of course have the source for WinView, so you can always fix the bugs in it you find. 08/28/95 12:09 tjz Added .MONTH,DAY,YEAR and >MONTH,DAY,YEAR to the data manipulation words, which will display the date in the form: " August, 28th, 1995 " 07/17/95 15:47 tjz Under Windows 95, you can after editing this file by using the NewStuff command from Win32Forth, use the Windows 95 Properties menu item to set the font and window size for subsequent invocations of the Z editor. I like to set the edit window to 80 columns, and 50 lines on a 1024x768 screen, using the 7x12 font. 07/13/95 15:19 tjz & rls Added UTILDOC.TXT created by Robert Smith to provide some minimal documentation on some of the utility words in Win32Forth. It should give you a hint at least as where to look for other things. Also added Bob's file TESTANSI.F, which is his first attempt at creating an ANSI compatibility test for Win32Forth. 07/06/95 15:34 tjz & rls Added a file Win32For.PRJ which is the project file for Symantec C++ Version 7.0 for Windows 95 and Windows NT. This file is in addition to the Win32For.MAK file for Microsoft Visual C++ Version 2.1. The wrapper compiles cleanly under either C++ compiler. Robert got a CORE wordset tester from the internet. On testing Win32Forth, we found that there was a problem with the look aside hashed dictionary search mechanism. It has been corrected. We now pass the CORE wordset test without problems. I finished implementing and testing the BLOCK wordset. Win32Forth can now compile from blocks. A sample file BANNER.BLK is included with can be compiled. See BLOCK.F for a description of how to compile from a block file. 06/19/95 15:46 tjz & rls Robert Smith has finished the ANSI compatibility documentation, and it has been included in the system as ANSI.TXT. All of the ANSI wordsets except LOCALs have been implemented and tested to some level. There are no doubt many bugs yet to be found, but at least all the words are present. I have chosen to use a version of locals that is different from ANSI. This is done primariliy because I haven't gotten around to implementing a new word set yet. If anyone wants to donate an ANSI compatible LOCALs implementation, I will be glad to look at it. 06/14/95 17:04 tjz & rls Many mostly minor changes have occured to Win32Forth, to make it more ANSI compatible than before. The required ANSI documentation if now included, as are almost all of the defined word sets and extention word sets. Only the LOCAL and LOCAL EXT word sets and a few words from the TOOL EXT word set are not implemented. 04/07/95 11:00 tjz There have been many changes to Win32Forth since my last entry in this log, but I thought I should at least mention that the floating point software has been completely re-written by Robert Smith. It is now a full floating point package, supporting all of the functionality of the hardware floating point processor. The only demo programs I have updated recently are WINDEMO.F (a simple graphics example) and WINVIEW.F (a simple text example). They now include tool bars and right button popup menus. WINTEXT.F has been removed as it is not up to date with the system. It should be noted, that the redisplay technique used to WINDEMO.F of keeping a bitmap in memory and updating the screen from the bitmap is not a particularly good way to do things. It uses large quantities of memory, and doesn't work with scalable windows well. Ideally, you should keep a draw list, and redraw the screen from the list when the On_Paint: method is executed. The reason this is fairly important, is that if you want to print your windows, you must scale the output to the resolution of the printer, which essentially requires redrawing whatever is on the screen at printer resolution. To choose any other technique, may result in inferior printing. I cheat in WINDEMO.F, by saving the parameters used for the last run of the drawing program, and restoring them before drawing to the printer. This works, but only for the last run, not for multiple runs on top of each other. 12/16/94 15:42 tjz Re-worked the way printing to the line printer is done. PRINTER and CONSOLE work as before, except that they now print into a bordered window on the page, and you can specify SINGLE-PAGE, TWO-PAGE or FOUR-PAGE, for one, two or four pages to be printed on a single physical paper page. When TWO-PAGE or FOUR-PAGE are used, PRINTER and CONSOLE just append to a print buffer until you switch back to SINGLE-PAGE which then flushes the buffer to the windows spooler. This works very nicely. Added some words FPRINT, 2PRINT and 4PRINT, to print a file in each of the three formats. They all switch back to SINGLE-PAGE automatically, and put the filename at the bottom of each page. Page numbers are automatically added to all printing that is more than one page long. Print date and time is always printed at the bottom of each page. Sorry, no flexibility provided. 12/14/94 13:32 tjz Added WINTEXT.F, an example of a simple file browser application 12/12/94 13:37 tjz Added prototype support for objects. A new word OBJECT: allows the definition of an object that is unique, with its own methods, but without the need to define a class for only one object. :OBJECT is used as follows: :OBJECT DEMOW