alexis@dasys1.UUCP (Alexis Rosen) (09/07/88)
Recently, I have gotten a slew of requests for descriptions of how FoxBase can do menus, windows, and dialogs. Rather than answer each one individually, since this seems to be a topic of some interest, I am posting this article. Most people also wanted comparisons with 4D, so I will describe both. Menus: In 4D, there is a graphic menu editor. It creates entire menu bars, and you can set a cmd-key equivalent and style for each menu item. The editor is a little clunky but it gets the job done. The drawbacks to this system are that any changes to a menu, except enabling or disabling, require you to draw an entirely different menu bar which was created previously. It is also impossible to create menus on the fly. (There are external commands which do this, I believe, which does help the situation.) The other serious problem with 4D menus is that in the top level of an application, choosing a menu automatically activates a procedure. At all other times, you must detect the menu hit and process it yourself. This is a real pain as it requires you to define every response to a menu hit twice. Also, certain subtle problems can crop up when you try to create a global menu hit procedure. In Foxbase, you create arrays for the menu bar and the menus, fill them up, and tell it to draw the menus. The Apple, File, and Edit menus are taken care of automatically, just like 4D. (I wish they weren't. This may change in the future.) The following is an annotated extract from some of my code. The "&&" is a comment delimiter. Dimension mbar(2), mFiles(2), mGo(4) && create space for menu arrays mbar(1)="Placement System" && menu title #1 mbar(2)="Go" mFiles(1)="Clients File" && 1st item in Placement menu mFiles(2)="Prospects File" mGo(1)="First" mGo(2)="Next" mGo(3)="Previous" mGo(4)="Last" Menu Bar mBar && draw the Menu Bar Menu 1, mFiles && make menu #1 ("Placement System") using mFiles array Menu 2, mGo && make menu #2 On Menu Do MenuProc With Menu(0),Menu(1) && set up procedure for menu hits ----- This will set up a menu bar containing: {Apple} File Edit Placement System Go vari- New Undo Clients File First ous Open Cut Prospects File Next DAs Print Copy Previous etc. Paste Last etc. ----- The drawback to this method is that there is no nice graphic menu editor. You have to write the code to create menus. There are advantages, however. The syntax to alter menu items and disable or enable them on the fly is very clean ("Menu Off 2,1" would turn off the first item in the second menu- "Last" in the example above). Cmd-keys, styles, marks, and all the other things you can do in any Mac language are available in exactly the same way (if mGo(4) were "(Last/L", Last would be disabled and have the command key 'L'). There will probably be a graphic menu editor for those who don't like to write code (I would guess around December or January). Until then, you can use the template-based applications generator to build your menu code for you. If you do that, you'll only have to write the code once, and then it will work with whatever menus you want. The template language is very powerful and can do lots of other good stuff, too. The other big advantage to Fox's menu system is that I can easily create one procedure which handles all menu hits. If my menu-handling procedure is called MenuProc, then the statement "On Menu Do MenuProc With Menu(0), Menu(1)" tells FoxBase that any menu hit should activate the procedure 'MenuProc', passing it the parameters 'Menu(0)' and 'Menu(1)' (these are functions which return the menu title number and menu item number, respectively). The MenuProc procedure has a bunch of 'Case' of 'If' statements to decide what to do, based on which menu item was hit. In fact, writing a menu-handling procedure is pretty much the same for both 4D and Fox. They both require some programming to use the menus, and the code will look very similar. I give Fox the edge on the cleanness of the programming model, though. Fox 4D No menu editor (-) Ugly but useable menu editor (1/2 +) Clean code structure (+) Bad code structure (-) Easily altered menus (+) Some problems altering menus (-) All in all, the difference isn't vast. It's mostly a matter of individual style, but I think that Fox has an edge here. Windows: Windowing is one of the weakest points in 4D. It does not have a lot of control over what type of window to use. Worse, it is not capable of doing multiple windows under program control. There is a very bogus second window capability, but when the second window is up the first becomes unavailable. This is entirely unMacish. This is not likely to change in the near future (i.e., V2.0 in December) because of the way procedures are tied to windows. 4D hangs uncomfortably between being an object-oriented programming environment and a procedural one. It is neither entirely, and this will continue to cause enormous problems for Acius, unless it undergoes a fundamental change-- but that's another article... The one good point in 4D's favor is that it can create windows with a document area larger than the current window size (and larger than the screen). FoxBase's windowing capabilities are better than any other Mac DBMS's (except Helix, in some ways). It has a graphic screen generator which is vastly superior to the current incarnation of 4D (and all the other Mac DBMSs). When running your program, it can handle ten database browse windows (spreadsheet- like views of a data file) automatically. In addition, you can create up to nine separate windows entirely of your own design on the screen at once. The screen generator will do it all for you, but if you want to do it yourself, you use the 'Screen' command. You can use the following arguments: Screen <expN> this is the number of the screen Heading "<window title>" this text becomes the window title At <expN>,<expN> location of window from upper left corner Type <expN> the window type. Just like in Inside Mac! Size <expN>,<expN> window size. Can be in pixels or characters. Font <expC>,<expN> Font name, size, and style. This is only a default and can be changed at any time. Color <expC>|<expN> default window color. Old QuickDraw or new. Lock hides the goAwayBox Off hides the window without erasing it. It can still be drawn to in this state. Top bring this window to the front (and show it) Delete remove and forget this screen You can have all nine windows up at once, draw to any of them at any time, get input through any one at any time, move them around, show and hide them, etc. Note also that the Type clause lets you make windows that look just like DAs (round-cornered), dialogs (modal and non-modal), and alerts. In fact, you can use any type supported by the current WDEF. (If that last is gobbledygook to you, just forget it. In English, it means that Fox can draw any of the windows that you see in everyday use of your Mac.) The one limitation in Fox's window scheme is the lack of support for scroll bars. You can't have a form which is seven feet wide and look at it through a seven inch window. I don't think that this is a serious restriction, though, since you can have nine windows. In addition, you can change the particular data items displayed or entered in any window at any time (unlike 4D, or any other Mac DBMS), so you could fake scrolling easily enough if it were critical. I almost forgot- 4D has some really silly limitations on what can go in a window, whereas there are no such limits in Fox. The upgrade to 4D due in December relaxes those restrictions, but they were a _major_ pain to deal with. I'm not going to even try to draw a chart comparing 4D to Fox here- it would be embarrasing. Let's just say that windows are one area where 4D loses big and FoxBase really shines. Dialogs and Alerts: 4D has some rudimentary commands to show an alert or ask for one text string. They are useful in a limited context, but if you want anything more, you need to pull up a window which looks like an alert. The problem is that if you want a Modeless dialog box, you are S.O.L. Even worse, if you already have a second window up, you _can't_ bring up another window. This is really painful... FoxBase has a variety of simple alert and dialog commands which all do pretty much the same thing: Show a modal dialog with one, two, or three buttons, an icon of your choice and up to six lines of text. The dialogs are resources in the "FoxUser" file, which can be altered if you really want. You can draw the dialog centered on the screen or at any location. Fox's dialogs are even more restricted that 4D's in that you can't read data in from them. However, this isn't really a problem, since you can fall back on the wonderful windowing system so easily (not to mention the template language, which can be set up to generate dialog code to your heart's content). Therefore, it is very easy to create unusual alerts, modeless dialogs, and very complex dialogs (like the configuration screens in terminal emulators, for example). The graphic screen generator can do this very nicely. So in fact, FoxBase is very good at dialogs of all sorts. Score: Again, it's FoxBase by a mile... ----- I hope this has cleared up a lot of questions. Serious debate is always welcome, flames are not. I will be running a database mini-conference at the MacUser Business Expo (or whetever they're calling it now) for three and a half hours on November 1. It will have no resemblance to the ridiculous kid-gloves-on-and-pat-every- manufacturer-on-the-back stuff evident at the past two MacWorld Expos. We will have some really good speakers, such as Wayne Ratliff, Janet Walker from Fox, Guy Kawasaki from Acius, someone from Oracle, and a few more. We will cover both current and forthcoming products, and will spend a lot of time going over techniques to increase the utility of databases on the Mac in current, real-world environments. There will be a heavy emphasis on DBMSs running on Local Area Networks. If you go to the Expo, live nearby, or have a deep interest in these things, come to the conference! It should be a blast. One last thing- if anyone has lots of experience with the new 4D, why not write an article and tell us all about the new features? ---- Alexis Rosen {allegra,philabs,cmcl2}!phri\ Writing from {harpo,cmcl2}!cucard!dasys1!alexis The Big Electric Cat {portal,well,sun}!hoptoad/ Public UNIX if mail fails: ...cmcl2!cucard!cunixc!abr1 Best path: uunet!dasys1!alexis