Filling Text Value

When I use code: for iint:= 0 to 255 do begin cht:=iint; text2[iint+1]:=cht; end; with

  • iint as integer
  • text2 as text (256)
  • cht as char
    , I can see cht values in debugger, but Navision not fill text2 value. If I use iint values from 1 to 255 and fill text2 with iint index, code fill text2 value as I want. Isn’t here a bug in Navision or the main bug is between keyboard and my chair?[:)]

In your code, the array index (inti) is never modified during execution of the loop. Therefore, all chracters get stored into array location 1 (or, more precisely, into the very same location, depending on the initial value of inti). As you mentioned, using iint as index works, because then each character gets assigned into its own, unique array element.

quote:


Originally posted by xorph
In your code, the array index (inti) is never modified during execution of the loop. Therefore, all chracters get stored into array location 1 (or, more precisely, into the very same location, depending on the initial value of inti). As you mentioned, using iint as index works, because then each character gets assigned into its own, unique array element.


I am sorry. here must be iint. I already corrected my mistake. If i use iint as index in text2, after loop text2 value is empty

The Null-Character (ASCII 0) is always a dangerous thing to use inside a text string. I don’t know in detail how Navision text variables are laid out in memory, but since they are defined with a fixed length and may contain strings of arbitrary length up to this defined maximum, there must be some way to mark the end of the string. In C/C++, the end of a string is marked with a Null-Character (’\0’), and I assume that Navision does the same (Pascal and Basic use a counter instead). Therefore, when you fill the first element with 0, the rest of the text variable is always ignored. That’s the reason why it works when the loop starts with 1 instead of 0.

Thanks.