Frequently Asked Questions about Foundation Shell for 4th Dimension | 4D
Foundation Frequently Asked Questions (FAQ)
How Do I…
How do I tell what version of the shell I’m using?
The version is included as part of the component’s file name. For example, Foundation_541_v11.4dbase is the v11 version of Foundation 5.4.1.
The Foundation component does almost what I want, but I need to modify it slightly. How do I do this?
Make your change to the Foundation component (Foundation_541_v11.4dbase). Then just install the modified component into your projects in place of the original Foundation component.
Using this technique, it’s easy to revert back to the original components as they are updated. Be sure to track your changes so you can add them back in when there is an update to Foundation. As much as possible, use the Foundation Hook methods to modify Foundation’s behaviors.
I’ve done something wrong that causes problems when the database is launched. How do I get back into the Design environment to fix it?
When you launch the database hold down the Control and Alt keys (on Windows) or the Command and Option keys (on Macintosh) when you click on the Connect button in the password dialog. Foundation’s startup code will check for this, and if these keys are down you’ll drop into the debugger at the beginning of the Fnd_Hook_Shell_Setup hook.
I’m trying to diagnose a problem, but I need to trace through a Foundation component’s source code. How can I do this?
Make sure you have the uncompiled version of Foundation in your components folder. As you trace through with the debugger, be sure you click on the Step Into (F8) button and you will be able to trace the component methods.
I don’t want to display a startup window when my application launches. How do I turn off this feature?
You can prevent the startup window from displaying by calling Fnd_Art_SetStartupDialogForm and passing it a blank string for a form name (pass it a pointer to anything in the first parameter – it will be ignored):
How do I specify the tables displayed in the Open Table dialog?
You can use the new Fnd_Hook_Shell_OpenTable hook to specify which tables are displayed in the Open Table dialog.
Are there any hidden (or at least not obvious) features in the Foundation Shell?
If you hold down the Option or Alt key when quitting an interpreted database in the Custom Menus environment, Foundation will actually quit 4D rather than switch to menu bar #1.
If you hold down the Command and Option keys (Macintosh) or the Control and Alt keys (Windows) when you launch Foundation, you’ll drop into the 4D debugger at the beginning of the startup process. This is useful if you’ve got some code in the Fnd_Hook_Shell_Startup hook that’s causing problems.
A window doesn’t close when its close box is clicked. What’s wrong?
Two things must happen for a window’s close box to work. First, you must enable the form’s On Close Box event. Then the form method must call either the Fnd_IO_InputFormMethod, Fnd_IO_OutputFormMethod, or Fnd_Gen_FormMethod method.
Why doesn’t 4D quit when I select Quit from the File or Application menu in the Application environment? I have to select it twice to actually quit 4D.
The 4D application will actually quit if you compile the database, or use it with 4D Runtime. Foundation assumes that if one of these isn’t true, you’re the developer.
You can also just hold down the Option key (Mac) or Alt key (Windows) when you select Quit from the menu to actually quit. This option is provided as a shortcut for the developer.
If you need another option, you’ll need to modify the Fnd_Shell_Quitter routine.
Why does Foundation appear to hang when I try to quit from the Application environment?
When you quit a Foundation Shell based database, the shell tries to quit all non-4D processes. It waits for all of these processes to quit, then displays an error message if a process doesn’t end. If you launch a new process (or install a non-Foundation component or plug-in that does), you either need to teach it to quit properly (use Foundation’s Fnd_Gen_QuitNow method), or tell Foundation not to worry about this process when it quits (use the Fnd_Shell_ExcludeFromQuit method).
How do I fix a runtime error “Database Foundation_xxx is write protected”?
If you get that error, it is because you are missing the matching file Foundation_5XX.4DIndy. Simplest thing to do is to launch Foundation_5XX.4DB directly. It will ask you to create a new .4DD datafile. This is create the matching .4DIndy file.
The other option is to replace your Foundation_5XX.4DB with Foundation_542.4dbase which contains all the files necessary for Foundation.
Foundation IO questions…
Foundation’s OK and Cancel buttons are hidden under my other form objects. How do I get them to move down below my form objects?
If you’re inheriting the Fnd_IO_InputForm to get the OK, Cancel, and navigation buttons, you’ll need to leave about 60 pixels at the bottom of your form. If you’ve set the form size to Automatic, just set the vertical spacing to 60 pixels instead of the 20 pixel default.How can I control the location and look of the input form’s Cancel and Save buttons?
There’s currently no way to procedurally change the location or content of these buttons. But you don’t have to inherit the Fnd_IO_InputForm. The only thing it does right now is localize and place those buttons. So instead you can just not inherit the Fnd_IO_InputForm and use your own Save and Cancel buttons.
If you do this, don’t use the Foundation button variable names. Create your own unique variable names for the buttons.
The input form window title displays the record number. How can I change this to something more meaningful to my users?
Call the Fnd_Wnd_SetTitle command from the Fnd_Hook_IO_DisplayRecord hook. This hook gets called just before the window displaying the input form is opened.
For example, you can test for the current table in a Case statement, then set a specific field for each table.
Why are the Save and Cancel buttons drawn in the upper-left corner of the input dialog instead of the lower-right corner?
These buttons have been hidden in the Fnd_IO_InputForm form that gets inherited by your input form. They’re moved into place at runtime when the window is opened, and then moved again when the window is resized. For this to happen, the form’s On Resize event must be enabled, and you must call the Fnd_IO_InputMethod method from the form method.
How do I procedurally specify the input form to use?
Just pass the name of the form to the Fnd_IO_InputFormName method from the Fnd_Hook_IO_DisplayRecord hook. This hook gets called just before the window displaying the input form is opened.
Rather than using the Foundation IO component to display my output form, I want to use my own form. What methods should I call from the buttons on my output form to duplicate the behavior of Foundation’s buttons?
Call these methods from your buttons: New: Fnd_Rec_NewRecord
Delete: Fnd_Rec_DeleteUserSet Show All: Fnd_Rec_ShowAll
Find: Fnd_Hook_Shell_Find Sort: Fnd_Hook_Shell_Sort Print: Fnd_Shell_Print
What technique should I use when the user hits the inherited Save button to verify that needed fields are filled out, and if necessary, reject the Accept action?
Just add your code to the Fnd_Hook_IO_InputFormButton hook. This also works for the Cancel and Navigation buttons.
Menus and Windows…
I’m procedurally modifying the current window title. How can I update the window name in the Window menu so it matches my new window title?
Just call the Fnd_Menu_Window_Add after calling 4D’s SET WINDOW TITLE command. Foundation will recognize that the current process is already in the list, and update it with the new window title.
Why isn’t my window name removed from the Window menu when I close the window?
You need to call the Fnd_Menu_Window_Remove method before you call 4D’s CLOSE WINDOW command.
Should I name my methods and variables with “Fnd_”?
No. The Foundation component objects begin with this prefix to avoid naming conflicts with your objects.
If you want to use a naming convention (it’s not required by Foundation), you should pick a unique prefix that will not likely be used by any other products that might be installed in your database.
What style sheets should we use when creating form objects?
You can safely use Fnd_IO or Fnd_Gen style sheets for your input and output forms.
© 2013 Nelson Consulting, Inc.