TStringList.AddObject('xxx', TObject(^record))

Sample code:

PMyRec = ^TMyRec;
TMyRec = record
  Value1: string;
  Value2: Integer;
  ...
end;


FList : TStringList;

function AddNew(Id: string; AValue1: string; AValue2: Integer): Integer;
var
   P: PMyRec;
begin
  New(P);
  with P^ do
  begin
    Value1 := AValue1;
    Value2 := AValue2;
  end;

   FList.AddObject(Id, TObject(P));  
end;

The above code run just perfectly in compiler other than "NextGen". From the forum I found solution on using TList<TmyRec>. But if i would like to keep it in using tstringlist, is it still possible? The reason I want to keep using tstringlist because 1 avoid changing too much of my current code, 2 i need the ID to ease of locating the object. Add ID into the TMyREc and use TList can achieve the purpose but require much change to my current code.
0
Chen
3/19/2014 3:46:32 AM
embarcadero.delphi.ios 412 articles. 0 followers. Follow

13 Replies
2472 Views

Similar Articles

[PageSpeed] 38

Chen Yap Chia wrote:
> Sample code:
> 
> PMyRec = ^TMyRec;
> TMyRec = record
>   Value1: string;
>   Value2: Integer;
>   ...
> end;
> 
> 
> FList : TStringList;
> 
> function AddNew(Id: string; AValue1: string; AValue2: Integer): Integer;
> var
>    P: PMyRec;
> begin
>   New(P);
>   with P^ do
>   begin
>     Value1 := AValue1;
>     Value2 := AValue2;
>   end;
> 
>    FList.AddObject(Id, TObject(P));  
> end;
> 
> The above code run just perfectly in compiler other than "NextGen". From the forum I found solution on using TList<TmyRec>. But if i would like to keep it in using tstringlist, is it still possible? The reason I want to keep using tstringlist because 1 avoid changing too much of my current code, 2 i need the ID to ease of locating the object. Add ID into the TMyREc and use TList can achieve the purpose but require much change to my current code.

If your ID's are unique you should be using a TDictionary<> instead of a 
TList<>, lookup is simple on the key.

-- 
Jeff Overcash (TeamB)
       (Please do not email me directly unless  asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted  corridors of Whitehall.
              (Fish)
0
Jeff
3/19/2014 5:49:13 AM
> If your ID's are unique you should be using a TDictionary<> instead of a 
> TList<>, lookup is simple on the key.
> 

PMyRec = ^ TMyREc;
TMyRec = record
V1,V2: string;
end;

Is it possible to do it this way with TDictionary:

List: TDictionary<Integer, PMyRec>

procedure NewItem(Id: Integer; Value1: string; Value2: string);
var
  P: PMyRec;
begin
  New(P);
  with P^ do
  begin
     V1 := Value1;
     V2 := Value2;
  end;
  List.Add(Id, P);
end;
0
Chen
3/19/2014 8:53:19 AM
Chen Yap Chia wrote:
>> If your ID's are unique you should be using a TDictionary<> instead of a 
>> TList<>, lookup is simple on the key.
>>
> 
> PMyRec = ^ TMyREc;
> TMyRec = record
> V1,V2: string;
> end;
> 
> Is it possible to do it this way with TDictionary:
> 
> List: TDictionary<Integer, PMyRec>
> 
> procedure NewItem(Id: Integer; Value1: string; Value2: string);
> var
>   P: PMyRec;
> begin
>   New(P);
>   with P^ do
>   begin
>      V1 := Value1;
>      V2 := Value2;
>   end;
>   List.Add(Id, P);
> end;

Yes.

     List : TDictionary<Integer, PMyRec>;

To Add an Item

procedure TForm3.NewItem(Id: Integer; Value1: string; Value2: string);
var
   P: PMyRec;
begin
   New(P);
   with P^ do
   begin
      V1 := Value1;
      V2 := Value2;
   end;
   List.Add(Id, P);
end;

To cleanup (you can actually just override the TDictionary destructor and do 
this and make it cleaner.

procedure TForm3.FormDestroy(Sender: TObject);
var
   MyEnum: TDictionary<Integer, PMyRec>.TPairEnumerator;
begin
   MyEnum := List.GetEnumerator;
   while MyEnum.MoveNext do
     Dispose(MyEnum.Current.Value);
   MyEnum.Free;
   List.Free;
end;

Enumerating through the whole list putting it out to a memo

procedure TForm3.btn2Click(Sender: TObject);
var
   MyEnum: TDictionary<Integer, PMyRec>.TPairEnumerator;
begin
   mmo1.Clear;
   MyEnum := List.GetEnumerator;
   while MyEnum.MoveNext do
     mmo1.Lines.Add(MyEnum.Current.Key.ToString + ' ' + MyEnum.Current.Value^.V1 
+ ' ' + MyEnum.Current.Value^.V2);
   MyEnum.Free;
end;

Looking up a single value

procedure TForm3.btn3Click(Sender: TObject);
var
   P: PMyRec;
begin
   mmo1.Clear;
   try
     P := List.Items[StrToInt(edt1.Text)];
     mmo1.Lines.Add(edt1.Text + ' ' + P^.V1 + ' ' + P^.V2);
   except
     mmo1.Lines.Add('Key ' + edt1.Text + ' does not exist')
   end;
end;


-- 
Jeff Overcash (TeamB)
       (Please do not email me directly unless  asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted  corridors of Whitehall.
              (Fish)
0
Jeff
3/19/2014 4:35:50 PM
Chen wrote:

> The above code run just perfectly in compiler other than "NextGen".
> From the forum I found solution on using TList<TmyRec>. But if i would
> like to keep it in using tstringlist, is it still possible?

No, because TStringList uses TObject for its Objects[] property, and TObject 
uses ARC in NextGen, so you must store true objects, not type-casted pointers 
to non-objects.  In order to keep using TStringList, you would have to either:

1) change TMyRec itself into a class:

{code}
{$IFDEF NEXTGEN}
PMyRec = class
public
{$ELSE}
PMyRec = ^TMyRec;
TMyRec = record
{$ENDIF}
  Value1: string;
  Value2: Integer;
  ...
end;

FList : TStringList;

function AddNew(Id: string; AValue1: string; AValue2: Integer): Integer;
var
  P: PMyRec;
begin
  {$IFDEF NEXTGEN}
  P := PMyRec.Create;
  {$ELSE}
  New(P);
  {$ENDIF}
  P.Value1 := AValue1;
  P.Value2 := AValue2;

  FList.AddObject(Id, {$IFDEF NEXTGEN}P{$ELSE}TObject(P){$ENDIF});
end;
{code}

{code}
var
  P: PMyRec;

P := PMyRec(FList.Objects[Index]);
....
{$IFNDEF NEXTGEN}
Dispose(P);
{$ENDIF}
{code}


2) wrap it inside of a class for storage purposes:

{code}
PMyRec = ^TMyRec;
TMyRec = record
  Value1: string;
  Value2: Integer;
  ...
end;

{$IFDEF NEXTGEN}
TMyRecWrapper = class
public
  Rec: PMyRec;
  constructor Create(ARec: PMyRec);
end;

constructor TMyRecWrapper.Create(ARec: PMyRec);
begin
  inherited Create;
  Rec := ARec;
end;
{$ENDIF}

FList : TStringList;

function AddNew(Id: string; AValue1: string; AValue2: Integer): Integer;
var
  P: PMyRec;
begin
  New(P);
  with P^ do
  begin
    P.Value1 := AValue1;
    P.Value2 := AValue2;
  end;

  FList.AddObject(Id, {$IFDEF NEXTGEN}TMyRecWrapper.Create(P){$ELSE}TObject(P){$ENDIF});
end;
{code}

{code}
var
  P: PMyRec;

{$IFDEF NEXTGEN}
P := TMyRecWrapper(FList.Objects[Index]).Rec;
{$ELSE}
P := PMyRec(FList.Objects[Index]);
{$ENDIF}
....
Dispose(P);
{code}

> The reason I want to keep using tstringlist because 1 avoid changing too
> much of my current code, 2 i need the ID to ease of locating the object.

As others have suggested, you should use TDictionary instead.

> Add ID into the TMyREc and use TList can achieve the purpose but
> require much change to my current code.

Porting code to the NextGen compiler tends to require code changes to accomodate 
different coding models.

--
Remy Lebeau (TeamB)
0
Remy
3/19/2014 5:12:18 PM
> {quote:title=Chen Yap Chia wrote:}{quote}
> Sample code:
> 
> PMyRec = ^TMyRec;
> TMyRec = record
>   Value1: string;
>   Value2: Integer;
>   ...
> end;
> 
> 
> FList : TStringList;
> 
> function AddNew(Id: string; AValue1: string; AValue2: Integer): Integer;
> var
>    P: PMyRec;
> begin
>   New(P);
>   with P^ do
>   begin
>     Value1 := AValue1;
>     Value2 := AValue2;
>   end;
> 
>    FList.AddObject(Id, TObject(P));  
> end;
> 
> The above code run just perfectly in compiler other than "NextGen". From the forum I found solution on using TList<TmyRec>. But if i would like to keep it in using tstringlist, is it still possible? The reason I want to keep using tstringlist because 1 avoid changing too much of my current code, 2 i need the ID to ease of locating the object. Add ID into the TMyREc and use TList can achieve the purpose but require much change to my current code.

Well, I would not do that even in the old compiler. Apart from the unsafe cast, I think, there is a real problem with the string within the record.
Remember that strings are reference counted ever since Delphi 2.

In that "FList.AddObject(Id, TObject(P));" line, I bet the compiler adds a reference to your string, but does not ever release it (disposing of the record will not decrement the reference, that was counted an extra time in that cast).
I would advise you to double check your existing code.
That code probably causes a memory leak, even in the old compiler.
-1
Yegor
3/22/2014 7:12:24 PM
A few more question over the use of TDictionary:

1. I can't find an IndexOf like TStringList do to locate Item Index by using Key. In TDictionary ContainKey function, it calls GetBucketIndex which is a private method, is this for checking item index?

2. say I have a TDictionary<Integer, TMyRec>, then call the following:

procedure Add;
var
  rec: TMyRec;
begin
  FDict := TDictionary<Integer,TMyRec>.Create;

  with rec do
  begin
    Value1 := '12345';
    Value2 := 12345;
  end;
  FDict.Add(1, rec);
end;

The record added as reference to the record or cloning value from record? As I have seen from the code, it seems copying value rather than referencing rec.

3. If it is not added as reference, would it be better to use pointer to record as I mentioned in reply above in stead of record? Is adding pointer to record to a generic TList or TDictionary a proper implementation? I am affraid after few more Delphi upgrade, this will no longer valid and force to change to TObject

Edited by: Chen Yap Chia on Mar 25, 2014 3:50 AM
0
Chen
3/25/2014 10:52:25 AM
Chen Yap Chia wrote:
> A few more question over the use of TDictionary:
> 
> 1. I can't find an IndexOf like TStringList do to locate Item Index by using Key. In TDictionary ContainKey function, it calls GetBucketIndex which is a private method, is this for checking item index?
> 

TDictionary it is jsut Items[<key>] will return the value associated with the key.

> 2. say I have a TDictionary<Integer, TMyRec>, then call the following:
> 
> procedure Add;
> var
>   rec: TMyRec;
> begin
>   FDict := TDictionary<Integer,TMyRec>.Create;
> 
>   with rec do
>   begin
>     Value1 := '12345';
>     Value2 := 12345;
>   end;
>   FDict.Add(1, rec);
> end;
> 
> The record added as reference to the record or cloning value from record? As I have seen from the code, it seems copying value rather than referencing rec.
> 

For Records it will be doing a copy.  For Object types and pointers and stuff it 
holds a reference.  There is no cloning mechanism in the Add function though. 
Basically if you assigned one variable of type T to another of type T what would 
normally go on?  Whatever would go on is what is going on here.

So if A anf B are record types (or any native type, integers etc)

   A := B

makes a copy of B into A.

If A and B are objects (or any ref counted thing like Strings)

   A := B

makes A point to the B instance.

Ultimately the adding is done like this

{code}
   FItems[Index].HashCode := HashCode;
   FItems[Index].Key := Key;
   FItems[Index].Value := Value;
{code}

so all you have to do is ask yourself what would happen on the Value line normally.

> 3. If it is not added as reference, would it be better to use pointer to record as I mentioned in reply above in stead of record? Is adding pointer to record to a generic TList or TDictionary a proper implementation? I am affraid after few more Delphi upgrade, this will no longer valid and force to change to TObject
> 

It is no more right or wrong.  I personally would not use a pointer because now 
you have memory cleanup (in addition to extra code to allocate the memory etc) 
to worry about whereas if you just did straight records you don't, the will auto 
cleanup for you.

> Edited by: Chen Yap Chia on Mar 25, 2014 3:50 AM


-- 
Jeff Overcash (TeamB)
       (Please do not email me directly unless  asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted  corridors of Whitehall.
              (Fish)
0
Jeff
3/25/2014 2:57:22 PM
Chen wrote:

> I can't find an IndexOf like TStringList do to locate Item Index by
> using Key. In TDictionary ContainKey function, it calls GetBucketIndex
> which is a private method, is this for checking item index?

You don't need to retreive the index.  ContainsKey() tells you whether or 
not a given Key exists in the dictionary.  You would pass the desired Key 
to the Items[] property or the TryGetValue() method to retrieve the value 
for a given Key, or pass the Key to the Remove() method to remove the value 
of a given Key.  If you need to iterate through a dictionary, use its GetEnumerator() 
method, or a for...in loop.

> FDict.Add(1, rec);
>
> The record added as reference to the record or cloning value from
> record?

It is a copy of the original, it is not a reference to the original.  If 
you need that, you have to store a pointer instead.

> As I have seen from the code, it seems copying value rather than referencing 
rec.

Yes.

> If it is not added as reference, would it be better to use pointer
> to record as I mentioned in reply above in stead of record?

You can do that, but then you are responsible for manually allocating and 
freeing the memory for each record that you store.  The alternative is to 
change your record into a class and let ARC handle the memory management 
for you.

--
Remy Lebeau (TeamB)
0
Remy
3/25/2014 5:18:57 PM
> You can do that, but then you are responsible for manually allocating and 
> freeing the memory for each record that you store.  The alternative is to 
> change your record into a class and let ARC handle the memory management 
> for you.

There is a question been puzzling me for quite some time, TObject vs Record. Does TObject make any different in term of performance compare to record as I am going to have a lot of record created.


Another problem with TDictionary is when i know exactly the index how can I get the value with index? Or I I shouldn't use TDictionary?

FItems for TDIctionary is made private, how if I use class helper to gain access to it and add a ItemByIndex[AIndex: Integer]: TValue? I mean, in my TDictionary derived class.


Just tried out TDictionaryHelper<TKey,TValue> = class helper for TDictionary<TKey,TValue> but it failed to compile.

Besides, if I need to swift position in between two items, how can I do it? In traditional TList and TStringList, I can do the following:

        T := List.Objects[i];
        Str := List[i];
        List.Objects[i] := List.Objects[j];
        List[i] := List[j];
        List.Objects[j] := T;
        List[j] := Str;

Edited by: Chen Yap Chia on Mar 25, 2014 7:30 PM
0
Chen
3/26/2014 2:32:25 AM
Chen Yap Chia wrote:
> There is a question been puzzling me for quite some time, TObject vs Record. Does TObject make any different in term of performance compare to record as I am going to have a lot of record created.
> 
> 
> Another problem with TDictionary is when i know exactly the index how can I get the value with index? Or I I shouldn't use TDictionary?
> 

Look at ToArray.  Treat that as read only though.  Never try to assign a 
TPair<Key,Value> directly to it (it won't add it to the dictionary).  The key 
needs to be hashed on adding.  Use Add or AddOrSet to add new/replace key/value.

> FItems for TDIctionary is made private, how if I use class helper to gain access to it and add a ItemByIndex[AIndex: Integer]: TValue? I mean, in my TDictionary derived class.
> 
> 
> Just tried out TDictionaryHelper<TKey,TValue> = class helper for TDictionary<TKey,TValue> but it failed to compile.
> 
> Besides, if I need to swift position in between two items, how can I do it? In traditional TList and TStringList, I can do the following:
> 
>         T := List.Objects[i];
>         Str := List[i];
>         List.Objects[i] := List.Objects[j];
>         List[i] := List[j];
>         List.Objects[j] := T;
>         List[j] := Str;
> 

Dictionaries are not ordered in concept so there is no "between" two items.  It 
is not an ordered list, it is a data structure that associates a key with a 
value.  The current internal structure is an array so internally today it has an 
ordering, but that can change in the future because the dictionary concept 
itself is not naturally ordered.  That is why its internal structure is private.

> Edited by: Chen Yap Chia on Mar 25, 2014 7:30 PM


-- 
Jeff Overcash (TeamB)
       (Please do not email me directly unless  asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted  corridors of Whitehall.
              (Fish)
0
Jeff
3/26/2014 3:19:54 AM
Hello Chen,

> There is a question been puzzling me for quite some time, TObject vs
> Record. Does TObject make any different in term of performance compare
> to record as I am going to have a lot of record created.

That depends on how you are using them.

> Another problem with TDictionary is when i know exactly the index how
> can I get the value with index? Or I I shouldn't use TDictionary?

A Dictionary is not designed for accessing items by index.  TDictionary does 
have a ToArray() method, but then you are allocating a new array and filling 
it with the entire contents of the Dictionary just to access a specific index, 
which is overkill.  The alternative is to get the Dictionary's Enumerator 
and loop through it until you reach the desired index.

> FItems for TDIctionary is made private, how if I use class helper to
> gain access to it and add a ItemByIndex[AIndex: Integer]: TValue?
> Just tried out TDictionaryHelper<TKey,TValue> = class helper for
> TDictionary<TKey,TValue> but it failed to compile.

IIRC, Generics do not support helpers yet.

> Besides, if I need to swift position in between two items, how can I
> do it?

You cannot do that with a Dictionary.

Based on your descriptions, TDictionary is not suitable for your needs.

--
Remy Lebeau (TeamB)
0
Remy
3/26/2014 5:40:09 PM
> That depends on how you are using them.

I am going to have lot of record created, for existing usage they are mainly for storing data, that was why we have chosen record over tobject. But now if we are going to keep using tstringlist, things we can do is to wrap the record pointer into a tobject class in order to be able to add to string list or change record to tobject. Will it leads too many of overhead when changing record to object? FYI, thousands of records required to be created.

> Based on your descriptions, TDictionary is not suitable for your needs.
Yeah, I have given up TDIctionary. Looking else where now.

Besides changing record to object, how if creating a new class which include 2 TList. 

TNewList<TKey,TValue> = class
  KeyList: TList<TKey>
  ValueList: TList<TValue>


   function Add(AKey: TKey; AValue: TValue): Integer;
   
   property Items[AIndex: Integer]

   ... etc ,,,
end;

Since TValue can be anytype, so I can still use it with my record pointer.

Any suggestion?
0
Chen
3/27/2014 1:56:47 AM
I have created a new list for my own usage as below, tested seems work, but need help to verify something.

1. Am i doing the correct way for generic class?
2. for Delete method, I call both PObject(@Item.Key).DisposeOf and PObject(@Item.Value).DisposeOf after removing the item from TList. Is this proper as I have seen TObjectDictionary were doing same. Does it work for all kind of data type say TSpecialList<string,PMyRec> ? (PMyRec = ^TMyRec (record)).For ARC enabled, those objects that are created in record, will be freed automatically once record pointer has been disposed, right?


TSpecializeList<TKey,TValue> = class
  private
    type
      TSpecialItem<TKey,TValue> = record
        Key: TKey;
        Value: TValue;
        constructor Create(const Akey: TKey; const AValue: TValue);
      end;
  private
    FList: TList<TSpecialItem<TKey,TValue>>;
    FComparerKey: IComparer<TKey>;
    FComparerValue: IComparer<TValue>;

    function GetValue(const AKey: TKey): TValue;
    procedure SetSorted(const Value: Boolean);
  protected
    procedure Sort; virtual;
  public
    constructor Create;

    function Add(const Akey: TKey; const AValue: TValue): Integer;
    function IndexOf(const AKey: TKey): Integer;
    procedure Delete(const AIndex: Integer);

    property Sorted: Boolean read FSorted write SetSorted;
    property Values[const AKey: TKey]: TValue read GetValue;
  end;


procedure TSpecializeList<TKey, TValue>.SetSorted(const Value: Boolean);
begin
  if FSorted <> Value then
  begin
    if Value then
      Sort;

    FSorted := Value;
  end;
end;

procedure TSpecializeList<TKey, TValue>.Sort;
begin
  FList.Sort(TComparer<TSpecializeList<TKey,TValue>.TSpecialItem<TKey,TValue>>.Construct(
    function (const L, R: TSpecializeList<TKey,TValue>.TSpecialItem<TKey,TValue>): Integer
    begin
      Result := FComparerKey.Compare(L.Key, R.Key);
    end
  )) ;
end;

constructor TSpecializeList<TKey, TValue>.Create;
begin
  FComparerKey := TComparer<TKey>.Default;
  FComparerValue := TComparer<TValue>.Default;

  FList := TList<TSpecialItem<TKey,TValue>>.Create;

  FSorted := False;
end;

function TSpecializeList<TKey, TValue>.Add(const Akey: TKey;
  const AValue: TValue): Integer;
begin
  FList.Add(TSpecializeList<TKey,TValue>.TSpecialItem<TKey,TValue>.Create(Akey,AValue));
end;

procedure TSpecializeList<TKey, TValue>.Delete(const AIndex: Integer);
var
  Item: TSpecialItem<TKey, TValue>;
begin
  if (AIndex < 0) or (AIndex >= Count) then
    raise Exception.Create('Index out of bound.');

  Item := FList.Items[AIndex];
  FList.Delete(AIndex);
  PObject(@Item.Key)^.DisposeOf;
  PObject(@Item.Value)^.DisposeOf;
end;

Edited by: Chen Yap Chia on Mar 27, 2014 5:52 PM
0
Chen
3/28/2014 12:56:00 AM
Reply:

Similar Artilces:

''''''''''''''''''''
Name: haznen Email: haznenatyahoodotcom Product: Gran Paradiso Alpha 8 Summary: '''''''''''''''''''' Comments: '''''''''''''''''''''''''''''''''''' Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061204 UGES/1.7.2.0 GranParadiso/3.0a1 From URL: http://www.mozilla.org/projects/granparadiso/ Note to readers: Hendrix gives...

'''''
Name: mario Email: ramar17atfastwebnetdotit Product: Gran Paradiso Alpha 2 Summary: ''''' Comments: K: Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a2) Gecko/20070206 GranParadiso/3.0a2 ...

Occaisonal Build problems (type 'xxx' exists in both 'yyy.dll' and 'xxx.dll')?
Hello: Been working with Express for about 2 months now -- and it generally works fine -- but I occaisonally get this error message when I rebuild projects to rerun it: ------ Rebuild All started: Project: http://localhost/TestIV/, Configuration: Debug .NET ------ Build Web Beginning D:\DEV\DEV_NET\CS\SITES\TestIV\portal.aspx(9,31): error CS0433: The type 'ASP.Portal' exists in both 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.40607\Temporary ASP.NET Files\testiv\2bc5e680\fdf16dd9\f3iai7un.dll' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.40607\Temporary ASP.NET Files\testiv\...

'do' won't 'do' if '/'
Greetings to All from Au, Have a NetWare Perl 5.8.4 and wanted to tweak File\Spec\NW.pm to try and standardise on '/' separators. If I run a test script (t/uni/lower.t) with an unmodified NW.pm, it calls t/uni/case.pl, that, in case.pl, (when the path separators are '\'), the $file is '..\lib\unicore\To\Lower.pl' and the following code portion works, with $simple getting a returned table: sub casetest { my ($base, $spec, $func) = @_; my $file = File::Spec->catfile(File::Spec->catdir(File::Spec->updir, "lib", &qu...

value of type 'XXX' cannot be converted to type 'XXX'
 I've had this issue with VS2008 lately that is driving me crazy.  I have a website where I built a class that does all my Web Service interaction.  This class returns instances of Web Service proxies, or list of the same.  In my web page I'll create a temporary variable (Dim - I'm using VB) with the same type that my service class is going to return.  When I assign my variable to the return of the method, I'm getting a message similar to the following"Value of type 'Namespace.Foo' cannot be converted to type 'Namespace.Foo'. ...

'''
Name: L Lachowsky Email: e2brutus_10atyahoodotcom Product: Firefox Summary: ''' Comments: why duddn this surprise me... I change default server from IE to Mozilla, and then i get error messages. well, shud I decide to not get on my computer with Mozilla..or shud I risk security breeches with IE....hmmm at least i can get on the internet with IE Browser Details: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this fee...

Cast from type ''''DBNull'''' to type ''''String'''' is not valid.
How do I avoid getting this error: Cast from type ''''DBNull'''' to type ''''String'''' is not valid. I am trying to get values from the database into a form for updating using a Datareader, SQL is set to allow nulls for certain fields as they are not required but the only way I can get the form to display is by adding a space in SQL. Is there another way around this? Check if it is equal to DBNull.Value first and if it is, don't do the cast.Stanley Tan theSpoke Blog Where in the code does it need to go? I am using the following and it's the profile that isn't always requi...

-189 Unable to find in index 'XXX' for table 'XXX'
We are using the Sybase SQL Anywhere 9.0.1.4339 in a healthcare environment. Recently a very critical problem arised at a customer system. The database reported a missing index entry. Error: General error: Unable to find in index 'XXX' for table 'XXX' NativeError: State:S1000,Native:-189,Origin:[Sybase][ODBC Driver][Adaptive Server Anywhere] The validation tool dbvalid reported: Foreign key "XXX" has missing index entries. A database rebuild did repair the corrupt index. But the root cause, how the index got corrupted is not found yet. Within our...

table_info('','','','%') cannot return any types
I was recently confirming table_info special cases and discovered the case for getting table_types cannot work. table_info('','','','%') should return a list of table types but it returns a list of empty strings instead: my @types = $h->tables('', '', '', '%'); print "all types:\n", join("xxx\n", @types), "\n"; # should output something like: # "dbo" # "INFORMATION_SCHEMA" # "sys" # and actually outputs: xxx xxx It seems to be down to the following ...

Bugizilla 4.4.8 : There was an error sending mail from 'bugzilla-daemon@xxx.xxx.x.xxx' to 'mail-id@domain': Couldn't authenticate 'mail-id@gmail.com:...'
Dear All, I had configured Bugizilla 4.4.8 almost 8 months back for our internal purpose and was working fine all these days. Today morning it started giving the following error when I try to login as administrator. -----ERROR----------------------------------------------- An unexpected error occurred. This could be a temporary problem, or some code is behaving incorrectly. If this problem persists, please email this page to mail-d@domain with details of what you were doing at the time this message appeared. URL: http://192.168.0.138/complaints/index.cgi There was an error ...

'b'..'a'
Hello. I'm using defferent 5.6.0's for Win32. I wonder wheter following behaviour is intentional or not: d:\>perl -e "print 'b'..'c'" bc d:\>perl -e "print 'b'..'a'" bcdefghijklmnopqrstuvwxyz I expected empty list in latter case, like in perl -e "print 'bb'..'a'" <!ENTITY Vadim REALLIFE "Vadim V.Konovalov, St.Petersburg, Russia"> &Vadim; On Wed, Sep 20, 2000 at 03:14:41PM +0400, Konovalov, Vadim wrote: > Hello. > > I'm using defferent 5.6.0'...

'or' or 'union'
Hello I was just wondering, in general what is better to use, an 'or' clause in a select or a 'union' to join two selects together. Do both statements create work tables? Many thanks Alex I think OR will be better than union. because suppose u have 3 tables and using OR u can join table a and table b and table c so each table will have only one read. but using union you will join table a and table b and in another query of union u will use table (a or b) and table c so ur one read is more in union . Ramdas Alex Cheung wrote: > Hello > >...

'IN' Clause or 'OR'
Hello, [1]: select * from TABLEA where COL1 IN('value1','value2''valu3'....) [2]:select * from TABLEA where COL1 = 'value1' OR COL1= 'value2' OR COL1='valu3'. TABLEA is a huge table and it has non-clustered index on COL1. Among the above 2 queries, which query will give me the better performance or fast response and WHY? What is the difference between 'IN' and 'OR' clauses as for as Sybase Optimization is concerned. Which is the better one to be used on huge tables. Thanks. Mac An IN list is treated ...

E2094 'operator+' not implemented in type 'XXX' for arguments of type 'int'
Okay I have a problem; I am trying to extend a string class that I wrote for a friend so I can use it another project I am working on. I have an error that makes absolutely no sense. Here is the code for the copy constructor: String(const String &str) // for copying into a new string object { Size = str.Size; Data = new char[Size+1]; for (int i = 0; i<Size; i++) Data[i] = str[i]; // recieving the following error on the above line: [BCC32 Error] Mystring.h(33): // E2094 'operator+' not implemented in type 'String' for arguments of typ...

Web resources about - TStringList.AddObject('xxx', TObject(^record)) - embarcadero.delphi.ios

Resources last updated: 2/9/2016 12:30:45 PM