HELP! (or....What the hell is wrong with this code?)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sam

    #1

    HELP! (or....What the hell is wrong with this code?)

    I'm writing an address processing app in C#, using an ActiveX
    component (Addr) written in VB6, for which I have the source code. The
    main function is FixAddress, which takes a string representing the
    address to process (as tab separated fields) and returns a validated
    and "standardiz ed" address as a (tab separated) string of address
    fields. Here is the code that's driving me nuts (minus a lot of
    parsing/error checking stuff):

    //******** begin ***********

    string inputAddr;
    string outputAddr;
    string allAddr; // all addresses, separated by "\n"

    //Block 1
    inputAddr = "415 N Western\t#4\tCh icago\tIL\t6062 5";
    outputAddr = Addr.FixAddress (inputAddr);
    allAddr = outputAddr + "\n";

    //Block 2
    inputAddr = "235 East Fullerton\tApt 111\tMiami\tFL\ t33174";
    outputAddr = Addr.FixAddress (inputAddr);
    allAddr = allAddr + outputAddr + "\n";

    //********* end ************

    Looks pretty simple, but when I run it, allAddr only has the value
    assigned in Block 1, minus the newline. When I step through the code,
    I can see the variable outputAddr in Block 2 set to the right value,
    but, again, the concatenation does NOT work, allAddr is unchanged. I
    have even tried something like allAddr = allAddr + "XXX"; but even in
    that case allAddr remains unchanged.
    WHAT IS GOING ON? Is there something about strings returned from an
    unmanaged app that makes them behave like this?

    help...

    Sam
  • Jon Skeet

    #2
    Re: HELP! (or....What the hell is wrong with this code?)

    Sam <process@marihu ana.com> wrote:[color=blue]
    > Nevermind, I found the problem: it seems like the string returned from
    > the ActiveX component is null terminated.[/color]

    Note that that will stop the debugger working properly (in VS.NET 2002,
    anyway) but shouldn't stop the concatenation from happening itself -
    it's just the debugger doesn't show values after a null. The values are
    still there though.

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    Working...