Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to store 8 bit binary in VFP...

Status
Not open for further replies.

cnguyen

Programmer
Dec 15, 2002
21
US
does anyone know how to store 8bit binary in VFP...
this value return from an ActiveX ... I need to able to store it and able to pass it back to the activeX with the same 8bit binary....
thank you;
cuong.

 
8 bit binary is one byte, right? You could stoer it in Char(1) BINARY field.

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
 

Could you clarify .... what exactly are you getting back from the ActiveX control? Is it an 8-bit integer (between 0 and 255), or a string containing one and zeros, or a whole series of separate one-bit fields, or what?

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 

the strings I got back from ActiveX contains a bunch of machine codes... I got information from people wrote this activeX that it must be in 8 bit binary strings...
 

Sorry to labour the point. But to say "a bunch of machine codes" doesn't take us any further forward.

Also, you twice mentioned the word "strings". Do you literally mean a character string, such as "0101001"?

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
sorry Mike;
I'm try to use the Biotools ActiveX... in VB it works ok...
but when convert to VFP it won't work.

when I issued this command in VB
sReg = PentacomBiometricFingerprint1.GetRegistrationFeature

and in VFP
sReg = thisform.pentacomBiometricfingerprint1.GetRegistrationFeature

and when I compared these two sregs value they both difference. According to the folks at Biottools, that it return 8 bit binary strings... and they're using this type of strings to pass between their activeX ... and I have no idea what this is...

I also try the CREATEBINARY() and still no result...

The results for both strings were not 010101.. but funky charactesrs.. square,0,&^#)*)...

thanks.
cuong.


 
The results for both strings were not 010101.. but funky charactesrs.. square,0,&^#)*)...

What do you get if you look at the ascii codes of these characters? If that's what the suppliers mean by '8 bit binary string' then you can use the VFP bitwise operators like BITTEST() to inspect each bit.

Geoff Franklin
 

Cuong,

Perhaps we're looking at this from the wrong angle.

Let me ask you this. What do you need to do with SReg? It's obviously a "registration feature" (whatever that is), but what sort of information do you expect it to give you?

By the way, I don't think CREATEBINARY()is the way to go, as that converts a string to a "binary type string" to pass to an ActiveX control. You are receiving data from the control.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
cnguyen,

You don't say what version of VFP you are using, but you could use STRCONV() to change the binary string to hex to store it then convert it back before sending to the ActiveX control again.

Code:
lcHex = STRCONV([0,&^#)*)],15)
?lcHex && 302C265E23292A29
lcBinary = STRCONV([302C265E23292A29],16)
?lcBinary && 0,&^#)*)
Though you aren't specific about what the differences are that you notice between the two strings you are getting from VB versus VFP using the GetRegistrationFeature method, I would perhaps guess that the return string (sReg) may contain CHR(0) in it which would null terminate the string of characters - in effect truncating the result displayed in VFP.

Some of this doesn't make a lot of sense. A single Ascii character will represent 8 bits (2^8). However, what you show is a string of characters that looks more like you are talking about an 8 byte binary string. You can store that value either in a Character field that is 8 in length, or in the case where you use the STRCONV() function to turn the binary string into hex you can store it in a Character field that is 16 characters in length (hex representation of a byte is 2 characters long).

It's difficult to know for sure what problems you are running into and what exactly you want without more information, but perhaps this is enough for you to sort the rest of the problem out.

If not feel free to post back with more information such as what exactly VB is returning as opposed to VFP. Where do you want to 'store' the value? (field in a table, variable, text file, etc.) Is the ActiveX failing when you attempt to pass the value of sReg back to it? If so, what is the error you are getting? These are just a few questions I can think of that might help everyone sort out what you are trying to do and what solution is best.

boyd.gif

SweetPotato Software Website
My Blog
 
Thank You Craig; I'm using VFP 8.0, I think you're right about the 8 Byte binary strings not 8 bit binary...

This is a Biometric Finger Print ActiveX it has 3 main functions ... Register, verify and match the prints...

sreg = activex.getregistrerfeature
sver = activex.getverifyfeafture
lfound = activex.matchfeature(sreg,sver)

I think you're right about the return string contains CHR(0).

if that the probem, do I need to convert it to HEX before I move it to string variable SREG???
sreg = STRCONV(activex.getregisterfeature, 15)

thanks again;
cuong.




 

Cuong,

Do you need to store sreg or sver anywhere between calls, or do you call getverifyfeafture immediately after getregistrerfeature, and compare the results?

If the latter, I wonder if you need to know what's inside sreg and sver? Isn't it enough to look at lfound?

If that's not right, here's something else you can do:

Code:
sreg = activex.getregistrerfeature
for x = 1 to len(sreg)
  ? asc(substr(sreg, x, 1))
endfor

That will tell you exatly what's in sreg.

Do the same for sver, and compare the results.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Cnguyen,

have you looked up "binary string" in the VB help? Is there really such a variable type? What does it say makes it different from a normal string?

In VFP, each string could be called a binary string, as you can have any character in it, and even 0 or better chr(0) does not terminate a string in VFP. That's because every variable in VFP is stored within a structure, a string has the structure of a pointer to a memory block containing the string and a length property, that way it does not need any terminating character.

As Maike said, there is CREATEBINARY(), but that function is meant for passing strings from VFP to some ActiveX control. But the help also says something about the other direction:

An ActiveX control or automation object passes binary data to applications such as Visual FoxPro as an array of VT_UI1 type data. Visual FoxPro automatically converts binary data passed from an ActiveX control or automation object as an array of VT_UI1 type data to a Visual FoxPro character string.

So you should get the string right away and correctly converted. Perhaps there is a problem in the conversion of that VT_UI1 array within VFP, perhaps the activeX control does pass the binary string (OLE VT_BSTR type data) in an unusual way VFP can't cope with. Or perhaps even your VB sample is getting the data wrong.

Bye, Olaf.
 
craig said:
...the return string (sReg) may contain CHR(0) in it which would null terminate the string of characters - in effect truncating the result displayed in VFP.

I guess I should have clarified what I meant by 'displayed'...

Code:
PUBLIC oForm as Form
oForm = CREATEOBJECT("Form")
oForm.Addobject("Text1", "Textbox")
oForm.Text1.value = "Hello" + CHR(0) + "World"
oForm.Text1.Visible = .T.
oForm.Show(1)
MESSAGEBOX("Hello" + CHR(0) + "World")

boyd.gif

SweetPotato Software Website
My Blog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top