How can I change an integer to Hex in Attain 3.60?

benmannbenmann Member Posts: 8
edited 2003-10-06 in Navision Attain
Hi, I am trying to get a hexidecimal representation of an integer in Attain 3.60 as part of a checksum routine to validate some files that I'm importing.

Does anyone know if there is a way to do this within Attain?
If not, I guess I could write a routine to do it...

Thanks.

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Try this code:
    Vars:
    txtDigits	 Text		30
    txtHex	    Text		30
    intInteger	Integer		
    intValue	  Integer		
    
    
    MESSAGE(fctInt2Hex(1000));
    MESSAGE(FORMAT(fctHex2Int('3E8')));
    
    
    fctInt2Hex(pInt : Integer) : Text[30]
    
    txtDigits := '0123456789ABCDEF';
    
    txtHex := '';
    
    REPEAT
      txtHex := COPYSTR(txtDigits,(pInt MOD 16) + 1,1) + txtHex;
      pInt := (pInt - (pInt MOD 16)) / 16;
    UNTIL pInt = 0;
    EXIT(txtHex);
    
    
    
    fctHex2Int(pText : Text[30]) : Integer
    
    txtDigits := '0123456789ABCDEF';
    
    intInteger := 0;
    
    WHILE pText <> '' DO BEGIN
      intInteger := intInteger * 16;
      intValue := STRPOS(txtDigits,COPYSTR(pText,1,1)) - 1;
      intInteger := intInteger + intValue;
      pText := COPYSTR(pText,2);
    END;
    EXIT(intInteger);
    
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • benmannbenmann Member Posts: 8
    Thanks,
    I'll try it out on Monday as I've been away from the office today.
  • LG_HellströmLG_Hellström Member Posts: 13
    Luc, you are one *** of a hacker.. :shock:

    me impressed :D
    Did I commit today?
  • benmannbenmann Member Posts: 8
    Yes, that solved the problem.

    Thanks Luc.
Sign In or Register to comment.