elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Introducción a Git (Primera Parte)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  [SRC] [Delphi] Text_Beetwen_Words [by *PsYkE1*]
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [SRC] [Delphi] Text_Beetwen_Words [by *PsYkE1*]  (Leído 2,077 veces)
Psyke1
Wiki

Desconectado Desconectado

Mensajes: 1.089



Ver Perfil WWW
[SRC] [Delphi] Text_Beetwen_Words [by *PsYkE1*]
« en: 23 Agosto 2010, 18:37 pm »

Hola, me he pasado a Delphi hace dos dias y he pasado esta funcion que tenia hecha en VB6...  :P

http://foro.rthacker.net/programacion-visual-basic/%28src%29-%28funcion%29-text_between_words-%28by-*psyke1*%29/

Código
  1. (* * * * * * * * * * * * * * * * * * * * * * * * * *)
  2. (* Function : Text_Beetwen_Words                   *)
  3. (* Author   : *PsYkE1*                             *)
  4. (* Mail     : vbpsyke1@mixmail.com                 *)
  5. (* Date     : 24/8/10                              *)
  6. (* Purpose  : Returns text which is beetwen        *)
  7. (*            two words.                           *)
  8. (* Visit    : http://foro.rthacker.net/            *)
  9. (* * * * * * * * * * * * * * * * * * * * * * * * * *)
  10.  
  11. function InStr(iStart: integer; sText: string; sWord: string): integer;
  12. begin
  13. Result := Pos(sWord,Copy(sText,iStart,Length(sText) - (iStart - 1)));
  14. end;
  15.  
  16. function Text_Beetwen_Words(sTextToAnalyze:String ; sStartWord:String ; sEndWord:string): String;
  17. var
  18.  iPosition1  : Integer;
  19.  iPosition2  : Integer;
  20.  iStart      : Integer;
  21. begin
  22.     iPosition1 := Instr(1,sTextToAnalyze,sStartWord);
  23.     if iPosition1 > 0 then
  24.      begin
  25.        iStart := (iPosition1 + Length(sStartWord));
  26.        iPosition2 := Instr(iStart,sTextToAnalyze,sEndWord);
  27.      end
  28.     else
  29.      exit;
  30.     if iPosition2 > 0 then
  31.      Result := Copy(sTextToAnalyze,iStart,iPosition2 -1);
  32. end;

Un ejemplo:
Código
  1. procedure TForm1.FormCreate(Sender: TObject);
  2.    begin
  3.      (* añade un textbox *)
  4.    edit1.Text:= text_beetwen_words('Hoy estoy muy aburrido','Hoy ',' aburrido');
  5.    end;
  6.  
  7. end.

Devuelve esto:
Citar
estoy muy

DoEvents¡! :P


« Última modificación: 26 Agosto 2010, 16:46 pm por *PsYkE1* » En línea

VanHan

Desconectado Desconectado

Mensajes: 41


.:: [ vHn ] ::.


Ver Perfil WWW
Re: [Delphi] Text_Beetwen_Words [by *PsYkE1*]
« Respuesta #1 en: 24 Agosto 2010, 02:23 am »

Me encanto  ;D Lindo Source

Salu2
[vHn]


En línea

.:: I'm GeeK ::.
Psyke1
Wiki

Desconectado Desconectado

Mensajes: 1.089



Ver Perfil WWW
Re: [Delphi] Text_Beetwen_Words [by *PsYkE1*]
« Respuesta #2 en: 24 Agosto 2010, 02:40 am »

Gracias, ire pasando mis funciones de vb a delphi progresivamente...

DoEvents¡! :P
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines