hex2num ( )

Function stats

Average user rating
37
405
9999
Support
FileMaker 8.0 +
Date posted
13 September 2016
Version
1
Recursive function
Yes

Author Info
 Fabrice

74 functions

Average Rating 4.4

author_avatar



 

Function overview

Prototype

hex2num  ( _hex )


Parameters

_hex  


Description

Tags:  Numbers   Number   Math   hexadecimal   Conversion  

Converts an hexadecimal value into a number

Examples

Sample input

hex2num ( 539 )


Sample output

1337

 

Function code

/* hex2num

by Fabrice Nordmann, 1-more-thing
@1morethingtweet

Sept 2016

input: an hexadecimal string (will be filtered, so you can pass blanks, or entities like ß)
ouput: a number. If you're lucky, it will correspond to the hexadecimal value.

*/


Case ( IsEmpty ( _hex ) ; Let ([ _result = $cf.hex.result; $cf.hex.result = "" ; $cf.hex.depth = "" ]; _result ) ;

Let ([
    _alpha = "0123456789ABCDEF" ;
    _hex = Case ( $cf.hex.depth ; _hex ; Filter ( Upper ( _hex ) ; _alpha )) ;
    $cf.hex.result = $cf.hex.result + ( Position ( _alpha ; Right ( _hex ; 1 ) ; 0 ; 1 ) - 1 )* 16^(0+$cf.hex.depth) ;
    $cf.hex.depth = $cf.hex.depth + 1
];
    hex2num ( Left ( _hex ; Length ( _hex ) - 1 )) )
)

// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/405

    Prototype: hex2num( _hex )
    Function Author: Fabrice (http://www.fmfunctions.com/mid/37)
    Last updated: 13 September 2016
    Version: 1

*/
// ===================================

 

 

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (31)
Date  (28)
XML  (26)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Layout  (15)
Interface  (15)
Text  (14)
Variables  (12)
Filter  (11)
Layout Objects  (11)
Design  (10)
Array  (7)