AN-332 Hexadecimal string to Integer Decimal number

AN-332 Hexadecimal string to Integer Decimal number

This document exposes a useful BASIC subroutine to parse a hexadecimal string value to a decimal integer and store it into a VR. It does something similar to the BASIC command VAL(“numerical_string”), which converts a string to a numerical value.
    • Related Articles

    • Parsing text srring from Hex to a value

      Change a Hexadecimal String to a value using the BASIC Function Library. ' Function to convert a HEX number string to a value ' Call: hex_to_val(hex_string, string_size) ' e.g. x = hex_to_val("38E38D", 6) ' FUNCTION hex_to_val(hex_string AS STRING, ...
    • Is it possible to create a directory on the SD card using a variable?

      Yes it is. ' create a new directroy on the SD card DIM dirname AS STRING(20) dirname = "folder1" FILE "MD" dirname folder_number = 3 dirname = "Folder" + STR(folder_number, 0) FILE "MD" dirname   dir d  Volume is MCCARD  Volume Serial Number is ...
    • AN-294 Integer to Bytes conversion

      When handling communication channels like RS232, CAN or Telnet on Ethernet, it is sometimes necessary to send or receive a long integer as 4 bytes. This document describes a software routine that converts a 32 bit integer held in a VR to 4 bytes for ...
    • Reading DX4 Fault Code Displayed On Front Of Drive

      The code below will move the error number displayed on the 8 segment display into a declared variable for use in other programs. 'This example is for Axis 0 error number reading ' 'CO_READ_AXIS(axis_number, index, subindex ,type [,vr_number]) 'CoE ...
    • Number of CONSTANT definitions in STARTUP

      The number is shown in the Trio BASIC Help for CONSTANT. CONSTANT are set globally and are available to all the BASIC programs. There is a local constant definition called DEFCONST. When that is set in a program it is known to that program alone. You ...