Accessing Pervasive.SQL With Perl | ||||||
Page Last Modified: 20/11/12 | ||||||
Win32::API Examples 2 - parsing a table in DEMODATA Here we step through the records in one of the tables in the DEMODATA sample database installed with Pervasive.SQL: | ||||||
| ||||||
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
In this example I've used pack to set up the position block, data buffer and key buffer variables instead of treating them as strings (as in the previous example). To me this looks tidier, ties in more with the fact that they are buffers, and matches the unpack calls I have to make on parameters passed into, and filled in by, the BTRCALL function. In this case I have to unpack the data buffer length parameter to convert it into an integer. I also moved the Win32::API Call operation into its own function (_call_btrv) to tidy things up a bit and reduce the number of times I have to print the return value in terms of lines of code. I have passed references into this function those arguments that can be updated by the BTRCALL function. As a result_call_btrv looks to my eyes more like the underlying BTRCALL (and corresponding BTRAPI, etc. calls) when accessed in C and it is clearer which arguments can be changed by the call. Note that anything passed by reference into _call_btrv has to be dereferenced before being passed onto BTRCALL - as explained elsewhere, Win32::API expects parameters that are pointers/buffers to be passed by value/name and not by reference. | ||||||
All content on this site is copyright | ||||||
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |