Skip to Content
avatar image
Former Member

why do casts from char to packed fields fail?

hello there,

i try to assign a quite small value ('-9.123E-123') from a character(255) field into a field type p. but although the string is a number i get a CX_SY_CONVERSION_NO_NUMBER exception. only if i move the value into a float field first the typeconversion works.

data: var1(255) type c value '-9.123E-123',

var2 type f,

var3(7) type p decimals 2.


var3 = var2 = var1. => works fine

Does anybody know why the types aren't converted correctly and were i can get some additional documentation? the character field is also used for other not number like values and i do not want to use a lot of RTTI to determine the type of the field i assign the value to in my program.

thanks in advance


Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Mar 20, 2004 at 01:07 PM

    Packed variables will only allow conversion from character strings like "1234.56-", not even "1,234.56-".

    Your value is not a packed number but rather a float. This is why the conversion to packed must go char -> float -> packed, accepting possible truncation and rounding along the way.

    Most type-conversion documentation can be accessed by looking at the help for the MOVE command.


    Message was edited by: Scott Barden

    Add comment
    10|10000 characters needed characters exceeded