<br><font size=2 face="sans-serif">I'm attempting to write a generic writeln type of procedure for win32 console mode programs, but I'm having trouble using sizeof. I'm reasonably certain I've got it written correctly, but perhaps I'm missing something. The procedure looks like this:</font>
<br>
<br><font size=2 face="sans-serif">Procedure Win32Write (Col,Row : byte; var SourceData);</font>
<br>
<br><font size=2 face="sans-serif">var</font>
<br><font size=2 face="sans-serif"> BuffSize : TCoord;</font>
<br><font size=2 face="sans-serif"> BuffCoord : TCoord;</font>
<br><font size=2 face="sans-serif"> DestRect : TSmallRect;</font>
<br>
<br>
<br><font size=2 face="sans-serif">begin</font>
<br>
<br><font size=2 face="sans-serif"> // BuffSize is how big a window to write</font>
<br><font size=2 face="sans-serif"> BuffSize.X := sizeof (SourceData);</font>
<br><font size=2 face="sans-serif"> BuffSize.Y := 1;</font>
<br>
<br><font size=2 face="sans-serif"> // BuffCoord is where in the window to start</font>
<br><font size=2 face="sans-serif"> BuffCoord.X := 0;</font>
<br><font size=2 face="sans-serif"> BuffCoord.Y := 0;</font>
<br>
<br><font size=2 face="sans-serif"> // DestRec is where on the screen to write, here it's at Col,Row</font>
<br><font size=2 face="sans-serif"> DestRect.Top := pred (Row);</font>
<br><font size=2 face="sans-serif"> DestRect.Bottom := pred (Row);</font>
<br><font size=2 face="sans-serif"> DestRect.Left := pred (Col);</font>
<br><font size=2 face="sans-serif"> DestRect.Right := pred (sizeof (SourceData));</font>
<br>
<br><font size=2 face="sans-serif"> WriteConsoleOutput (getstdhandle (std_output_handle), @SourceData, BuffSize, BuffCoord, DestRect);</font>
<br>
<br><font size=2 face="sans-serif">end;</font>
<br>
<br><font size=2 face="sans-serif">Data being passed as SourceData is an array of tcharinfo.</font>
<br>
<br><font size=2 face="sans-serif">Where I'm having the problem is that sizeof returns invalid information about the actual size of the SourceData variable. For example, if I pass an array with only [1..10] elements sizeof doesn't return a value of 10. And WriteConsoleOutput needs to have the correct sizes established for BuffSize.X and DestRectRight, or it prints garbage (if the numbers for those variables are larger then the data you're trying to print the remainder of the line is random, colored blocks). </font>
<br>
<br><font size=2 face="sans-serif">Since SourceData can be any size, how do I know how large it is so I can set those values properly?</font>
<br>
<br><font size=2 face="sans-serif">TIA...</font>
<br>
<br><font size=2 face="sans-serif">Jim</font>