![]() |
PosEx für Delphi 5?
Gibt es PosEx für Delphi 5?
|
Re: PosEx für Delphi 5?
unter delphi5 gibt es posex nicht. Aber du kannst dir doch ohne probleme selbst eine solche Funktion schreiben.
|
Re: PosEx für Delphi 5?
das hab ich mal selber geschrieben, sollte posex fast gleichen
Delphi-Quellcode:
function TMain_Form.fnPos(sRow, sChar : String; iVonSt : Integer) : Integer;
var i, iLen : Integer; begin iLen := Length(sRow); For i := iVonSt To iLen Do Begin If sRow[i] = sChar Then Begin fnPos := i; Break; End; End; end; |
Re: PosEx für Delphi 5?
deine Funktion dürfte aber nicht funktionieren wenn man nicht nur nach einem zeischen sondern nach einem String sucht.
|
Re: PosEx für Delphi 5?
Mein PosEx-Klon:
Delphi-Quellcode:
function PosEx(Substr, s : string; Offset : Integer = 0) : Integer;
begin Result := 0; Delete(s, 1, Offset); Result := Pos(Substr, s) + Offset; end; |
Re: PosEx für Delphi 5?
Zitat:
Der liefert ja immer ein Ergebnis, wenn Offset größer 0 ist. Auch wenn Substr überhaupt nicht vor kommt. PosEx ist in Delphi folgendes - aus OH: Zitat:
|
Re: PosEx für Delphi 5?
Zitat:
|
Re: PosEx für Delphi 5?
|
Re: PosEx für Delphi 5?
Der originale PosEx-Code ist folgender:
Delphi-Quellcode:
Vielleicht hilft's dir ja ;)
(* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1 * * The implementation of function PosEx is subject to the * Mozilla Public License Version 1.1 (the "License"); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at [url]http://www.mozilla.org/MPL/[/url] * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is Fastcode * * The Initial Developer of the Original Code is Fastcode * * Portions created by the Initial Developer are Copyright (C) 2002-2004 * the Initial Developer. All Rights Reserved. * * Contributor(s): Aleksandr Sharahov * * ***** END LICENSE BLOCK ***** *) function PosEx(const SubStr, S: string; Offset: Integer = 1): Integer; asm test eax, eax jz @Nil test edx, edx jz @Nil dec ecx jl @Nil push esi push ebx mov esi, [edx-4] //Length(Str) mov ebx, [eax-4] //Length(Substr) sub esi, ecx //effective length of Str add edx, ecx //addr of the first char at starting position cmp esi, ebx jl @Past //jump if EffectiveLength(Str)<Length(Substr) test ebx, ebx jle @Past //jump if Length(Substr)<=0 add esp, -12 add ebx, -1 //Length(Substr)-1 add esi, edx //addr of the terminator add edx, ebx //addr of the last char at starting position mov [esp+8], esi //save addr of the terminator add eax, ebx //addr of the last char of Substr sub ecx, edx //-@Str[Length(Substr)] neg ebx //-(Length(Substr)-1) mov [esp+4], ecx //save -@Str[Length(Substr)] mov [esp], ebx //save -(Length(Substr)-1) movzx ecx, byte ptr [eax] //the last char of Substr @Loop: cmp cl, [edx] jz @Test0 @AfterTest0: cmp cl, [edx+1] jz @TestT @AfterTestT: add edx, 4 cmp edx, [esp+8] jb @Continue @EndLoop: add edx, -2 cmp edx, [esp+8] jb @Loop @Exit: add esp, 12 @Past: pop ebx pop esi @Nil: xor eax, eax ret @Continue: cmp cl, [edx-2] jz @Test2 cmp cl, [edx-1] jnz @Loop @Test1: add edx, 1 @Test2: add edx, -2 @Test0: add edx, -1 @TestT: mov esi, [esp] test esi, esi jz @Found @String: movzx ebx, word ptr [esi+eax] cmp bx, word ptr [esi+edx+1] jnz @AfterTestT cmp esi, -2 jge @Found movzx ebx, word ptr [esi+eax+2] cmp bx, word ptr [esi+edx+3] jnz @AfterTestT add esi, 4 jl @String @Found: mov eax, [esp+4] add edx, 2 cmp edx, [esp+8] ja @Exit add esp, 12 add eax, edx pop ebx pop esi end; Chris |
Re: PosEx für Delphi 5?
Zitat:
|
Re: PosEx für Delphi 5?
@SirThornberry:
Da ich den Lizenztext über der Prozedur entdeckt hab', war es für mich direkt klar, dass man sie problemlos verbreiten darf (inkl. Lizenz). Außerdem sollte Borland sowieso keine Probleme machen, da der Code noch nicht einmal von ihnen ist. Naja, sollte ich mich geirrt haben, tut es mir sehr leid... :oops: Viele Grüße, Chris |
Re: PosEx für Delphi 5?
Beitrag ist vorerst wieder aktiviert/eingeblendet :-D
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:09 Uhr. |
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