PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Query on "wide" function {PPL 0.7b]

Kornalius,

Can you confirm that the "wide" function still works.

My combobox_add function no longer adds strings to comboboxes correctly - only the first character of the string is added. The string looks in tact as far as I can trace up to the wide call, immediately before generating the "sendmessage".
Show me a piece of your code.
I can confirm it works.
PointOfLight · 23 Aug 2004, 18:21 UTC
Here's some code from an app I'm playing around with. The combobox_additem function comes from the combobox_lib.ppl library, but it's basically a wrapper around the SendMessage function to the combo with a parameter of CB_ADDSTRING. Only the first character of the PublisherName field appears in the combo box.

Code:

func ReadADOCEDB
dbpath$ = "\\CF Card\\My Documents\\Database\\comics.cdb";

db$ = CreateObject("adoce.recordset.3.1");
if(not isnull(ComError%))
ShowMessage(ComError%);
return(false);
end;

Invoke(db$, "Open", "SELECT * FROM tblPublishers", dbpath$);
if(not isnull(ComError%))
ShowMessage(ComError%);
return(false);
end;

cnt$ = GetProperty(db$, "RecordCount");
i$ = 0;

while(i$ < cnt$)
f$ = GetProperty(db$, "Fields");
item$ = GetProperty(f$, "Item", "PublisherName");
value$ = Wide(GetProperty(item$, "Value"));
combobox_additem(COMBOBOX101$, -1, value$);
Invoke(db$, "MoveNext");
i$++;
end;

DeleteObject(db$);

ShowMessage("DB traverse is complete");
end;
Attachments:
TEMP.zip (19 KB)
That is because you are passing a WIDECHAR to a PPL parameter variable. You should pass it regular CHAR and then in the SendMessage make it WIDE().

That is new with PPL 0.8. No WideChar allowed within PPL other than passing the values to API libraries. Even so, PPL does the conversion for you, there is no reason I think to use Wide() anywhere.
PointOfLight · 23 Aug 2004, 19:17 UTC
Originally I did not have the Wide in there at all, and I got a bunch of empty strings in the combo box. I know the data is there, however, because I can put alerts after every read from the DB and see the Publisher name.
Instead of this:

Code:
value$ = Wide(GetProperty(item$, "Value"));
combobox_additem(COMBOBOX101$, -1, value$);


Try this:

Code:
value$ = GetProperty(item$, "Value");
combobox_additem(COMBOBOX101$, -1, value$);


Then if you want convert to WIDE() in the SendMessage() function call.
PointOfLight · 23 Aug 2004, 19:43 UTC
Completely removing the Wide worked. For some reason it didn't seem to work the first time without the wide, but I probably had an error somewhere else.
Thanks gentlemen for the discussion above. It helped me solve my problem.

My original code which had worked up to and including 0.7a was

Code:

text$ = wide(text$);
result$ = SendMessage(ComboBox$,CB_ADDSTRING,0,&text;$);


and I assure you the "wide" was necessary!

Following your discussion I tried dropping the "wide", but without success. I had to ALSO CHANGE the way I passed the string parameter in "SendMessage" from "&text;$" to just "text$". I don't think I would have got it without your help! The code simply becomes ....

Code:

result$ = SendMessage(ComboBox$,CB_ADDSTRING,0,text$);


regards
PointOfLight · 24 Aug 2004, 12:40 UTC
I'm just curious: why where you passing the variable as &text$? I've never had to use the & when I've called the sendmessage functions (at least not for the combobox calls).
The problem with passing &var;$ text variables to an API call will result in passing an address value, therefore PPL won't be able to convert the string to widechar. It simply won't know.