Example Script: How to convert a string containing a Decimal number to its Hexidecimal equivalent. The zip file contains the sample ITB, designed with ITScriptNet 3.1.
Conversion Script:
; get the input and make it upper case
@Input@ = UCase(this.txtInput.Value)
; initialize the hex portion
@hex@ = ""
; initialize the decimal portion
@dec@ = VAL(@Input@)
; loop through the string
while(VAL(@dec@) > 0)
; get the character value by doing a MOD division with 16 to get the remainder
@mod@ = MOD(@dec@, 16)
; get the quotient for the next loop
@dec@ = @dec@ / 16
; convert the number to hex
if((@mod@ >= 0) && (@mod@ <= 9))
; keep the digit unconverted
@char@ = @mod@
elseif((@mod@ >= 10) && (@mod@ <= 15))
; convert to the HEX A-F
@char@ = @mod@ + ASC("A") - 10
@char@ = Chr(@char@)
else
@char@ = "0"
endif
; add to the result
@hex@ = @char@ & @hex@
wend