C code for PA_Request and PA_Confirm
We are now ready to open our project in either Codewarrior or Visual C++.
Metrowerks Codewarrior:
Double-click on the 4Dplugin.mcp file. This will open the Codewarrior project. Now expand the folder called Sources to reveal the 4Dplugin.c file as shown below.

Now double-click on the 4Dplugin.c file to open it. You are now ready to begin working on the .c file. To compile under Codewarrior, simply go to the Project menu and choose Make from the menu. We recommend reading the Codewarrior Quick Start manuals to become familiar with all the options available.
Microsoft Visual C++:
Double-click on the 4Dplugin.dsp file. This will open the Visual C++ project. To open the 4Dplugin.c file, make sure you are in the File View and not Class View as the image below shows. Expand the 4D Plug-In files folder and the Source folder.

You should now see the 4Dplugin.c file. Double-clicking on this file will open it. To compile, go to the Build menu and choose "Build the 4D Plugin.4DX file". This will compile and create the plug-in. We recommend reading the documentation on Visual C++ to become familiar with all the different options available.
Below is displayed the code for the Request and Confirm commands. Please note the code in red. This is the only code that was added in our IDE (Integrated Development Environment). All other code was generated from the Plug-In Wizard.
void Dim_Request( PA_PluginParameters params )
{
char Request_Message[256];
char Request_Value[256];
char OK_ButtonText[256];
char Cancel_ButtonText[256];
short returnValue = 0;
PA_GetStringParameter( params, 1, Request_Message );
PA_GetStringParameter( params, 2, Request_Value ); PA_GetStringParameter(
params, 3, OK_ButtonText PA_GetStringParameter( params, 4, Cancel_ButtonText
);
if(PA_Request(Request_Message, Request_Value, OK_ButtonText,
Cancel_ButtonText))
returnValue = 1; // Requst accepted
else
returnValue = 0; // Request canceled
PA_SetStringParameter( params, 2, Request_Value ); PA_ReturnShort( params, returnValue );
}
void Dim_Confirm( PA_PluginParameters params )
{
char Confirm_Message[256];
short returnValue = 0;
PA_GetStringParameter( params, 1, Confirm_Message );
if(PA_Confirm(Confirm_Message))
returnValue = 1; // Confirm accepted
else
returnValue = 0; // Confirm canceled
PA_ReturnShort( params, returnValue );
}
PA_GetStringParameter: This command retrieves the value of the string parameter that was sent to the plug-in.
PA_SetString Parameter: This command returns a value into a parameter that was passed to the plug-in.
PA_ReturnShort: This command causes the Plug-in command to return a value like a function.
Essentially, this is all you need to know to write a plug-in. Remember, when adding commands, think about what the parameters for each call in the plug-in should contain. This should eliminate having to go back at a later date and update the project to add or delete parameters to the plug-in. Thinking about the structure of your plug-in now can help you save time in the future.
Download the Codewarrior or Visual C++ Project and the sample database for the sample plug-in above.
Tutorial
1 Source Files (Mac)
Tutorial
1 Source Files (Windows)