As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.
Join the TIBCO Community TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.
From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
Request access to the private WebFOCUS User Group (login required) to network with fellow members.
Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.
I have a value let's say 50 that I want to convert into a binair value 110010 In excel I have the formula dec2bin that won't go far enough (try 2000 p.e.)
any ideaThis message has been edited. Last edited by: FrankDutch,
Frank
prod: WF 7.6.10 platform Windows, databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7 test: WF 7.6.10 on the same platform and databases,IE7
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006
There is no specific User Written Subroutine to convert a decimal Number to hex or binary.
Try this workaround :
-*======= DEFINE FUNCTION DECBIN8 (DECNUM/I3) -*======= -* THIS WORKS WITH A DECIMAL NUMBER OF 255 OR LESS ONLY; -* -*------- BINARY DIGIT 8 -* BIND8 /A1 = IF DECNUM GE 128 THEN '1' ELSE '0';
-*------- BINARY DIGIT 7 -* BINDR7 /I3 = IF BIND8 EQ '1' THEN DECNUM - 128 ELSE DECNUM; BIND7 /A1 = IF BINDR7 GE 64 THEN '1' ELSE '0';
-*------- BINARY DIGIT 6 -* BINDR6 /I3 = IF BIND7 EQ '1' THEN BINDR7 - 64 ELSE BINDR7; BIND6 /A1 = IF BINDR6 GE 32 THEN '1' ELSE '0';
-*------- BINARY DIGIT 5 -* BINDR5 /I3 = IF BIND6 EQ '1' THEN BINDR6 - 32 ELSE BINDR6; BIND5 /A1 = IF BINDR5 GE 16 THEN '1' ELSE '0';
-*------- BINARY DIGIT 4 -* BINDR4 /I3 = IF BIND5 EQ '1' THEN BINDR5 - 16 ELSE BINDR5; BIND4 /A1 = IF BINDR4 GE 8 THEN '1' ELSE '0';
-*------- BINARY DIGIT 3 -* BINDR3 /I3 = IF BIND4 EQ '1' THEN BINDR4 - 8 ELSE BINDR4; BIND3 /A1 = IF BINDR3 GE 4 THEN '1' ELSE '0';
-*------- BINARY DIGIT 2 -* BINDR2 /I3 = IF BIND3 EQ '1' THEN BINDR3 - 4 ELSE BINDR3; BIND2 /A1 = IF BINDR2 GE 2 THEN '1' ELSE '0';
-*------- BINARY DIGIT 1 -* BINDR1 /I3 = IF BIND2 EQ '1' THEN BINDR2 - 2 ELSE BINDR2; BIND1 /A1 = IF BINDR1 EQ 1 THEN '1' ELSE '0';
-*======= DEFINE FILE CAR -*======= DECNUM /I3 WITH CAR = 50 ; BINVAL /A8 = DECBIN8 (DECNUM);
END
-*======= TABLEF FILE CAR -*======= PRINT DECNUM BINVAL
IF RECORDLIMIT EQ 1 END -RUN
This code currently converts a decimal of 255 or less i.e 8 binary digits. If you adjust this code to 16 bit binary it will convert decimals of 65535 or less i.e (2*(2 to the power of x)) -1 where x is the number of binary digits.
The DEFINE FUNCTION code can be INCLUDED in the EDASPROF.PRF file too.
I know what you want and this will be my solution, but ther is a small failure in it as far as I can see. I think on line 9 you test if the &CNTR EQ 1, I think that is wrong, in any case you should concatenate the &N value to the string it would be something like 100101... I need also the counters when the value &N is 1 so I'm going to print them.
Thanks anyway.
Frank
prod: WF 7.6.10 platform Windows, databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7 test: WF 7.6.10 on the same platform and databases,IE7
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006
The test on &CNTR Eq 1 will be the last digit in the string, if you remove it you will have an extra zero on the end. You could remove that check if you set &O to ' ', but then the string will have a blank on the end, which may, or may not, be important.
Alan. WF 7.705/8.007
Posts: 1451 | Location: Portugal | Registered: February 07, 2007
The only problem I can foresee is trying put a nine digit integer into the DM process from Alan, which you will have to do, Frank, if you need a 45 bit binary number. 99999999 will only give you 28 bits.
To get 45 bits your maximum number would be 35184372088831.
You might be able to utilise Danny's approach as you will not have the restriction on number of digits in the input, but you would have to move away from Integer input and use another numeric format.
T
In FOCUS since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2
WebFOCUS App Studio 8.2.06 standalone on Windows 10
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004
I know how to handle that I will put the "number" an alpha string and split that in 2 times 23. the 23 will work and the second 23 will work too and the only thing I have to do at the end is add 23 to the results of the second calculated numbers (sounds a bit confusing, certainly when you do not know what I'm going to use this for, but it will work.)
When it is finished I will try to write the whole thing in a proper white paper. It will be used for restricting or allowing users or usergroups to certain reports and projects.
Frank
prod: WF 7.6.10 platform Windows, databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7 test: WF 7.6.10 on the same platform and databases,IE7
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006
-*======= DEFINE FUNCTION DECTOBIN (DECNUM/D20) -*======= ERROR /I1 = DECNUM GE &MaxDec OR DECNUM LT 0 ;
-REPEAT :LOOP1 FOR &I FROM 1 TO &MaxDig STEP 1 ; BIN_NUM&I/D1 = DMOD (DECNUM, 2 , 'D1'); DECNUM /D20 = DECNUM / 2 ; -:LOOP1
DECTOBIN/A&MaxDig = IF ERROR THEN 'ERROR' ELSE -REPEAT :LOOP2 FOR &J FROM &MaxDig TO 2 STEP -1 ; EDIT (BIN_NUM&J) || -:LOOP2 EDIT (BIN_NUM1) ; END -RUN
thanks all for the support and remarks. my program is now working as it should be.
I use this to test the fingerprint of a user against the fingerprint of the report.
In a small table I have all the used databases. when I start a project I calculated a number based on the used databases for this special project. A USER or a group of USERS is allowed to read from several databases or database tables. That gives him also a number, composed the same way.
If someone tries to run a report that is part of a project the (incuded) proces checks if he is allowed to based on the above mentioned numbers.
If you want to I will send the masters and build proces. (Will take a while since I have to translate some fields into English)
Send me a privat message with your mail.
Frank
Frank
prod: WF 7.6.10 platform Windows, databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7 test: WF 7.6.10 on the same platform and databases,IE7
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006
The DEFINE FUNCTION exist since version 5. It's very usefull sometimes. By the way, I have in my pocket another nice function that convert a 32 byte Hexadecimal value to a 32 byte decimal value.
You have to be careful here, DMOD won't work on values over 9007199254740992, though other non-function based maths will work.
The maximum binary length you can get using DMOD is therefore 54 characters.
And just so it doesn't feel left out, the same thing in MAINTAIN (my favourite language):
-SET &IN='9007199254740992';
FILEDEF BINOUT DISK BINOUT.DAT (LRECL 54
-RUN
MAINTAIN
Declare In/P17 = ∈ Out/A0; Bin/d2;
If In gt 9007199254740992 begin
type on binOut "Error in field value"; goto exit;
endbegin
Repeat 56
Bin = dmod(In,2,Bin); In = int(In/2); Out = Bin | Out ;
if In lt 1 goto ExitRepeat;
EndRepeat
type on binOut "<Out";
END
-RUN
-READ BINOUT &longBinary.A54.
-TYPE BIN: &longBinary
Alan. WF 7.705/8.007
Posts: 1451 | Location: Portugal | Registered: February 07, 2007