> I am actually trying to create my own plug-in. > > I have a Delphi 7 book and was just wanting to see if I could implement > some of the book's examples as a R:base plug-in.
It makes little difference in the actual programming, but the RB 6.5 UDF API also works in 7.x. I like that API better because, using the plugin API, it's pretty easy to write a plug in that will crash and/or corrupt memory. Both APIs offer the same functionality (single TEXT paramter in, single TEXT return value out). Using the UDF API, R:Base allocates some memory, and passes your function a pointer and size desriptor for that memory. Using the Plugin API, your code itself allocates the memory used to hold the result. You cannot allocate this as a string in Delphi, since strings are taken off the heap -- your memory won't be there when the function returns and you will cause an Access Violation. Instead, you have to allocate a character array as a local variable which (in current versions of Delphi) means that the memory will come off the stack and (in current versions of Windows) will still be available for R:Base to read, assuming R:Base reads it immediately after your function returns rather than preserving the pointer. In that case, if another function is called and overwrites the stack, your results will be gone. -- Larry
