Re: Tcl_SetStringObj question



The source of the problem is here:

Tcl_SetStringObj(resultPtr, myname, sizeof(myname));
^^^^^^^^^^^^^^

If myname is a static or stack-allocated buffer (which is most likely
the case, as I see no free()), sizeof() returns its size in bytes,
which will exceed the actual length of the string. So the created
Tcl_Obj will have a string rep that starts with the given string but
extends past the NUL terminator up to the end of the buffer. This
string will not be equal to the plain string "NULL", hence your
problem.

The code should be:

Tcl_SetStringObj(resultPtr, myname, strlen(myname));

or:

Tcl_SetStringObj(resultPtr, myname, -1);

for an implied strlen.
.



Relevant Pages

  • RE: Loop through files in a folder and unprotect sheets
    ... What is the value of myName when it has the error? ... Private Const BIF_DONTGOBELOWDOMAIN As Long = &H2 ... lpszINSTRUCTIONS As String ... Dim BrowseInfo As BrowseInfo ...
    (microsoft.public.excel.programming)
  • RE: Loop through files in a folder and unprotect sheets
    ... Debug.print myName before the error and see what it gives you. ... Private Const BIF_DONTGOBELOWDOMAIN As Long = &H2 ... lpszINSTRUCTIONS As String ... Dim BrowseInfo As BrowseInfo ...
    (microsoft.public.excel.programming)
  • Re: File not found when opening
    ... If you were really unlucky, the wrong files in a wrong directory (with the same ... Dim tmp As String ... Dim myPath As String, myName As String, folder As String ...
    (microsoft.public.excel.programming)
  • Re: Copying files in a certain date range to other locations
    ... lCount = 0 'initialise counter ... Dim strPath As String, strFile As String, MyPath As String ... Dim MyFile As String, MyPath As String, MyName As String ... 'Retrieve the first entry. ...
    (microsoft.public.vb.general.discussion)
  • RE: Loop through files in a folder and unprotect sheets
    ... Private Const BIF_DONTGOBELOWDOMAIN As Long = &H2 ... lpszINSTRUCTIONS As String ... Dim BrowseInfo As BrowseInfo ... Dim myName As String ...
    (microsoft.public.excel.programming)