Focal Point Banner


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.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [Sharing] Decimal to Hexadecimal conversion

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[Sharing] Decimal to Hexadecimal conversion
 Login/Join
 
Virtuoso
posted
One of our customers asked for the possibility to convert a decimal number to hexadecimal. both in Dialog Manager and as a WebFOCUS function.
Here is what we came up with.

Dialog Manager:
  
-SET &ECHO=ALL;
-* File dec2hex.fex
-DEFAULT &DEC=123456789;
-SET &HEX=' ';
-SET &H0=&DEC;
-#NXTHEX
-SET &H1=&H0/16;
-SET &HN=&H0 - &H1 * 16;
-SET &HX=DECODE &HN(0 '0' 1 '1' 2 '2' 3 '3' 4 '4' 5 '5' 6 '6' 7 '7' 8 '8' 9 '9' 10 'A' 11 'B' 12 'C' 13 'D' 14 'E' 15 'F');
-SET &HEX = &HX | &HEX;
-IF &H0 LE 15 GOTO #DONE;
-SET &H0 = &H1;
-GOTO #NXTHEX
-#DONE
-TYPE &DEC = &HEX


WebFOCUS Function
  
-SET &ECHO=ALL;
-* File f_dec2hex.fex
DEFINE FUNCTION DEC2HEX (DEC/I9)
H0/I9=DEC;
HEX/A9=' ';
-REPEAT #HLOOP FOR &I FROM 1 TO 9;
-SET &J=&I-1;
H&I/I9=H&J / 16;
HN/I9=H&J - H&I * 16;
HX/A1=DECODE HN(0 '0' 1 '1' 2 '2' 3 '3' 4 '4' 5 '5' 6 '6' 7 '7' 8 '8' 9 '9' 10 'A' 11 'B' 12 'C' 13 'D' 14 'E' 15 'F');
HEX/A9=HX | SUBSTR(9, HEX, 1, 8, 8, 'A8');
-#HLOOP
DEC2HEX/A9=TRIM('L',HEX,9,'0',1,'A9') ;
END
-RUN
TABLE FILE CAR
SUM SALES 
COMPUTE HSALES/A9=DEC2HEX(SALES);
BY COUNTRY
END


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Expert
posted Hide Post
That's great Danny, but what if the server has DMPRECISION set to anything other than the default 0? Might be worthwhile using INT function in the DM solution? As in -SET &H1=INT(&H0/16);

Now, where's that like button?

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, 2004Report This Post
Virtuoso
posted Hide Post
Actually, you can convert entire Bytes (0-255) to HEX at once using HEXBYT and UFMT.
I wrote this once, but ISTR that this function became deprecated - but by what I don't remember...

-SET &_INTEGER = &INTEGER;

-SET &HEX = '';
-REPEAT :HXLOOP WHILE &_INTEGER GT 0;
-SET &BYTE = DMOD(&_INTEGER, 256, 'I3');
-SET &_INTEGER = (&_INTEGER - &BYTE) / 256;
-SET &HEX = UFMT(HEXBYT(&BYTE, 'A1'), 3, 'A2') || &HEX;
-:HXLOOP


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Expert
posted Hide Post
More likes, plus the memory that you could call the function from DM anyway Danny Smiler

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, 2004Report This Post
Virtuoso
posted Hide Post
Tony,
Oh so true!
Good One


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [Sharing] Decimal to Hexadecimal conversion

Copyright © 1996-2020 Information Builders