Bitmask operations

Hi! Does anybody now hot to work with bitmasks in Attain? Operators AND/OR work only with boolean, but i would like to work with integer: CASE (param1 AND 255) OF // Use only lower 8 bits Regards Bostjan

At first glance, i think you could use the MODULUS operator if you want to work with lower bits. It is not a real bitmask but is useful in this case. 560 Modulus 256 = 48 hope it helps you.

quote:


Originally posted by lessi: At first glance, i think you could use the MODULUS operator if you want to work with lower bits. It is not a real bitmask but is useful in this case. 560 Modulus 256 = 48 hope it helps you.


In this case maybe, but there are other cases where i should use bitmask. So does any body know how? bostjan

I don’t think this is possible from within Navision. Could be fun however to make a routine which converts an integer into its binary representation i a text-variable, which could then be manipulated char by char. Regards

This is a very interesting question. My question to this would be “why”? Normally bit mask operations are either because of hardware issues, speed, or saving disck space. I can not see that any of these apply to an Attain environment. _________________________ David Singleton Navision Consultant since 1991 dmks22@comcast.net___________ Edited by - David Singleton on 2002 Aug 04 03:18:41

quote:


Originally posted by David Singleton: [img]/forum/images/icon_smile_question.gif" border=“0”>This is a very interesting question. My question to this would be “why”? Normally bit mask operations are either because of hardware issues, speed, or saving disck space. I can not see that any of these apply to an Attain environment. _________________________ David Singleton Navision Consultant since 1991 [u]dm


Why? Becouse I develop CTI modul and when using TAPI, there are a lot of bitmask operations. Thats why i need those. Bostjan

Hi, Please make a COM componenet in VC++ or VB to return the bitmask, and can use this DLL thriugh Automation in Navision.

quote:


Originally posted by Rajeshj: Hi, Please make a COM componenet in VC++ or VB to return the bitmask, and can use this DLL thriugh Automation in Navision.


Hi! Only external DLL/Automation that I would like to us is TAPI,… Any external functions, should be part of Windows,… I am not fun of too much external’s,… So if there is any build in automation, that can handles bitmask i will use it, if not,… I will probably write bitmask function in C/AL,… Regards Bostjan

Just posted a fob to the download-forum with som bitwise stuff. If you can’t wait for it to enter the download forum then here’s the code. OBJECT Codeunit 60002 BitWise { OBJECT-PROPERTIES { Dato=05-08-02; Tid=22:01:09; Rettet=Ja; Versionsliste=; } PROPERTIES { OnRun=BEGIN END; } CODE { VAR Counter : Integer; PROCEDURE IntToBin@1(Int : Integer) BinaryValue : Text[200]; VAR Stop : Boolean; BEGIN REPEAT BinaryValue:=INSSTR(BinaryValue,FORMAT(Int MOD 2),1); Stop:=ROUND(Int/2,1,’<’)=0; Int:=Int-(ROUND(Int/2,1,’<’)+(Int MOD 2)); UNTIL Stop; END; PROCEDURE BinToInt@2(BinValue : Text[200]) Int : Integer; VAR ByteTmp : Integer; BEGIN FOR Counter:=0 TO STRLEN(BinValue)-1 DO BEGIN EVALUATE(ByteTmp,COPYSTR(BinValue,Counter+1,1)); Int:=Int+ByteTmp*POWER(2,(STRLEN(BinValue)-Counter-1)); END; END; PROCEDURE BitWiseOr@3(BinValue1 : Text[200];BinValue2 : Text[200]) BWO : Text[200]; VAR Pad : Text[200]; TheCount : Integer; BEGIN Pad:=PADSTR(Pad,200,‘0’); IF STRLEN(BinValue1)>STRLEN(BinValue2) THEN BinValue2:=COPYSTR(Pad,1,STRLEN(BinValue1)-STRLEN(BinValue2))+BinValue2 ELSE IF STRLEN(BinValue2)>STRLEN(BinValue1) THEN BinValue1:=COPYSTR(Pad,1,STRLEN(BinValue2)-STRLEN(BinValue1))+BinValue1; FOR Counter:=1 TO STRLEN(BinValue1) DO IF (BinValue1[Counter]=‘1’) OR (BinValue2[Counter]=‘1’) THEN BWO[Counter]:=‘1’ ELSE BWO[Counter]:=‘0’; IF BWO=’’ THEN BWO:=‘0’ ELSE BWO:=DELCHR(BWO,’<’,‘0’); END; PROCEDURE BitWiseAnd@6(BinValue1 : Text[200];BinValue2 : Text[200]) BWO : Text[200]; VAR Pad : Text[200]; TheCount : Integer; BEGIN Pad:=PADSTR(Pad,200,‘0’); IF STRLEN(BinValue1)>STRLEN(BinValue2) THEN BinValue2:=COPYSTR(Pad,1,STRLEN(BinValue1)-STRLEN(BinValue2))+BinValue2 ELSE IF STRLEN(BinValue2)>STRLEN(BinValue1) THEN BinValue1:=COPYSTR(Pad,1,STRLEN(BinValue2)-STRLEN(BinValue1))+BinValue1; FOR Counter:=1 TO STRLEN(BinValue1) DO IF (BinValue1[Counter]=‘1’) AND (BinValue2[Counter]=‘1’) THEN BWO[Counter]:=‘1’ ELSE BWO[Counter]:=‘0’; IF BWO=’’ THEN BWO:=‘0’ ELSE BWO:=DELCHR(BWO,’<’,‘0’); END; PROCEDURE BitWiseXor@8(BinValue1 : Text[200];BinValue2 : Text[200]) BWO : Text[200]; VAR Pad : Text[200]; TheCount : Integer; BEGIN Pad:=PADSTR(Pad,200,‘0’); IF STRLEN(BinValue1)>STRLEN(BinValue2) THEN BinValue2:=COPYSTR(Pad,1,STRLEN(BinValue1)-STRLEN(BinValue2))+BinValue2 ELSE IF STRLEN(BinValue2)>STRLEN(BinValue1) THEN BinValue1:=COPYSTR(Pad,1,STRLEN(BinValue2)-STRLEN(BinValue1))+BinValue1; FOR Counter:=1 TO STRLEN(BinValue1) DO IF BinValue1[Counter]<>BinValue2[Counter] THEN BWO[Counter]:=‘1’ ELSE BWO[Counter]:=‘0’; IF BWO=’’ THEN BWO:=‘0’ ELSE BWO:=DELCHR(BWO,’<’,‘0’); END; BEGIN END. } } Regards

quote:


Originally posted by ohlfert: Just posted a fob to the download-forum with som bitwise stuff. If you can’t wait for it to enter the download forum then here’s the code. … Regards


Hi! Thank you very much. I will try this code,… regards Bostjan