AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Msn contact list

Ein Thema von Razor · begonnen am 27. Jan 2009 · letzter Beitrag vom 29. Jan 2009
Thema geschlossen
Seite 2 von 4     12 34      
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.858 Beiträge
 
Delphi 11 Alexandria
 
#11

Re: Msn contact list

  Alt 27. Jan 2009, 20:34
Zitat:
if MSNMyContact.Status=status then
MSNMyContact is reference -> points to Nil!!!!!!
Zitat:
Delphi-Quellcode:
BEGIN
    MSNMyContact := (MSNMyContacts.Item(v_Count) as IMessengerContact);
Afterwards you assign it.
As you been told before, You have to assign it first!
Markus Kinzler
 
Razor
(Gast)

n/a Beiträge
 
#12

Re: Msn contact list

  Alt 27. Jan 2009, 20:38
Zitat von mkinzler:
Zitat:
if MSNMyContact.Status=status then
MSNMyContact is reference -> points to Nil!!!!!!
Zitat:
Delphi-Quellcode:
BEGIN
    MSNMyContact := (MSNMyContacts.Item(v_Count) as IMessengerContact);
Afterwards you assign it.
As you been told before, You have to assign it first!

How can it point to nil if you define it in variable in function

Delphi-Quellcode:
const
  MISTATUS_UNKNOWN = $00000000;
  MISTATUS_OFFLINE = $00000001;
  MISTATUS_ONLINE = $00000002;
  MISTATUS_INVISIBLE = $00000006;
  MISTATUS_BUSY = $0000000A;
  MISTATUS_BE_RIGHT_BACK = $0000000E;
  MISTATUS_IDLE = $00000012;
  MISTATUS_AWAY = $00000022;
  MISTATUS_ON_THE_PHONE = $00000032;
  MISTATUS_OUT_TO_LUNCH = $00000042;
  MISTATUS_LOCAL_FINDING_SERVER = $00000100;
  MISTATUS_LOCAL_CONNECTING_TO_SERVER = $00000200;
  MISTATUS_LOCAL_SYNCHRONIZING_WITH_SERVER = $00000300;
  MISTATUS_LOCAL_DISCONNECTING_FROM_SERVER = $00000400;

function contactslist(status:[b]MISTATUS[/b]):string;
Angehängte Dateien
Dateityp: rar msn_contact_list_648.rar (36,7 KB, 10x aufgerufen)
 
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.858 Beiträge
 
Delphi 11 Alexandria
 
#13

Re: Msn contact list

  Alt 27. Jan 2009, 20:41
Zitat:
How can it point to nil if you define it in variable in function
Because it is an interface reference ( pointer).

It seems you don't know much about oop!
Markus Kinzler
 
Razor
(Gast)

n/a Beiträge
 
#14

Re: Msn contact list

  Alt 27. Jan 2009, 20:43
Ofcourse i don't,i am a beginer in delphi programing i know like 13% of delphi.

Bascily what i want to do is filter the contacts by status thats all..
 
Razor
(Gast)

n/a Beiträge
 
#15

Re: Msn contact list

  Alt 28. Jan 2009, 18:16
Well?
 
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.858 Beiträge
 
Delphi 11 Alexandria
 
#16

Re: Msn contact list

  Alt 28. Jan 2009, 18:23
As you told severall times before you just can evaluate after assigning the reference to an object!
Markus Kinzler
 
Razor
(Gast)

n/a Beiträge
 
#17

Re: Msn contact list

  Alt 28. Jan 2009, 18:33
Can you show a working example couse i don't know what you are talking about.
 
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.858 Beiträge
 
Delphi 11 Alexandria
 
#18

Re: Msn contact list

  Alt 28. Jan 2009, 18:36
Reread my answers
Markus Kinzler
 
Namenloser

Registriert seit: 7. Jun 2006
Ort: Karlsruhe
3.724 Beiträge
 
FreePascal / Lazarus
 
#19

Re: Msn contact list

  Alt 28. Jan 2009, 19:27
An object in Delphi is actually a 4 byte long pointer to a structure in the memory (on the heap). At the beginning, the pointer contains a random adress (often nil, but it could be whatever value the register had before). So we have to create the structure in the memory first and then remember the adress of this structure in the variable.
We do this by writing something like this:
Delphi-Quellcode:
var
  MyStringlist: TStringlist; // declare the variable stringlist as an instance of a tstringlist-class.
begin
  MyStringlist := TStringlist.Create; // Create the Stringlist-object

  // Now we can use the object
  MyStringlist.LoadFromFile('readme.txt');

  MyStringlist.Free; // Destroy the object and free the allocated memory
end;
A class (e.g. TStringlist) describes "what the object does", which properties and which methods it has. Classes are something like "construction plans" for objects. If we build the object described in the construction plan, we call this object an instance (of the class).

So, one of the coolest things about OOP is, that you can extend (or inherit) classes. When declaring a new class, you can tell Delphi to build this class based on a class that already exists (the parent). Now the new class contains all methods and properties of the parent plus some extra features. Because the child contains everything of the parent (the classes are compatible), you can assign instances of child classed to their parent classes. This works only in one direction of course.

For example the TStrings-class has basic properties and methods to work with text. The TStringlist-class extends the class by adding some methods like sorting and saving the data to a file and loading it (i think).

Now we can do something like this:
Delphi-Quellcode:
procedure DoSomething(Strings: TStrings); // Note that the parameter is declared as TStrings
begin
  Strings.Clear; // deletes the text contained in "Strings". Just some random example...
end;

var
  MyStringlist: TStringlist; // Note that we use a TStringlist
begin
  MyStringlist := TStringlist.Create;
  MyStringlist.LoadFromFile('readme.txt');

  DoSomething(MyStringlist); // This works now, because TStrings is the parent of TStringlist, therefore TStringlist has everything TStrings has.

  MyStringlist.Free;
end;
This gets really interesting when it comes to overriding methods. "Strings.Clear" in line 3 is a bad example because it calls the same method for both TStrings and TStringlist (TStringlist doesn't override it). But classes can also override methods of their parents (if the method is declared as "virtual" in the parent class). Then one line can call different methods depending on which class the object is an instance of.

Look at the TGraphic class. The base class doesn't even do anything except declaring the methods used by the children (TBitmap, TJPEGImage and so on...). All codes for loading the image formats are implemented in the child classes and override the methods of the base class. This way, we can work with graphic without knowing which format they have.

Now because most of the methods of the base class don't contain any code, they are marked as "abstract". When trying to call them directly, you get an exception stating something like "abstract error".

A more flexible alternative to those only abstract objects are interfaces. Interfaces may not contain code. They only describe which functionality an object must have. This way a program (or a programmer) doesn't have to care about each individual implementaion as long as it supports the interface. Whatever the object behind the interface is, it doesn't matter, the code stays the same.

This is how I understand interfaces.


What you have done, is, you have declared some variables as interfaces (IMessenger, IMessengerContacts, IMessengerContact), but you haven't assigned any instances to them. Remember, interfaces only describe the functionality, but they don't contain any themselves.

I hope you understand my explanation. Please note that I haven't really worked with interfaces yet myself (except for reading out XML files). If I left out something, please search for a tutorial about OOP, I'm sure there are plenty of them on the internet.
 
Razor
(Gast)

n/a Beiträge
 
#20

Re: Msn contact list

  Alt 28. Jan 2009, 21:56
Guyz the code works its just the if MSNMyContact.Status=status then BEGIN this is making problems.Code WORKS WAKE UP lol IT WORKS!! i just want to filter the contacts.
 
Thema geschlossen
Seite 2 von 4     12 34      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:33 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz