[Prev][Next][Index][Thread]

<c-string> vs <byte-string>?



Is it supposed to work this way, or is there some bug?

I call make (<c-string>, size: 256) and pass that into SQLDescribeCol
which takes an argument of type <LPSQLCHAR>. After that call I can use
the string in a call to format-out and it prints just fine. But if I put
it into a sequence and instantiate a <list-box> with that sequence it
displays garbage. (I can inspect the sequence & strings in the debugger
with no problem.)

If I call make (<byte-string>, size: 256) and use that instead,
format-out prints all 256 characters while the list box looks OK (of
course, the extra spaces might still be there).

The only way I have found is to instantiate and use <c-string> for the
call into the odbc-ffi library, then convert it when adding to my
sequence using as (<byte-string>, ...).

This is not exactly the end of the world to have to do this ;-) But it
does seem a little clunky. Am I missing something, or is this the way to
do it?

And, more interesting, (to me at least) is that if I creat a pane as
follows:

make(<list-box>, items: *colnames*);

I get the behavior described, garbage when *colnames* is a sequence of
<c-string>, but I can use the same code to build *colnames*, and the
following pane definition works just fine:

make (<table-control>, headings: #["name"],
      items: range (from: 0, to: *colnames*.size - 1),
      generators: vector (method (idx) *colnames*[idx] end));

So how is it that a list box cannot get its values from a sequence of
<c-string> but a <table-control> can? Is there some coercion going on
within the <table-control> call to the generator functions? If so, why
not the same coercion with the <list-box>?

(BTW, I do need to be using the odbc-ffi library right now instead of
the higher-level access.)



Follow-Ups: