Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well, I'd probably read into a buffer that was declared using a more appropriate type. </p> <p>For example, suppose your data are 16 bit integers, <code>Smallint</code> in Delphi. Then declare a dynamic array of <code>Smallint</code>.</p> <pre><code>var buf: array of Smallint; </code></pre> <p>Then allocate enough space for the data:</p> <pre><code>Assert(ckiData.cksize mod SizeOf(buf[0])=0); SetLength(buf, ckiData.cksize div SizeOf(buf[0])); </code></pre> <p>And then read the buffer:</p> <pre><code>mmioRead(HMMIO, PAnsiChar(buf), ckiData.cksize); </code></pre> <p>Now you can access the elements as <code>Smallint</code> values.</p> <p>If you have different element types, then you can adjust your array declaration. If you don't know until runtime what the element type is you may be better off with <code>array of Byte</code> and then using pointer arithmetic and casting to access the actual content.</p> <p>I'd say that the design of the interface to <code>mmioRead</code> is a little weak. The buffer isn't really a string. It's probably best considered as a byte array. But perhaps because C does not have separate byte and character types, the function is declared as taking a pointer to char array. Really the Delphi translation would be better exposing a pointer to byte or even better in my view, a plain untyped <code>Pointer</code> type.</p> <hr> <p>I assumed that you were struggling with interpreting the output of <code>mmioRead</code> since that was the code that you included in the question. But, according to now deleted comments, your question is a GUI question.</p> <p>You want to add content to a memo. Do it like this:</p> <pre><code>Memo1.Clear; for i := low(buf) to high(buf) do Memo1.Items.Add(IntToStr(buf[i])); </code></pre> <p>If you want to convert to floating point then, still assuming 16 bit signed data, do this:</p> <pre><code>Memo1.Clear; for i := low(buf) to high(buf) do Memo1.Items.Add(FormatFloat('0.00000', buf[i]/32768.0));//show 5dp </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload