lsatenstein
1st May 2005, 16:57
I would like to use the domain SET definitions for bit operations where, if
A is a member of a set, and B is an equivalent value, I can replace

bit.long(A,B) by A*B

I refer you to the Baan function guide
You can also use the mathematical operators +, -, and / for computing bit
operations. The operands must be declared as variables of type SET. You can
declare such a variable only with a domain declaration where the domain is of
database type SET.
* The operator + equates to the function bit.or().
* The operator * equates to the function bit.and().
* The operator / equates to the function bit.exor().
* The operator - equates to a special form of the function bit.and(). That is, to a - b
for sets equates to bit.and(a, bit.inv(b)) for longs.

Can someone show me the declaration for a variable of type SET.

Les.

Does big.and() bit.or() actually call a function or does the compiler generate inline code?

Andreas
2nd May 2005, 15:10
Hi Leslie,
you have to define a domain with data type 'set' in ttadv4500m000/ttadv4100s000 (sessions for Vc).
After that you can declare your variable like
(extern) domain domainname variable

Hitesh Shah
24th May 2005, 20:21
Les.

Does big.and() bit.or() actually call a function or does the compiler generate inline code?

Maybe it's delayed response and u know what i write.

'Set's are nothing but long (just like text numbers) . It represents a bit pattern which is used to have enum-like field with multiple select option. (as against single select option for enums) . From the value of set (etol(setfield)) , u can decrypt the user selection e.g.

if bit.and(etol(setfield),lpow(2,enumnumber -1)) then
set option is selected
endif

bit functions can not be used in select queries (thus making larger selects). However u can use the dynmic SQL with IN clause if u want database driver only to filter out records for u .

We use set fields extensively where users need multiple selects for enum fields .

As sets are actually long , u can only have maximum 32 options (2**32) . Sets with more than 32 options may not work.

Thus bit functions are actually bshell functions which work directly on the bit image of a long (4 bytes / 32 bits) and boolean algebra with that.

lsatenstein
25th May 2005, 02:56
I asked if the bit.or, bit.and etc, were inline functions. That is, the interpretor determines that both arguements are long, and does the and/or,xor,not, or shift operations inline.

I have written an application that sets 8 bits in a long, and with the appropriate masks, I query the condition.

One idea I had was using the bit.and, bit.or to have seven bits set up as days of the week. Then the test for a monday or thursday, or any combination would easily be done with one bit.and() operation.

I setup an enum as a set, but could not get the sets to work. I determined that the range of values to assign to sets consided of bit positions from 1 to 32. I did not pursue this further.

Thanks to all for replying. If you have used sets, please email me or respond with a trivial example. I can take it from there.

Hitesh Shah
25th May 2005, 17:30
Here is an example .

Table tihra100 has an enum field dayn of domain tcdynm (representing the 7 week days).

If the user wants to get records for any combination of these 7 days (in all 127 ) , from the table , u can use sets for that matter.

U need to create a set (say tcdynms) for with same enum options . Each set option has the follwing values

Sunday - 1
Monday - 2
Tuesday - 4
Wednesday - 8
Thursday - 16
Friday - 32
Satudrday 64
Total = 127

Now in program use a variable (say day_selection) of set domain to allow multiple select for 7 week days.

In dynamic SQL or embedded SQL u can use follwoing statement to know what are the set options selected by the user.

if bit.and(etol(day_selection) , lpow(2,etol(tihra100.dayn)-1)) then
|day is selected in the set option by user
else
|day is not selected.
endif

Hope this clarifies ur query . We have used this in our divisional reporting wherein users can ask and enquire results for any combination of about 10 divisions (about 1023 combinations).

I am still not clear about ur question about interpreter . Bshell itself returns true or false based on the physical representation of the long arguments.

lsatenstein
27th May 2005, 13:09
I have been more than successful in using bit operations on long variables. I would like to use the set options that the manual describes. But I was unable.

When two variables, A, B, for example, have domain types of sets, the manual states that that an AND operation can be written as

A*B and an OR operation can be written as A+B, with A-B for symmetric differences.

Since I could not get that to work, I ressorted to the bit.and(), bit.or() and other bit.x() operations.

My question was, Does the interpretor actually call a function for bit.and() and the other bit.operations, or is it smart enough to generate the code in-line?

My thanks to all who have responded to this question.

Leslie

Hitesh Shah
28th May 2005, 06:34
I have tested only the bit.and and bit.in functions . I have not tested the arithmetic expressions as illustrated in documentation . I take ur experience as a guide not to use arithmetic expressions bcos bit functions already are doing the same job (working as per documentation).

My response to ur question also is based on documentation and i do not have exact knowledge how it works . According to me bshell (logic service / interpreter whatever one calls ) compares the physical memory address (On-off status ) of longs in the argument and then returns the result . Think / guess , it does not call any other function internally.

Probably some tools developer, can answer ur query in prescise manner.

lsatenstein
29th May 2005, 06:59
Hi

The question I was asking was whether these functions actually are called or are the instructions inline.

Here is what I mean

somewhere there is a declaration

function bit.and (long arg1, long arg2)
{
do what has to be done
}

or is it inline as the pseudo assembly code below suggests

bit.and:
load rega,arg1
and rega,arg2
store rega,result


Anyone have the answer?

Les