Einzelnen Beitrag anzeigen

Benutzerbild von ErazerZ
ErazerZ

Registriert seit: 27. Mai 2005
Ort: Baden
315 Beiträge
 
Delphi 2007 Enterprise
 
#5

Re: Copy und Delete ohne Strings

  Alt 28. Mai 2007, 20:56
Sowas?
Delphi-Quellcode:
function MyLength(s: string): Integer;
begin
  asm
    xor ecx, ecx
    cmp dword ptr [s], 0
    je @@exit
    mov eax, [s]
  @@start:
    inc ecx
    cmp byte ptr [eax+ecx], 0
    jne @@start
  @@exit:
    mov [result], ecx
  end;
end;

function MyCopy(s: string; start, len: Integer): string;
var
  x: Integer;
begin
  result := '';
  if (start >= 0) and (len >= 0) then
  begin
    for x := start to (start + len) -1 do
    begin
      result := result + s[x];
    end;
  end;
end;

procedure MyDelete(var s: string; start, len: Integer);
var
  x: Integer;
  tmp: string;
begin
  if (start >= 0) and (len >= 0) then
  begin
    tmp := '';
    if (start > 1) then
    begin
      for x := 1 to start -1 do
      begin
        tmp := tmp + s[x];
      end;
    end;
    x := (start + len);
    repeat
      tmp := tmp + s[x];
      x := x +1; // kein inc >_>
    until s[x] = #0; // achtung prüft nur auf #0 zeichen!
    s := tmp;
  end;
end;
Aber du kannst ja immer noch die APIs benutzen, lstrlen etc.
  Mit Zitat antworten Zitat