/* example bcmd plugin for HotPaw cbasPad Pro Basic * 99-Nov-11 by rhn@nicholson.com * * This source code is hereby placed is the public domain * and may be modified and/or used without fee, license or * disclosure. * * This source code is distributed in the hope that it might * be useful, but WITHOUT ANY WARRANTY OF ANY KIND; not even * the implied warranties of MERCHANTABILITY or fitness for * ANY purpose. * */ // revision 2 , for use with version yb 0.99b17 or later // bcmd prototype long int main(long int param1, long int param2, char *str64array); // Creating a bcmd using Codewarrior for Palm: // Set 68K target to "PalmOS Code Resource" // Set ResType to 'code' // Set the ResID to 1000 // Set the PalmRes post linker Output File Type to 'bCmd' // Please register and use your own Creator type. // (Your own application Creator is a good choice for this.) // Set the database name to the function name you wish to use // prefixed by the 4 character string "bcmd" // Make sure your main() routing is the very first routine in // the code resource. // The following examples use the pdb name "bcmdmytest". // There are two different syntaxes for calling your bcmd // from HotPaw Basic: // x = fn bcmd("mytest", param1) // This will return -1 if the bcmd is not found. // and // x = fn mytest() // x = fn mytest(param1) // x = fn mytest(param1, param2) // These will cause a statement error if the // named bcmd resource is not found. // x = fn mytest.op1() // x = fn mytest.op1(param1) // x = fn mytest.op1(param1, param2) // op1 my be any variable name not be a reserved word // The bcmd code module is typedef'd in the calling routine as: long int (*bcmdfn)(long int param1, long int param2, char *str64array); // param1 and param2 are the signed long int parameters // and are set to 0 if not present the calling argument list // str64array points to an 1024 element character array // intepreted as 16 contiguous strings 64 characters in length // accessed as s$(48) .. s$(63) from Basic // This string array is for temporary string calling and result // parameters. Remember that s$() is shared with all other bcmd's // and many of the built-in GUI and database access routines. // *** *** change from the rev 0 bcmd specification *** *** // // When the fn mytest.op1 calling method is used // the op1 variable name is copied to s$(48). // In future versions, s$(48) may be set to "StopApp" after // the Basic interpreter receives a stop application notice. // Otherwise the first character of s$(48) is set to zero. // Another method of getting lots of input data to a bcmd is to pass // a pointer to a long integer array as one of the parameters, e.g. : // dim iparams%(16) : param2 = varptr(iparam%(0)) // Remember that NO global variables are available in a bcmd. // You can acquire more persistant storage if necessary using the // Feature Manager (FtrMgr). // Here's the code for an example bcmd // that returns the sum of its 2 parameters, // and uses the s$() temporary string array. long int main(long int param1, long int param2, char *str64array) { long int result; long int *iarray; if ( str64array == NULL ) { result = -2; } else if (str64array[0] == 'i') { result = 0; } else { result = param1 + param2; } return(result); } /* eof */