Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Zugriffsverletzung ??? Ich kappiers nicht! (https://www.delphipraxis.net/22186-zugriffsverletzung-ich-kappiers-nicht.html)

IngoD7 13. Mai 2004 19:09

Re: Zugriffsverletzung ??? Ich kappiers nicht!
 
Ist das abgefragte Feld an der Stelle vielleicht ein leerer String? Dann geht die Abfrage auf ein bestimmtes Zeichen des Strings in die Hose.

glkgereon 13. Mai 2004 19:09

Re: Zugriffsverletzung ??? Ich kappiers nicht!
 
aarghh, ich idiot!!!

wahrscheinlich isses das:

du hast 2 variablen Commands, er weiss nit, welche er nehmen soll

wobei, stand nicht mal innem buch, das die lokale die globale übergeht?

ausprobieren

faux 13. Mai 2004 19:13

Re: Zugriffsverletzung ??? Ich kappiers nicht!
 
Delphi-Quellcode:
unit Unit2;

interface

uses SysUtils, AgentObjects_TLB;

const
  LMax = 2;

type
  TCommandAction = (ccTrue, ccFalse, ccNoCommand);

function Inizialize(const Command: String; AgentItem: IAgentCtlCharacterEx): TCommandAction;
function ActCommand(Commands: Array of String; AgentItem: IAgentCtlCharacterEx): TCommandAction;

implementation

function Inizialize(const Command: String; AgentItem: IAgentCtlCharacterEx): TCommandAction;
var
  Commands: Array[1..LMax] of String;
  i, j: Integer;
begin
  j := 0; //Hier ist EIN Fehler, weil der Array bei 1 beginnt, aber der ist anscheiden egal..
  if Length(Command) > 0 then
  begin
    for i := 0 to Length(Command) - 1 do //ARG!! der index eines strings beginnt bei 1 und nicht bei 0!!! aber wieso gibz da keine exception?
      if Command[i] <> ' ' then
        Commands[j] := Commands[j] + Command[i] //hier, j ist 0 und er schreibt aber anstandslos auf den array, wie das?
      else
        if j < Lmax then
          inc(j)
        else
          break;
    Result := ActCommand(Commands, AgentItem);
  end
  else
    Result := ccFalse;
end;

function ActCommand(Commands: Array of String; AgentItem: IAgentCtlCharacterEx): TCommandAction;
begin
  if Commands[1][1] = ':' then //Hier tritt sie auf.... hm....
  begin
    result := ccTrue;
  end
  else
    result := ccNoCommand;
end;

end.
hab das ausgebessert. jetzt weiß ich wieso die zugriffsverletzung auftritt, der array ist leer... *gg*

faux 13. Mai 2004 19:18

Re: Zugriffsverletzung ??? Ich kappiers nicht!
 
Zitat:

Zitat von glkbkk
aarghh, ich idiot!!!

wahrscheinlich isses das:

du hast 2 variablen Commands, er weiss nit, welche er nehmen soll

wobei, stand nicht mal innem buch, das die lokale die globale übergeht?

ausprobieren

nein nein nein!

1. mal sind beide variablen lokal und nicht global. denn die eine ist im var teil und die andere in der deklaration...

2. mal heißt eine commands und die andere nur command (ohne s)... *gg*

glkgereon 13. Mai 2004 19:43

Re: Zugriffsverletzung ??? Ich kappiers nicht!
 
hmmm, jetzt wo dus sagst seh ichs auch... :gruebel:


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:46 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz