AGB  ·  Datenschutz  ·  Impressum  







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

PosEx für Delphi 5?

Ein Thema von xZise · begonnen am 27. Mär 2007 · letzter Beitrag vom 27. Mär 2007
Antwort Antwort
Seite 1 von 2  1 2      
Benutzerbild von xZise
xZise

Registriert seit: 3. Mär 2006
Ort: Waldbronn
4.303 Beiträge
 
Delphi 2009 Professional
 
#1

PosEx für Delphi 5?

  Alt 27. Mär 2007, 09:19
Gibt es PosEx für Delphi 5?
Fabian
Eigentlich hat MS Windows ab Vista den Hang zur Selbstzerstörung abgewöhnt – mkinzler
  Mit Zitat antworten Zitat
Benutzerbild von SirThornberry
SirThornberry
(Moderator)

Registriert seit: 23. Sep 2003
Ort: Bockwen
12.235 Beiträge
 
Delphi 2006 Professional
 
#2

Re: PosEx für Delphi 5?

  Alt 27. Mär 2007, 09:20
unter delphi5 gibt es posex nicht. Aber du kannst dir doch ohne probleme selbst eine solche Funktion schreiben.
Jens
Mit Source ist es wie mit Kunst - Hauptsache der Künstler versteht's
  Mit Zitat antworten Zitat
Benutzerbild von Andidreas
Andidreas

Registriert seit: 27. Okt 2005
1.110 Beiträge
 
Delphi 10.1 Berlin Enterprise
 
#3

Re: PosEx für Delphi 5?

  Alt 27. Mär 2007, 09:37
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;
Ein Programmierer Programmiert durchschnittlich 15 Code Zeilen pro Tag
Wir sind hier doch nicht bei SAP!!!

Aber wir habens bald
  Mit Zitat antworten Zitat
Benutzerbild von SirThornberry
SirThornberry
(Moderator)

Registriert seit: 23. Sep 2003
Ort: Bockwen
12.235 Beiträge
 
Delphi 2006 Professional
 
#4

Re: PosEx für Delphi 5?

  Alt 27. Mär 2007, 09:42
deine Funktion dürfte aber nicht funktionieren wenn man nicht nur nach einem zeischen sondern nach einem String sucht.
Jens
Mit Source ist es wie mit Kunst - Hauptsache der Künstler versteht's
  Mit Zitat antworten Zitat
Benutzerbild von xZise
xZise

Registriert seit: 3. Mär 2006
Ort: Waldbronn
4.303 Beiträge
 
Delphi 2009 Professional
 
#5

Re: PosEx für Delphi 5?

  Alt 27. Mär 2007, 09:44
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;
Fabian
Eigentlich hat MS Windows ab Vista den Hang zur Selbstzerstörung abgewöhnt – mkinzler
  Mit Zitat antworten Zitat
IngoD7

Registriert seit: 16. Feb 2004
464 Beiträge
 
Delphi 7 Enterprise
 
#6

Re: PosEx für Delphi 5?

  Alt 27. Mär 2007, 10:00
Zitat von xZise:
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;
Den Klon kannste vergessen, oder?
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:
Delphi-Syntax:

function PosEx(const SubStr, S: string; Offset: Cardinal = 1): Integer;

Beschreibung:
PosEx gibt den Index von SubStr in S zurück, wobei die Suche bei Offset begonnen wird. Wenn Offset 1 ist (Vorgabe), entspricht PosEx Pos.

PosEx gibt 0 zurück, wenn SubStr nicht gefunden wird, Offset größer als die Länge von S ist oder Offset kleiner als 1 ist.
  Mit Zitat antworten Zitat
Benutzerbild von xZise
xZise

Registriert seit: 3. Mär 2006
Ort: Waldbronn
4.303 Beiträge
 
Delphi 2009 Professional
 
#7

Re: PosEx für Delphi 5?

  Alt 27. Mär 2007, 10:07
Zitat von IngoD7:
Den Klon kannste vergessen, oder?
Der liefert ja immer ein Ergebnis, wenn Offset größer 0 ist. Auch wenn Substr überhaupt nicht vor kommt.
Stimmt... Werde das also nochmal überprüfen, ob Pos = 0 ist ...
Fabian
Eigentlich hat MS Windows ab Vista den Hang zur Selbstzerstörung abgewöhnt – mkinzler
  Mit Zitat antworten Zitat
Benutzerbild von bitsetter
bitsetter

Registriert seit: 17. Jan 2007
1.169 Beiträge
 
Turbo Delphi für Win32
 
#8

Re: PosEx für Delphi 5?

  Alt 27. Mär 2007, 10:15
Hi,

in der Code-Lib ist auch PosEx drin:
PosEx
Gruß bitsetter
"Viele Wege führen nach Rom"
Wolfgang Mocker (geb. 1954), dt. Satiriker und Aphoristiker
  Mit Zitat antworten Zitat
Benutzerbild von CK_CK
CK_CK

Registriert seit: 30. Aug 2005
Ort: Dortmund, Germany
388 Beiträge
 
Delphi 2006 Enterprise
 
#9

Re: PosEx für Delphi 5?

  Alt 27. Mär 2007, 10:31
Der originale PosEx-Code ist folgender:
Delphi-Quellcode:
(* ***** 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;
Vielleicht hilft's dir ja

Chris
Chris
» «
Mehr von mir (Programme, etc.): http://www.kroegerama.de
  Mit Zitat antworten Zitat
Benutzerbild von Andidreas
Andidreas

Registriert seit: 27. Okt 2005
1.110 Beiträge
 
Delphi 10.1 Berlin Enterprise
 
#10

Re: PosEx für Delphi 5?

  Alt 27. Mär 2007, 11:58
Zitat von SirThornberry:
deine Funktion dürfte aber nicht funktionieren wenn man nicht nur nach einem zeischen sondern nach einem String sucht.
joa des weiß ich das meine funktion nur funktioniert wenn man nach einem bestimmten zeichen sucht, aber ich bin davon ausgegangen das posex genau das macht
Ein Programmierer Programmiert durchschnittlich 15 Code Zeilen pro Tag
Wir sind hier doch nicht bei SAP!!!

Aber wir habens bald
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


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 06:05 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