Ross,
Hi. If you looked at the definition of TStringItem, you will see that FString is of type string, so you shouldn't have cast it as a PString in the first place.
TStringItem = record FString: string; FObject: TObject; end;
The code:
var ListString: String; ListString := THackSList(MySList).FList^[Index].FString;
will retrieve the instance of the string.
BTW, I still don't understand why you can't simply do stringlist.Strings[index] to get at the string.
Dennis.
From: "Ross Levis" <[EMAIL PROTECTED]>
I can answer my own question again. After lots of playing around, I found that the String typecast is required, but I don't understand why. Can someone enlighten me?
I have something like this: var ListString: PString; ListString := PString(THackSList(MySList).FList^[Index].FString);
I was trying to do this: Showmessage(ListString^); //but this generates an AV.
I need to do this: Showmessage(String(ListString)); // it works!
Why is that?
Cheers, Ross.
----- Original Message ----- From: "Ross Levis" <[EMAIL PROTECTED]>
Hi Dennis
I know it's a hack but it will save a lot of work if I can get it to work.
I now have a problem which may stuff this idea up completely. A TStringList reallocates memory for the FList array as it gets bigger, as expected, but the location of the string also seems to be moving. For some reason I expected the string to stay where it was, and only the pointer array move location. But after 4 strings are added, the address returned from this code changes.
showmessage(inttostr(integer(@THackSList(MySList).FList^[0].FString)));
I've not been doing pointer manipulation for long so I may be doing it wrong. If I leave off the @, I get a constant address which doesn't change, but it does not appear to be the string location.
Am I stuffed?
Cheers, Ross.
_______________________________________________ Delphi mailing list [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
_________________________________________________________________ Check out news, entertainment and more @ http://xtra.co.nz/broadband
_______________________________________________ Delphi mailing list [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
