The data to which zs points is not valid any more?
Do you have complete code to test with?
Try with: dim shared as string sz
The data is still valid...the statement "print zs,*zs" just before WidgetSetLabel gives me both the pointer's address contents and the correct string data.
The program is complete and thoroughly tested. I get the correct results every time (verified manually.) This is just the last piece that doesn't function as intended.
I don't need sz to be shared. Both sz and zs are only local variables declared in the sub and only appear in the snippet I've posted. The widget is declared shared at the module level. I am using sz as a normal string so I can use the native FB string handling functionality to assemble the answer. The wiki says that using strptr() is the only real correct way to get a zstring pointer from a FB string. Also, the wiki indicates that a pointer declared as a "const <type> pointer" can change its contents during runtime; only the underlying data can't be changed. Which is true, I don't get a runtime error when the statement "zs = strptr(sz)" executes.
The strangeness is that a few characters at the end of the zstring display correctly. That tells me the zstring has a proper '\0' terminator. If the front end of the zstring has garbage, then the FB "print" statement is self-correcting, which I don't believe is true.