To create your own program, use the following procedure:
This creates a new folder and a set of source files within that folder. The folder has the same name as the project, and the project file within the folder has the extension name, .mcp, for example "BasicApp.mcp".
Double-click the Starter.c file to open an edit window.
#include <Pilot.h> #include <SysEvtMgr.h> #include "StarterRsc.h" #include <hmq.h> /* <- MQe header file */ static Err AppStart(void) { StarterPreferenceType prefs; Word prefsSize; /******* MQe defines ************/ MQEHSESS hSess; MQEHFIELDS hMsg; MQEINT32 compcode; MQEINT32 reason; MQEPMO pmo = MQEPMO_DEFAULT; /* Set default put message options */ /******* End of MQe defines *****/ // Read the saved preferences / saved-state information. prefsSize = sizeof(StarterPreferenceType); if (PrefGetAppPreferences(appFileCreator, appPrefID, , , true) != noPreferenceFound) { } /*************** MQe code added ***************/ /* Initialize the session: connect to the local queue manager */ hSess = MQeInitialize("MyAppsName", &compcode, &reason); /* Allocate memory for the MQeMsgObject (an MQeFields object with two set fields) */ hMsg = MQeFieldsAlloc( hSess, MQE_OBJECT_TYPE_MQE_MSGOBJECT, &compcode, &reason); /* If the allocation was successful put some data into the MQeFields object */ if ( compcode == MQECC_OK ) { /* Put ASCII text "Hello World" into the MQeMsgObject */ /*in a field named "HelloAscii" */ MQeFieldsPut(hSess, hMsg, "HelloAscii", MQE_TYPE_ASCII, "Hello World", StrLen("Hello World"), &compcode, &reason ); } /* Now put the message to a Queue Manager and Queue */ MQeQMgrPutMsg( hSess, "aQMgrName", "aQueueName", &pmo, hMsg, &compcode, &reason); /* If the initial allocation was successful, */ /* free the memory held by the MQeMsgObject */ if (hMsg!=MQEHANDLE_NULL) { MQeFieldsFree(hSess, hMsg, &compcode, &reason ); } /* Terminate the session */ MQeTerminate(hSess, &compcode, &reason); /*************** End of MQe code **************/ return 0; }
This code:
When you have finished editing the Starter.c file, save it and close the edit window.
A project message appears confirming that an access path has been added.
The project builds a compiled program called Starter.prc and stores it in the project folder.