Win32Forth FAQ Entire Document Updated March 28th, 1996 >Can objects be embeded as instance variables in Class definitions? For >example can I define a >class "Date" and then embed a Date in the class definition for "Person"? Yes, as you can see by the example WINDILOG.F (when I release it), you can create local objects within other classes or objects. >Is it posible to call VBX's from WIN32FORTH ? If its possible, I don't know how. If Visual Basic could make DLL's (which it can't), then you could use a DLL from Win32Forth. Sorry. >In your file getting started ( F1) you state that Forth is case >insensitive. This isn't true for calls like " call GetStockObject" >It must be typed in like the template >It is case sensitive but after same trys I can even write GSO and it is >loading?? Win32Forth is case insensitive, except when using the CALL word to call a Windows procedure. The procedure names are used to access the names right out of the DLL, and as such are case sensitive. > I have been trying to use the WinDirect DLL's from SciTech Software > with Win32Forth. No success. Has anybody information on the correct > way to use DLL's with Win32Forth or perhaps even tried WinDirect. If you are running Win32Forth 3.0 or higher, then you should be able to simply add the name of your dll to the WINLIB.F file along with the other dll's mentioned there. Then you just call the dll functions with something like; CALL MyDllFunction Be sure to put all its arguments on the stack in reverse order, that is the argument nearest the word CALL is the argument that appears first in the C call description. Also you need to use REL>ABS and ABS>REL to convert addresses back and forth between things sent to a DLL and things received from a DLL. Note: Win32Forth searches all the DLL's for a particular function name, and compiles a reference to which ever library it first finds the function in. So if you have conflicting function names, you will have a problem. >A couple of days ago, I downloaded Win32Forth v3.0 from taygeta and one thing (pherhaps the only one!), I disliked was when running on a Windows 95(my case), >it does not allow the creation of a single image file as it appened with >previous versions. > >I browsed away the C wrapper and found out that the image recognosance routine >is still there but all support for it was removed in FSAVE why? , the new >2 dictionary model does not allow it or what?. In my efforts to support Windows 3.1 with Win32s, I found that I could not pen, read or write to the currently running program. This made it very complicated to get Win32Forth to create a single executable. For simplicity I have chosen to use the current separate .IMG file approach until some future time when I figure out how to create a single executable the right way. NOTE: March 28th, 1996 With Version 3.1, FSAVE will automatically create a single executable .EXE on WindowsNT. The .EXE can subsequently be used on Windows95, and WindowsNT. It is known that the single executable .EXE will not be runable on OS/2, and may not be runable on Win32s, these being due to a resource read error on user defined resources. Windows95, Win32s on Windows 3.1 and OS/2 automatcially create a split executable with a separate .IMG file. These will run on any of the above mentioned operating systems. >One other thing, is the OLE working in version 3.0?. No, Win32Forth 3.0 does not support OLE, though there is still an attempt to upport it included in the form of OLE.F, which was Andrew's and My first attempt. Unfortunately it was not really generalized, and was very ifficult to setup, so it is probably not useful. >A bug I found (I think its a bug!), is when you make a Call to a routine > in a DLL, (previouly registred )such as this : > > parameters Call DLLRoutine > >And DLLRoutine does not exist, forth returns an error to the console, >but more rastic than that is that when you make .Procs to see the >procedure table it is there? Is this made this way so you can resolve >the calls later, but anyway an error is returned througth ABORT" which >stops the compile, so I dont know. This is not a bug, you can only compile programs on a computer that will run the program. So, any DLL you reference must exist on your machine. You also must insert a line like; WINLIBRARY NEWDLL.DLL To tell Win32Forth that it should search the new DLL when you attempt to perform CALL to a function. I should mention that because Win32Forth searches all of the DLLs it knows about for any procedure you try to perform a CALL to, you must not create any DLLs that have a procedure name conflict (duplicate procedure with the same name) as any of the existing DLLs. >Is there any way to change the default application icon? You must have Visual C++ to change the ICON, unless someone donates a resource ditor that can be distributed wiht the system that would allow changing it in the existing executable. If you have Symantec C++, they have a resource editor that allows changing the icon of an executable file. >I've been trying to run two windows in an application, each with its >own menu bar. It seems that both windows want to use the last loaded >menu bar definition. I have a nice binary editor that gets its own >vocabulary, window and menu bar. So far, I haven't been able to use it >inside other apps because of the menu bar conflict. Well, that doesn't seem right. The menubar has to be started when the window s started. I do know that there is a GLOBAL variable called CURRENTWINDOW that is used by some of the primitive functions like menus, or perhaps you need to set CURRENTWINDOW when you change the focus from one window to another. >Is there a way to cut stuff from the Forth window for pasting to the >editor window? This might be useful for when you type some definitions >and they work, but they're not in a file anywhere. So, you have to >re-type them in the editor. Why now scroll back and cut (copy) them, or >SEE and copy? It is not as convenient, but if you look at the File menu, you will see an item or saving the console window to a file so it can then be re-opened with the editor. I think the file name is something like CONSOLE.TXT > Is there any written documentation on the details and philosophy > behind the use of Objects the have tried out some of the examples, and it makes me want to learn > more about object oriented programming with win32forth. I like being > able to try out different methods from the command line, but unless I > can find some written documentation I always suspect that I may be > missing something. > > Would it be worthwhile obtaining the documentation for Yerkes, or > whatever that Object ORiented FOrth for the Mac is called? I have > read that there is a certain amount of similarity between the Object > models used. Yes, Andrew McKewan ported the NEON (yerks/MOPS) model of object oriented programming to Win32Forth. I have looked at the MOPS manual, and found it to be very similar (conceptually) to Win32Forth. >I just wrote my first Windows app using w32f (v2.0). I'm starting to get >the hang of it. I noticed that the demo program WINEDIT.F displays a >little bitty dot for a cursor. On_Focus: tries to MakeCursor: before >invoking the parent's On_Focus, so MakeCursor sees that there's no focus >and doesn't do its thing. Doing On_Focus: self first works much better. WinEdit is an obsolete example, and probably contains bugs. It was not included with Win32Forth 2.0 (at least I don't think it was). Try looking at either WinView.F for a complete example of an editor for windows. >I'd sure like to be able to make custom dialog boxes without having to >re-build the system, since I don't have Visual C++. Versions 3.0 and later include some reworked Controls code that makes it at least possible to create dialogs (really modal windows) without having a dialog editor. >I am confusing with clearing of stack parameters. >For example, there are two methods in Window.f source. > :M On_Init: ( -- ) ;M > :M WM_CREATE ( h m w l -- res ) > On_Init: [[ self ]] > 0 ;M >Why does stack parameters, hwnd msg wparam lparam, vanish >in On_Init: method? >Actually, stack parameters of On_Init:, On_Size: are different in >Window.f, Windemo.f and Winview.f In the above example, "On_Init:" is a method that does nothing special, in fact it does nothing at all, except become a place holder for the use of "On_Init:" in the following method WM_CREATE. All of the WM_ methods n Win32Forth are called during a callback from Windows, when it wants to send, in this case, a window create message (WM_CREATE). When this happens, then the WM_CREATE method will call the On_Init: method. The double brackets "[[ self ]]" signify a runtime specified reference to On_Init:, so if you have redefined On_Init:, then your definition of On_Init: will get called instead of the default no operation shown above. is sort of an automatic re-definition linkage for methods defined with [[ self ]]. Your second question relates to the fact that the stack seems to be left in a ad state. Well, you are right, it isn't cleaned up before returning from the WM_CREATE method, but it doesn't need to be. You see the WM methods are called only from a windows callback, which means that windows alls Forth, and durning that process, stacks are created for the method to use duiring execution, and they are destroyed when the method returns to window, so it doesn't make any difference that things are left on the stack. > Is there any posibility of porting Win32Forth to the >OS/2 Presentation Manager. Since the PM is a 32 bit flat >memory model porting should be feasable. If I was more >familiar with Forth I would attempt it my self. Unfortunately, I don't have OS/2 or any of its development tools. Porting Win32Forth o OS/2 would involve changing all of the system interface code to call OS/2 functions. Though many would be equivelant, they probably don't have exactly the same interface as Win32s functions do, so some code would need to be re-written. Note: I now (March 8th, 1996) have OS/2 and I have at least looked at the rogrammers manuals for Presentation Manager. The port might not be too difficult, but I don't think I have time at the present. I have tested Win32Forth Version 3.1 under OS/2 with Win32s Version 1.25.142 and now that I have fixed some memory management bugs) it works fairly well. You will need a new version of VW32S.SYS from the IBM update center to get Win32s 1.25 to work properly. >We have been thinking about >converting our industrial control product (currently based on FPC) to >Windows. Do you have comments on how difficult it might be to convert an >existing application to Win32Forth - excluding the user interface? Well, excluding user interface, Forth is pretty much Forth, though Win32Forth s a linear addressed 32bit Forth versus F-PC's 16bit, which leads to the normal 2+ versus 4+ (or CELL + for ANSI) problems. The biggest problem you will have in using Win32Forth, is it is ANSI compatible, not F-PC compatible, so the file words are different. Win32Forth also adds full object oriented support (ala NEON or MOPS) which is a whole new way of thinking about programming. I must warn you that excluding the user interface in Windows, or even F-PC, is to discard a large part of the application. >I am somewhat familiar with Windows 3.0 programing (just enough to be >dangerous I guess) but have not gotten into Win95 yet. Can you suggest a >good reference book to go along with Win32Forth? SAMS makes a book called Win32 API (ISBN 0-672-30364-7 or LCCN 93-84382) which although it doesn't document the Forth in any way, does document the Windows 32 API interface. It is the cheapest (about 50 dollars) and best resource I know of for anyone wanting to get started with Windows95 or NT programing. Otherwise you will have to spring for MS Visual C++ at about 400 dollars, or Symantec C++ about the same price. >I don't suppose there's another Dr. Ting around, excitedly writing >manuals for Win32Forth yet? Is that ever likely to happen? There has been some disscusion about a user written manual, but the most helpful ser input, would be simple examples of things that work, showing how to use small parts of the system to do useful things. >What kind of >activities did you undertake to get familiar enough with Win95/NT to >write W32F? My work was done out of necessity. My employer hired me to port their application, and I needed tools to accomplish that task. I was very fortunate to be working with Andrew McKewan who had just solved all of the really hard "windows" problems before I arrived. >Did your company send you to any training? No, not yet. >How much of your >knowledge came from 'self-education'? >How much of your knowledge comes from informal >'networking'? All of it, or you could say it was education by Andrew. >Does your company use consultants to >get training and info? Like most companies we use consultants to solve short term tasks where we can afford not to have full knowledge "in house". >Our project requires OLE >elements and it would be very helpful to know what support to expect >in Win32Forth in future releases and when to expect those releases. OLE support is in the works, but it is not known when it will be complete. There is some very primitive starting code for OLE server already included with Win32Forth. It has been tested to some extent, but is not fully tested. >I was very happy after I downloaded "Win32For". >But I have trouble in using Win32For because there are no manuals. >Help me The only documentation currently available is listed in the Help menu in the orth console window. This provides access to the several small documents that provide hints as to how to use Win32Forth. Version 3.1 also introduces help through the F1 key in WinView. Position the edit cursor within an ANSI standard word and press F1, the ANSI DPANS94 document will be opened on the standard definition of that word. The only way to learn to use Win32Forth currently is to look at the provided example programs listed at the start of the file WIN32FOR.NEW. >Tom, when I try to use help with Win32Forth, I get a message about >"unable to read drive D:" . On my system, drive D is a CD-ROM. Where >is the HELP stuff located, so I can reconfigure? Is it trying to use >the old F-PC hypertext help system (which _was_ on drive D because >I had a split hard drive)? HELP :-) There is no Windows help currently, though access to the Windows Help system in uilt in. If you edit the source for HELP, you will see that a compiled string is being used to try to locate a file API32.HLP on drive D:, where I have mine located. You will need to buy Visual C++ to get that file. >I am trying to find an affordable Windows-based Forth to use for >authoring physics tutorials, live demos, etc. >I note you, at least, have DONE THE RIGHT THING and kept the stacks >distinct (whether or not you cache on the co-processor and/or EBX). >Thus Win32Forth is a good candidate. > >My main problem now is documentation--I have not been able to make the >on-line docs for Win32Forth work, and I gather from reading other >people's troubles, that they might be only virtual. It is in fact virtual (I.E. almost completely non-existent). >If you wanted to supply me >with a list of the currently defined words, I would be willing to put >them into the form of documentation with examples, as I noodle around >and learn the system. You can use WORDS to display the words of one or more vocabularies to the screen and then use the SAVE CONSOLE menu item under the FILE MENU to generate a list of words in Win32Forth. >Some fairly complete form of documentation will >be necessary before we can make Win32Forth a suitable pedagogical system >--and I for one would emphatically like to see that happen! Documentation is seriously needed, but I don't have time to create it. > I'm trying to get some EDIT-WINDOWS on the screen, to read in some > numbers. I don't wont to use POPUPs build with the resourcecompiler. > Can you tell me some tricks how to realize this ? Win32Forth includes several demonstration programs, these are the only examples vailable. Note that WINVIEW does popup a generic edit box that is built into Win32Forth to accept input from the user for the simpleest form of text search while in browse mode. You could copy that method and void creating your own windows. if you want to get simple single parameter input. > A question concerning the win32for kernel: Register edx is saved and > restored in all primitives which use it, but as far as I have seen, it is > not really used as object pointer. The primitive DU< destroys edx. Do you > intend to use edx as object pointer in a future release? I'm not shure if > the gain in speed is worth the trouble. The Win32Forth kernel is still evolving, so decisions about EDX are basically being defered, but if it is being preserved everywhere but in DU<, then that is probably a bug.