Skip to main content

Bit variables

  • June 21, 2021
  • 8 replies
  • 0 views

Hi all,

some Microsoft OCXs need input/output parameters defined as a pure sequence of bits.
Is there a way to compose such a sequence using Uniface variable types and/or functions ?

Many thanks

Luigi

8 replies

Ingo Stiller
Forum|alt.badge.img+3
  • Participating Frequently
  • June 21, 2021

Hi all,

some Microsoft OCXs need input/output parameters defined as a pure sequence of bits.
Is there a way to compose such a sequence using Uniface variable types and/or functions ?

Many thanks

Luigi

Hi Luigi

"Bit-sequence fields" are often nothing more then an integer with special interpretation.
So check if it is possible to use an integer (I2,I4,I8) as parameter.
If this works then you can manipluate this intereger by any normal mathematic operations

Get a bit at position n; n zero based
   declare this a function LF_BIT_GET(bitvar,n) as you need it for every other function

  bit = (bitvar/(2^n))%2

Set a bit
  IF(!LF_BIT_GET(bitvar,n)) bitvar +=  2^n

Resset a bit

  IF(LF_BIT_GET(bitvar,n)) bitvar -=  2^n


Any yes you can write this getter/setter "inline"

bitvar +=  (1-(bitvar/(2^n))%2) * 2^n

bitvar -=  (bitvar/(2^n))%2) * 2^n

No very performant, but as UnifAce don't have such things then bit operations 🙂


Ingo






  • Author
  • Participating Frequently
  • June 21, 2021

Hi all,

some Microsoft OCXs need input/output parameters defined as a pure sequence of bits.
Is there a way to compose such a sequence using Uniface variable types and/or functions ?

Many thanks

Luigi

Hi Ingo,

thanks for your quick and accurate reply.
The problem encountered with interfacing with OCXs, as we know, depends also on the correct definition of the type of the OCX parameter so that the 'conversation' with Uniface is peaceful.
For the sake of simplicity (this is my case) suppose that it should send a binary/integer type value to the OCX. Its value is a combination of bits equivalent to 0,2,4,8,16 that can be added together.
Naturally, its representation in bits is equivalent, in this case, to the appropriate sequences within a byte ('00000000', '01000000', etc.).
OCX signatures imported into Uniface do not always match the actual representations that OCXs expect.
In particular my parameter is imported as' String - VT_VARIANT ".
I have tried various combinations by modifying the definition of the parameter in the signature (numeric VT_I2, VT_U1, raw, etc.) but I have not yet obtained the correct result.


Many thanks

Luigi


Ingo Stiller
Forum|alt.badge.img+3
  • Participating Frequently
  • June 22, 2021

Hi all,

some Microsoft OCXs need input/output parameters defined as a pure sequence of bits.
Is there a way to compose such a sequence using Uniface variable types and/or functions ?

Many thanks

Luigi

Hi Luigi

I'm not sure and never did a test, but ...


VT_VARIANT could by / is a union with a field determing the type and a payload field
Something like this

struc {
int type;
int payload;
}

So try to access the VT_VARIANT by I8.
The lower 4bytes are the type and the upper 4 ones are the payload, i.e your bit-field

As I said, never check this 🙂

Ingo



  • Author
  • Participating Frequently
  • June 22, 2021

Hi all,

some Microsoft OCXs need input/output parameters defined as a pure sequence of bits.
Is there a way to compose such a sequence using Uniface variable types and/or functions ?

Many thanks

Luigi

Hi Ingo,

I tried your suggestion but unfortunately still unsuccessful.
By the way, according to Microsoft documentation, that parameter should be of type I2 since it is of type 'Short'.
I also tried in the latter way by setting in the signature Numeric/I2 and similarly a local variable in my form.
Again without success.
I'll make a few more attempts and then I'll try to survive peacefully without that parameter.
Thanks for your help

Luigi


Iain Sharp
Forum|alt.badge.img+5
  • Inspiring
  • June 23, 2021

Hi all,

some Microsoft OCXs need input/output parameters defined as a pure sequence of bits.
Is there a way to compose such a sequence using Uniface variable types and/or functions ?

Many thanks

Luigi

Umm, not sure if this is appropriate, but we receive data from an ocx as raw with the interface as VT_ARRAY - (array of bytes). 

As an input parameter it'd be down to finding out how to fill the raw data field with the right bits presumably (assign it a numeric as per Inigo?)


Ingo Stiller
Forum|alt.badge.img+3
  • Participating Frequently
  • June 23, 2021

Hi all,

some Microsoft OCXs need input/output parameters defined as a pure sequence of bits.
Is there a way to compose such a sequence using Uniface variable types and/or functions ?

Many thanks

Luigi

FYI: To pass a pointer to something from Unicae to the outside world:
Just define a simple table in the model.
e.g
FLD_TYPE I2
FLD_VALUE I2

Then declare your signature with this table  instead a normal variable
Paint the table as an entity in your component, fill the fields as in normal entities and call the signature with the entity name.
Uniface convert the entity name into a pointer to the "struct" defined by the table.
After calling and if the call DLL changed the context, you can access them as a normal field in an entity.

Under Windows, I got the german tax application to work with UnifAce 🙂
(Was a little bit tricky, as there are pointers in pointer, but Windows provides some DLL-functions to handle it)

Ingo


  • Author
  • Participating Frequently
  • June 23, 2021

Hi all,

some Microsoft OCXs need input/output parameters defined as a pure sequence of bits.
Is there a way to compose such a sequence using Uniface variable types and/or functions ?

Many thanks

Luigi

Hi all,

first I would like to thank both Ingo and Iain for the help they are giving.
To Ingo I say that I have not yet tried the solution that involves the definition of an entity and its connection with the signature.
I must say that it is very interesting and I never thought there were such possibilities.
Regarding my attempts I have reached the point that, using raw type interfaces, both in the definition of the OCX method that interests me and the working variables with whose values ​​I interact with the aforementioned method, I have at least obtained that the values ​​I pass to OCX are correct in the range 0-8 (the important ones are 0-2-4-8)
The values ​​must be trivially set up as binary sequences 0000 - 0010 - 0100 - 1000
Just to make things clearer, my OCX is the well known RichTextBox with which you interact with an RTF type box.
The FIND operation allows you to search for strings within a text and, as long as you proceed with 'forward' searches, everything is fine.
FIND also allows you to search backwards thanks to one of its parameters, the one that is giving me some problems, if it is assigned the value 16.
The 0-2-4-8 values ​​allow you to guide the results based on various other options that are working smoothly.
I tried of course to pass the value 16 as a sequence '10000' or '00010000' but it seems that the bits that would give a value greater than 15 are ignored.

Many thanks

Luigi


  • Author
  • Participating Frequently
  • June 24, 2021

Hi all,

some Microsoft OCXs need input/output parameters defined as a pure sequence of bits.
Is there a way to compose such a sequence using Uniface variable types and/or functions ?

Many thanks

Luigi

Hi all,

For greater clarity regarding the problem I am encountering with the assignment of a certain value to the RichTextBox parameter that would activate the Reverse search for a string in a document, this parameter is of the Enumerated type.
It seems that this category of parameters has created several times some problems in the interfacing of an OCX by Uniface.

My best regards

Luigi