I am retrieving credit card details from a Magtek credit card swiper. The declare looks like this
declare Integer GetKSN in MTPPSCRA.dll String @,integer ksnlen,integer opstatus
and I call it like this:
r = GetKSN(@lcksn,lnksn,lnopstatus)
I don't get any error and r = 0 meaning success.
lcksn should contain a 20 character hexadecimal string that looks something like 9502580000005F20239A
but I am getting something unreadable.
Are you getting binary data or string data? If you get string data it's probably base64 encoded. Use:
STRCONV(lcBase64String,14)
to turn it into its binary representation.
Or vice versa if if the data is binary and you want to turn it into base64 content.
+++ Rick ---
Thanks, Rick.
I actually had to use the strconv(lcstr,15) option to get what I needed.
Hope all is well with you. John
I'm back.
This follow up is to see how to deal with dlls. The function I am trying to call is defined like this:
c++ const CARD_DATA* __stdcall GetCardDataInfo();
typedef struct CARD_DATA { //a bunch of fields BYTE DataType; char *Track1; etc... )
In foxpro, I have:
declare String GetCardDataInfo in MTPPSCRA.dll
buffer = GetCardDataInfo() && after this buffer contains a double quote ???
how do I deal with the struct?
You can't access this data directly. You have to load it into a predefined string buffer (REPL(" ",1024) or whatever the size is) which gives you the data structure as a binary binary blob of data. After that you have to parse the binary data using bit logic which - sucks.
You can't access C code directly from FoxPro easily - you can do the parsing using one of the various bin parsers but that's extremely tedious and error prone as you have to figure out how much data every piece of data in the structure takes up and then convert and map that to FoxPro. It's possible, but really painful.
The better choice is to build a C++ Win32 dll that calls the third party DLL and provides you the data in a usable format either as individual values, or something exported to a format you can read like XML or JSON or a text file.
+++ Rick ---